Useful shortcuts for vi editor

Saturday 22 November 2014

Useful shortcuts for vi editor

  • vi myfile.txt
    to open file with vi editor
  • vi + myfile.txt
    cursor goes to end of the file
  • vi +200 myfile.txt
    cursor goes to 200th row
  • :set list
    :set nolist

    see hidden characters or not
  • :set number
    :set nonumber
    see number of lines or not
  • :set paste
    activate paste option before get into insert mode (to resolve the commented lines problem)
  • :set nopaste
    deactivate paste option before get into insert mode
  • :[line_number]
    cursor goes to desired line
  • l, k, h, j
    cursor goes to right, up, left, down
  • w
    cursor goes to next word
  • b
    cursor goes to start of the current word
  • gg
    go top
  • shift + g
    go bottom
  • dd
    remove row
  • p
    paste the clipboard data
  • x
    remove one char
  • yy
    copy the row
  • u
    undo last operation
  • o
    add new row
  • :%d
    delete all lines
  • /hello
    find "hello" word
    n
    go to next searched word
    N
    go to previous searched word