VIM: Difference between revisions

343 bytes added ,  27 March 2020
Line 15: Line 15:




= Adding comments to a block =
= Instructions =


== Method 1 ==
== Adding comments to a block ==
 
=== Method 1 ===


Grab lines with visual block and then <code>:norm i#</code> to comment, and then <code>:norm x</code> or <code>:norm ^x</code> with indentation.
Grab lines with visual block and then <code>:norm i#</code> to comment, and then <code>:norm x</code> or <code>:norm ^x</code> with indentation.




== Method 2 ==
=== Method 2 ===


'''Commenting a block'''
'''Commenting a block'''
Line 34: Line 36:
# Ctrl-v and select the block to uncomment
# Ctrl-v and select the block to uncomment
# press x
# press x
== Auto-format HTML ==
1) Join all the lines
<source lang="vim">
(highlight lines) gJ
</source>
2) Break tags to new lines
<source lang="vim">
(highlight lines) :s/>\s*</>\r</g
</source>
3) Set filetype
<source lang="vim">
:set ft=html
</source>
4) Indent
<source lang="vim">
(highlight lines) =
</source>


= .vimrc =
= .vimrc =