Faster way to surround a block of HTML with tags, and auto indent?
Right now if I want to surround a block fo HTML with a DIV for example, it takes two steps. I have to wrap the code, and then select it and reformat.
I'm wondering if there's a faster way than this:
(click image below to see animation)
请先登录再写评论。
Hi there,
I may only suggest trying dedicated Surround Live Template -- should work.
https://confluence.jetbrains.com/display/PhpStorm/Live+Templates+%28Snippets%29+in+PhpStorm#LiveTemplates%28Snippets%29inPhpStorm-CreatingSurroundTemplates
I don't use surround, I instead ctrl+x to cut the existing code out, then add my new tag, then ctrl+v to paste the code back inside the new tag. Add enter key if needed for formatting.
Thanks for reminding me of that! I'll give it a shot
In Preferences | Editor | Live Templates | html/xml | T2, you can change the template text from:
to:
Steps:
Invoke
Surround With
(Shift-Ctrl-A
Win/Linux,Alt-Cmd-T
macOS)Hit
T
to chooseSurround with <tag></tag>
in the Live Templates sectionIn the prompt, type the name of the tag
If you're a fan of the Emmet system for quickly generating markup, you can also surround with Emmet.
https://www.jetbrains.com/pycharm/guide/tips/wrap-selection-with-tag/