Vim Packages and creating files

Installing Vim yum install vim of apt-get install vim.

vim -g can actually run the GUI - who cares though. There are a number of different GUI wrappers. gvim is the most popular.

So we have vi, vim - the improved vi and gvim.

Vim modes, navigation and commands

  1. Command/Normal mode
  2. Insert/Ex mode
  3. Mark mode


KeyWhat it does
xDelete character
:q!Quit and omit changes
:wqWrite and quit
:"File mode"
wWord forward
eWord forward last char
bBack word
0Go to start
$Go to end
vHighlight words
%Go to matching bracket/quotes etc
Number, commandMove by certain amount
d (twice)Delete the line
d, wDelete the word
Number, iInsert a number of times
Number, rReplace a number of chars
Number, xDelete certain number of keys
y, move to new spot, pYank the link, then paste
v, then yMark mode and yank
>>Indent forward
<<Indent back
/<word>Find a word
n/NForward search, N upwards
?<word>Search bottom up (N/n swap)
%s/ex/EX/gGlobal ex regex
#s/ex/EX/gcConfirm value swapping
j + jGo back to normal mode
g + gGo to top of document
GGo to end of file
(Jump to previous sentence
)Jump to next sentence
}Jump to next paragraph
{Jump to previous paragraph
aInsert text before cursor
AInsert test at end of line
oBegin new line below the cursor
OBegin new line above the cursor
:r [filename]Insert the file [filename] below the cursor
:r ![command]Execute [command] and insert its output below the cursor

Delete Text

KeyWhat it does
xDelete at cursor
dwDelete word
d0Delete to beginning of a line
d$Delete to end of a line
d)Delete to end of sentence
dggDelete to beginning of file
dGDelete to end of file
ddDelete line
3ddDelete three lines


KeyWhat it does
yyCopy current line into storage buffer
pPaste storage buffer after line
PPaste storage buffer before line


KeyWhat it does
uUndo the last operation
ctrl + rRedo the last undo

Executing external commands

These are a few of the more advanced things.

: ! ls -al ~ - it will run the command, and then we get the option to run a command.

:r ! cat /root/.bash_profile for example will read in the profile.

Files and buffers

:saveas <name|path>