Vim Editor

Introduction to Vim

Vim is a highly configurable text editor built to enable efficient text editing. It is an improved version of the vi editor distributed with most UNIX systems.

Key Features

Basic Commands

Command Description
:w Save the file
:q Quit Vim
:x Save and quit
i Enter insert mode
a Append text after the cursor
o Open a new line below the current line
shift+o Open a new line above the current line
esc Exit insert mode
esc Shift+Z+Z Save and quit
esc Shift+g Go to the end of the file
esc g+g Go to the beginning of the file
esc shift+0 Go to the beginning of the line
esc shift+$ Go to the end of the line

Vim Command mode

Command Description
y+y 3+y+y : Three line copy Yank (copy) a line
p Paste the copied text
u Undo last action
ctrl+r Redo last undone action
c+c 3+c+c: cut the 3 line Change a line
2+y+w Yank (copy) two words
c+w Change a word
:se nu Show line numbers
:se nonu Hide line numbers
d+d Delete a line
x 5+x: Delete 5 character at a time Delete a character
/SearchWord Search for a word
:20:5 Go to line 20 or Go to line 5
:se ic/SearchWord Ignore case while searching
:se noic/SearchWord Case sensitive search
:nohl Clear search highlighting
:edit /home/path/file.txt we can also use to copy any word in one file to another Open a file without exit current editing
:%s/ReplaceWord/to another word/igc
:1s/ReplaceWord/to another word/igc
:1,20s/ReplaceWord/to another word/igc
g :- global
i :- ignore
c :- conformation

y : Yes, n : No, q : Quit, a : To change all

Replace a word in the file