Feeds:
Posts
Comments

Archive for the ‘Vim’ Category

Vim as a diff/merge tool

Programmer’s Candy  —Vimdiff shortcuts

  • do ==== Get changes from other window into the current window
  • dp ==== Put the changes from current window into the other window
  • ]c ==== Jump to the next change
  • [c ==== Jump to the previous change
  • ^w^w ==== Switch between windows
Advertisements

Read Full Post »

Vim command cheat sheet

Working with Files

  • :e filename *** Open a new file. Tab can be used to find file
  • :w filename *** Save the current file if filename not specified
  • : x *** same with :wq

Moving around in the Files

  • e *** to the end of a word
  • b *** to the beginning of a word
  • 0 *** to the beginning of a line
  • ^ *** to the first non-space character of a line
  • $ *** to the end of a line

Edit Files

  • i *** insert before cursor
  • I *** insert to the start of current line
  • C *** change the rest of current line
  • ~ *** change the case of characters
  • u *** undo the last action
  • ^+r *** redo

Replace

  • : (range)s/source/target/(arguments)
  • (ranges)
    • %  *** the whole file
  • (arguments)
    • g *** replace all occurrences in the line or only the first one in current line is replaced
    • i *** ignore the case
    • c *** confirm each substitution.
  • examples:
    • :%s/source/target/gc  *** replace source with target within the whole file and confirm before every replace

Read Full Post »