O'Reilly logo

Linux Pocket Guide, 2nd Edition by Daniel J. Barrett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

vim — stdin  stdout  - file  -- opt  --help  --version

Synopsis

vim [options] [files]

vim is an enhanced version of the old standard Unix editor vi. To invoke the editor in a new X window, run:

$ gvim

To run in a existing shell window:

$ vim

To run the vim tutorial, run:

$ vimtutor

vim is a mode-based editor. It operates in two modes, insert and normal. Insert mode is for entering text in the usual manner, while normal mode is for running commands like “delete a line” or copy/paste. For basic keystrokes in normal mode, see Table 1-1.

Table 1-1. Basic keystrokes in emacs and vim

Task

emacs

vim

Type text

Just type

Type i, then any text, and finally ESC

Save and quit

^x^s then ^x^c

:wq

Quit without saving

^x^c

Respond “no” when asked to save buffers

:q!

Save

^x^s

:w

Save As

^x^w

:w filename

Undo

^/ or ^x u

u

Suspend editor (not in X)

^z

^z

Switch to edit mode

(N/A)

ESC

Switch to command mode

M-x

:

Abort command in progress

^g

ESC

Move forward

^f or right arrow

l or right arrow

Move backward

^b or left arrow

h or left arrow

Move up

^p or up arrow

k or up arrow

Move down

^n or down arrow

j or down arrow

Move to next word

M-f

w

Move to previous word

M-b

b

Move to beginning of line

^a

0

Move to end of line

^e

$

Move down one screen

^v

^f

Move up one screen

M-v

^b

Move to beginning of buffer

M-<

gg

Move to end of buffer

M->

G

Delete next character

^d

x

Delete previous ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required