Vi Editor Commands Cheat Sheet



Vi Editor Commands Cheat Sheet

This cheat sheet is intended to be a quick reminder for the main concepts involved in using the command line program Vim (or vi) and assumes you already understand its usage. It does not cover every command in Vim, only the ones we consider to be useful for most people for the majority of their text editing. What is VI-editor? While in vi you can run AIX commands without exiting the editing session. Creates a shell to execute the command that follows. 1.:!ls will create a shell 2. All files in the current directory are listed. Press return to exit the shell and return to the vi session or 3. While still in command mode, issue the:r. The ultimate Vi cheat sheet for anyone learning Vi Commands or the Vi editor in general. Keep this guide close by when using the editor and you will learn how to use Vi in no time. Vim commands will be the same as Vi for the most part – Windows however has Gvim which allows some GUI interaction.

Sheet

Some times I have to work on Server(Linux hosted server – Ubuntu), due to hands on experience on UI based editors (IDE, Sublime, Atom, Notepad ++, etc ) I felt difficult to edit any documents(usually programming) via terminal at initial stage. But VI is a powerful tool as any other editor, can perform almost all operation on File edit manipulation.

VI has 2 modes. Insert Mode and Command Mode.

  1. Insert mode: Its to used edit/update content of a file
  2. Command mode: Its help us to perform VI function and it has wide range of functions. Its a default mode of VI.

Vi Editor Commands Cheat Sheet Pdf

To switch to ‘Insert mode’ hit letter ‘i‘ or ‘insert‘ button.
To switch to ‘Command mode’ hit ‘Esc‘ button.

Basic Commands:-

:qClose file
:wWrite to File
:wqWrite to file and then close editer.
:12Go to specific line number of file. Number reference line number
GGo to last line of the file

Search & Replace Commands:- How can i download internet explorer for mac.

Linux
/testSearch word ‘test’ on document. Hit letter ‘n’ to repeat search and ‘N’ for backward search
/test/wordIf search term contains backward slash, escape with forward slash. Search term on above example is “test/word”
?testSearch word ‘test’ on document from bottom to top.
/test|wordSearch more than search term. “test” and “word” both are search criteria.
/test*
OR
/<test
Search word starts with ‘test’ on document, Like test, testing, tested, testimonial, etc.
/test>Search word ends with ‘test’ on document.
:%s/find/replace/gFind and replace content.
:%s/find/replace/giFind and replace content and its not case sensitive.
:%s/find/replace/gwFind and replace content on confirmation.
:10,20s/find/replace/gFind and replace content between lines 10 and 20.
:s/find/replace/Find and replace content at first occurrence on current line.
:s/find/replace/gFind and replace content on current line.

Delete Commands:-

'This is Mountain Biking' The Triple B mountain bike started out as the Bossnut’s big brother and was designed by the Calibre team to have all the upgrades they wanted to ride right out of the box. Details Buy now BOSSNUT The Bossnut is back, but not as you know it. Our multiple award winning, industry smashing trail bike has had a complete. Calibre full. Two lifelong friends on a hunting trip in Scotland find their nerves - and their morals - ruthlessly tested after a harrowing turn of events. Watch trailers & learn more. Calibre: The one stop solution for all your e-book needs. Comprehensive e-book software.

DDelete from cursor position to end of current line. D is equivalent d$
dwDelete from the current cursor position to the beginning of the next word
ddDelete current line
5ddRepeat dd command (delete current line) 5 times
dGDelete lines from current to end of file
d10jDelete from current line to 10 lines forward direction
d10kDelete from current line to 10 lines backward direction
:10,20dDelete lines between range.
:g/test/dDelete all lines containing matching pattern.
:v/test/dDelete all lines that does not containing matching pattern. Reverse of :g command
:v/test|testing/dDelete all lines except those that containing ‘test’ or ‘testing’.

Vi Editor Commands Cheat Sheet Download

Tab, Split & Switch:

:tabnew fileCreate new tab and open file
g tSwitch to next tab
g TSwitch to previous tab
002 g tSwitch to specific tab by tab number
:split fileSplit window/screen on horizontal
Ctrl + W Ctrl + WSwitch between window
:qaClose all tab or window
:e test.shOpen file or switch from current file
:e# 1Switch file, here number is file number

I have not listed all VI Commands, but these commands can help to modify document via terminal.