The VIM Editor

The VIM editor is the most widely used text processing software in Linux. It is primarily used from the console and is a powerful software. However, using this software is tricky, and requires a little practice. I'm listing a couple of options that one might need frequently while using VIM.



Command
Output
Insert OR i
Sets the editor in insert mode; required to write new lines.
Esc + u
Undo
Esc + yy
Yanks (copies) the current line to the clipboard
Esc + Nyy
Yanks (copies) N lines to the clipboard starting from current line
Esc + dd
Cuts the current line
Esc + Ndd
Cuts N lines starting from current line
Esc + p
Pastes the line below the current line
/search_text
Searches the written text within the file
Esc + : N
Goes to line number N
Esc + : set ic
Sets the editor to ignore case mode; useful in searching
Esc + : set nu
Displays line number
Esc + : q!
Quits without saving.
Esc + : w
Writes the file.
Esc + : wq OR Esc + : x
Save & quit.
Esc + : wq! OR Esc + : x!
Save & quit forcefully
:%s/text_to_find/text_to_replace/g 
Replaces ‘text_to_find’ with ‘text_to_replace’

Comments