Vim Editor 101

How to quit vim?

It has Dual-mode: GUI and Editor.

GUI

move

  • “H” moves left;
  • “K” moves up;
  • “L” moves right;
  • “J” moves down.

Copy & Paste

  • “Y” copies a line of text to the buffer.
  • “yy” copies a whole line of text.
  • “P” pastes it to the cursor’s current position.
  • “D” delete whole line and buffer
  • “dd” delete whole line and buffer
  • “xN”+ enter, will do
  • ”:” go to specific line: “:13”
  • Search and text replace: “:%s/Jack/John/g”
  • ”/” find, like “/moss”
  • “u” for undo last command
  • “:w” save
  • “:wq” save and quit
  • “:q!” quit without save

Editor

  • “i” to begin inserting text at the current cursor position
  • “a” to begin inserting after the current cursor position
  • escape to quit editor mode

Settings

find settings at ~/.vimrc

  • “:syntax on” color theme
  • “colorscheme “+ tag, to change theme
  • “vim ftp:////”. For example: “vim ftp://172.16.15.73//Users/john/test.pl”

Scenarioes

Empty a file:

  1. Go to command mode in the editor by pressing ESC key on the keyboard.
  2. Press gg. It will take to the first line of the file.
  3. Then press dG. This will delete from the first line to the last line.

References

Tags: ,

Updated: