Feeds:
Posts
Comments

Posts Tagged ‘Vim’

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 »

Add vim to right cursor menu.

Ubuntu’s default editor is Gedit. The following tutor you how to change it into vim — the god of the editor.

  1. Edit /etc/gnome/default.list, replace all the gedit.desktop with vim.desktop.
  2. Under /usr/share/applications, create a file vim.desktop, edit like the following:
    • [Desktop Entry]
    • Encoding=UTF-8
    • Type=Application
    • Exec=vim %f
    • Icon=”whatever pic you want to specify”
    • Name=Vim
    • Terminal=true
    • NoDisplay=true

    (more…)

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 »