Rakshan Shetty

Vim Tips

February 16, 2020☕️ 1 min read

List of vim tips I learned

  • Save a read-only file with sudo with
:w !sudo tee %
  • Get the full path of current buffer
1<C-G>
  • Vim Undo history
# Time-based undo/redo
g- / g+

# Tree-Based undo/redo
u / <C-R>
  • Toogle Case with tilde in normal mode
~
  • Repeat previous substitution :s
:&

# Use previous flags
:&&

# Change flags
:&gc

# Repeat last substitution in normal mode
g&

# Represent match pattern in a substitution

:s/sub/&stitution/ # Here & is sub
  • Change variable value
:let &<tab>
:let &hlsearch=1
  • Expression evaluation in insert mode
<Ctrl-r>=  # 5*6 <Enter>
  • Fix Indentation with syntax support
==  #In Normal Mode
=   # In Visual Mode    

More comming soon…


Tags: Tips

Software engineer, Learning Web development and sharing my experience