Vim - The power of `g`
Some interesting command with g
ggg?G
will root13 whole file :vga
display hex, ascii of character under the cursorg8
display hex value of utf-8 character.G=gg
auto (re)indent entire document.
:[range]g[!]/pattern/cmd
- Use
!
means do not match pattern - Cmd list:
d
: Deletem
: Movet
: Copys
: Replace
Example:
# Delete all line matching with pattern
:g/pattern/d
# Delete all blank lines
:g/^\s*$/d
# Move all line matching pattern to end of file
:g/pattern/m$
# Add text to end of line matching pattern
:g/^pattern/s/$/mytext
# Run a marco on matching lines
:g/pattern/normal @q
You can find more here