O'Reilly logo

Linux in a Nutshell, 6th Edition by Robert Love, Stephen Figgins, Ellen Siever, Arnold Robbins

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

Edit Commands

Recall that c, d, and y are the basic editing operators.

Changing and deleting text

The following table is not exhaustive, but it illustrates the most common operations.

Command

Action

cw

Change word.

cc

Change line.

c$

Change text from current position to end of line.

C

Same as c$.

dd

Delete current line.

numdd

Delete num lines.

d$

Delete text from current position to end of line.

D

Same as d$.

dw

Delete a word.

d}

Delete up to next paragraph.

d^

Delete back to beginning of line.

d/pat

Delete up to first occurrence of pattern.

dn

Delete up to next occurrence of pattern.

dfa

Delete up to and including a on current line.

dta

Delete up to (but not including) a on current line.

dL

Delete up to last line on screen.

dG

Delete to end of file.

gqap

Reformat current paragraph to textwidth. {vim}

g˜w

Switch case of word. {vim}

guw

Change word to lowercase. {vim}

gUw

Change word to uppercase. {vim}

p

Insert last deleted or yanked text after cursor.

gp

Same as p, but leave cursor at end of inserted text. {vim}

]p

Same as p, but match current indention. {vim}

[p

Same as P, but match current indention. {vim}

P

Insert last deleted or yanked text before cursor.

gP

Same as P, but leave cursor at end of inserted text. {vim}

rx

Replace character with x.

Rtext

Replace with new text (overwrite), beginning at cursor. Escape ends replace mode.

s

Substitute character.

4s

Substitute four characters.

S

Substitute entire line.

u

Undo last change.

Ctrl-R

Redo last change. {vim}

U

Restore current line.

x

Delete current cursor position.

X

Delete back one character.

5X

Delete ...

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