vi IMproved

fhLUG

Linux User Group FH Hagenberg

vi

vi enhancements

Vim basics

The two most important commands

Learning Vim

===============================================================================
=    W e l c o m e   t o   t h e   V I M   T u t o r    -    Version 1.7      =
===============================================================================

     Vim is a very powerful editor that has many commands, too many to
     explain in a tutor such as this.  This tutor is designed to describe
     enough of the commands that you will be able to easily use Vim as
     an all-purpose editor.

     The approximate time required to complete the tutor is 25-30 minutes,
     depending upon how much time is spent with experimentation.

Movement commands

h j k l
left, up, down, right
b e
Beginning/end of word
0 $
Beginning/end of line
w
Beginning of next word

More movement commands

( )
Previous/next sentence
{ }
Previous/next paragraph
%
Matching parens/brace/bracket
g-g and G
Beginning/end of file

Even more movement commands

^
First non-blank character of line
F f
Previous/next character (inclusive)
T t
Previous/next character (exclusive)
g-o
Go to byte

Edit commands

i a s x
Insert, append, substitute, delete
I A
Insert front, append back
o O
New line below/above

More edit commands

.
Repeat last command
J
Join lines
g-u g-U
Lowercase/Uppercase
g-~ ~
Change case

Autocompletion

Ctrl+n, Ctrl+p
Next/previous autocomplete
Ctrl+x-Ctrl+f
File name completion
Ctrl+x-Ctrl+o
Omnicompletion

Time travel

u Ctrl+r
Undo/redo
U
Undo line
g-- g-+
Go to older/newer text state

Selection

v V
Visual selection character/line based
Ctrl+V
Visual block select
g-v
Restore last selection

Selection modifiers

a i - w s p
A/inner word/sentence/paragraph
a i - " '
A/inner quoted string
a i - ( { [ <
A/inner block
a i - t
A/inner tag block

Buffers

y
Yank (copy)
d
Delete (cut)
p P
Paste after/before
"
Select specific buffer

Files

:r <file>
Read <file> into buffer
:e <file> or :o <file>
Open <file> for editing
:w <filename>
Write file to <filename>
Z-Z and Z-Q
:x and :q
Exit/quit vim (with/without saving)

Windows

Ctrl+w-s Ctrl+w-v
Split window horizontally/vertically
Ctrl+w-w
Switch windows
Ctrl+w-h/j/k/l
Move to window
Ctrl+w-c
Close window

Tabs

:tabnew or :tabedit
Open new tab
:tabclose
Close tab
g-t g-T
Previous/next tab

Macros

q
Record macro
@
Execute macro

Useful config values

:set number
Display line numbers
:set hlsearch
Highlight search matches
:set ignorecase smartcase
Clever case matching

Finding help

$ man vim
Command line arguments and config
:help <key>
Help about <key>
:help :<command>
Help about <command>
:help <topic>
Help about a <topic>

Contact