Rakshan Shetty

Vim Tips

February 16, 2020☕️ 1 min read

Vim Tips

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
  • Swap window
<Ctrl-w><Ctrl-r>

More comming soon…


Tags: Tips
Rakshan Shetty

Software engineer, Learning Web development and sharing my experience