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 всегда был минимизирован)
Please sign in to leave a comment.
Hi there,
Try surrounding that fragment with "noformat" comments (@formatter:off and @formatter:on)
https://www.jetbrains.com/help/phpstorm/code-style.html#d286299e165
Thanks / Спасибо
I tried use your advice in my header.tpl but it doesn't help/ What is the problem ?
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)
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
What exactly does not work there for you?
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?
I tried to use these markers
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
I meant this. No other ideas. Try disabling all custom plugins for the moment; try "File | Invalidate Caches..." just in case
Thanks it's helped!