Locked space for autoformat code

Answered

Hi all. I very often use autoformat code (hot keys  Ctrl+Alt+L) . Does phpStorm have  the ability not to change my minifigured code in some areas ? (Example on photo)

I don't want what my normalize.css unfolded whenever I press Ctrl+Alt+L. Could I freeze some parts of my code ?

----> This is a translation for a Russian-speaking audience

Всем привет. Я очень часто пользуюсь автовыравниванием кода в phpStorm через горячие кнопки Ctrl+Alt+L. Имеет ли Шторм возможность фиксировать часть кода которая не должна выравниваться по нажатию на автовыравниватели ? (Пример на рисунке. Мне необходимо что б мой normalize.css всегда был минимизирован)

9 comments
Comment actions Permalink

Hi there,

Try surrounding that fragment with "noformat" comments (@formatter:off and @formatter:on)

https://www.jetbrains.com/help/phpstorm/code-style.html#d286299e165

1
Comment actions Permalink

I meant this. No other ideas. Try disabling all custom plugins for the moment; try "File | Invalidate Caches..." just in case

1
Comment actions Permalink

Thanks / Спасибо 

0
Comment actions Permalink

I tried use your advice in my header.tpl but it doesn't help/ What is the problem ?

0
Comment actions Permalink

Seems to work OK for me:

The code in red frame area is not getting re-aligned as it otherwise would:

Checked in plain.html file as well as .php (no PHP code/tags though -- only HTML).

I'm using latest stable PhpStorm 2017.2.4

Maybe it's specific to your file (some other nuances). If so -- please share a file somehow (e.g. Google Dive or alike .. so it can be copied without modifications)

0
Comment actions Permalink

File - 

https://drive.google.com/file/d/1jigzOaEsbZMIRfJdbmZORl63NittWcsm/view?usp=sharing 

I used the same PhpStorm 2017.2.4

But after I pushe Ctrl+Alt+L my minimized styles stay biggest

0
Comment actions Permalink

What exactly does not work there for you?

  • I have renamed file into "top_menu.php" (so it's treated the same as yours, because by default *.tpl files are associated with Smarty templates)
  • I've added extra indent
  • I've tried to reformat -- the <style> tag remains as is.

As you can see from the screenshot -- the HTML code below got reformatted but the <style> tag remains as is. I've made no other modification to your file except adding some indent to better see if formatter will touch that area. but even the original file shows the same behaviour.

Maybe it's your settings somewhere? Does it work in other places (e.g. in PHP code; other file)? Maybe you have actually disabled that option by mistake?

0
Comment actions Permalink

I tried to use these markers 

<!-- @formatter:off -->

<!-- @formatter:on -->

in other files (html, css) the result is similar. phpStorm  doesn't ignore the code between markers. Where could I disable these settings? 

my settings file - >

https://drive.google.com/file/d/1JqgpMX5IZkfjKJeETd33mwHFO9yomalz/view?usp=sharing

0
Comment actions Permalink

Thanks it's helped!

0

Please sign in to leave a comment.