Vi Tips

Note tips of Vi

Shortcuts

dd # delete a line

3dd # delete 3 lines

u # undo you last action

command + r # redo something

  1. different ways to quit text

    1
    2
    3
    :q   # just quit
    :q! # force quit without any changes
    :wq # quit with saving changes
  1. show row number

    1
    :set nu
  2. search some string

    1
    /searchString
  3. set to search in ignore case sensitive

    1
    2
    :set ic      # ignore case
    :set noic # not ignore case
  4. search and replace

    1
    :%s/stringPattern/youNeed/g
  5. Sort lines

    1
    :startNum,endNum!sort # similarly we can do sort, awk, tr etc
0%