Saturday, July 26, 2008

Vi Tips

Command Mode:


  • Cursor Movement:
    • w - word ahead
    • b - word back
    • ( - sentence back
    • ) - sentence forward
    • { - paragraph above
    • } - paragraph below

  • Searching for Text:

    • /test - search downwards for "test"
    • ?test - search upwards for "test"
    • n/N - continue search the same/opposite direction

  • Undoing Changes:

    • u - undo most recent change
    • Ctrl + r redo last "undo" change
    • U - undo all changes to the current line

  • Change, Delete and Yank


      ChangeDeleteYankPaste
      Lineccddyyp blow cursor
      P above cursor
      Lettercldlylp after cursor
      P beofer cursor
      Wordcwdwywp after cursor
      P beofer cursor
  • Tricks:
    • dtx - delete from cursor to the letter x
    • rx - replace a character with x
    • x - delete a character
    • 5dd - delete 5 lines
    • 5yy - copy 5 lines
    • 5x - delete 5 charactersR - replace character-for-character until
Entering Insert Mode
  • a - appen after the cursor
  • i - insert before the cursor
  • A - append to end of line
  • I - insert at beginning of line
  • o - open a line below
  • O - open a line above

No comments: