Cheat Sheet: The Vim Linux Command Line Editor Cheat Sheet

Raziah Lauretta
3 min readSep 25, 2021

--

Cheat Sheet: The Vim Linux Command Line Editor Cheat Sheet

Here we can see, “Cheat Sheet: The Vim Linux Command Line Editor Cheat Sheet”

Keep this Vim cheat sheet handy to find out or relearn useful Vim commands.

Powerful, efficient, and highly configurable — — that’s Vim in a nutshell for you. This cross-platform instruction text editor has been around for ages and features a solid online community you’ll look to for help. The simplest part is that Vim is free and open source.

If you’ve only dabbled in Vim so far, the subsequent step is getting comfortable with Vim commands, i.e., Vim’s keyboard shortcuts. (This is important as long as Vim may be a keyboard-centric text editor.)

We’ve even compiled the simplest Vim shortcuts into a cheat sheet for you! Scroll right down to discover it. You’ll also download a PDF version of this Vim cheat sheet and reserve it to your desktop for quick access.

Remember that Vim (Vi Improved) may be modified like the Unix-based text editor Vi, which ships with several Linux distros. So you’ll find that several Vim also commands functions as Vi commands.

The Vim Commands Cheat Sheet

Shortcut

Action

Cursor Movement

h

Move cursor left

j

Move cursor down

k

Move cursor up

l

Move cursor right

w OR ¹W

Move cursor to the start of the next word

b OR ¹B

Move cursor to the start of the previous word

e OR ¹E

Move forward to the end of a word

0

Move to the start of the line

^

Move to the first non-blank character of the line

$

Move to the end of the line

G

Go to the last line of the document

nG OR :n

Go to line number n



To the position before the latest jump, / where the last “m’” / “m`” command was given.

fx

Move to next occurrence of character x

tx

Move to one character before the character x

}

Move to next paragraph

{

Move to previous paragraph

H

Move to home (top) of screen

L

Move to last line of screen

M

Move to middle of screen

3, f, x

Move to 3rd instance of character x forward from cursor on current line.

3, F, x

Move to 3rd instance of character x back from cursor on current line.

Editing a File

r

Replace a single character

dd

Cut (delete) a line

yy

Yank (copy) a line

2yy

Yank (copy) two lines

J

Join line below to the current one

cc OR S

Change (replace) entire line

cw

Change (replace) to the end of the word

c$

Change (replace) to the end of the line

s

Delete character and substitute text

xp

Transpose two letters (delete and paste)

u

Undo

Ctrl r

Redo

.

Repeat last command

Search and Replace

*

Search for word under cursor

/pattern

Search for pattern

?pattern

Search backward for pattern

n

Repeat search in same direction

N

Repeat search in opposite direction

:%s/old/new/g

Replace all instances of old with new

:%s/old/new/gc

Replace all instances of old with new, with confirmations

Screen Movement

Ctrl u

Move screen up by half page

Ctrl b

Move screen up by one page

Ctrl d

Move screen down by half page

Ctrl f

Move screen down by one page

zz

Center screen on cursor

zt

Align top of screen with cursor

zb

Align bottom of screen with cursor

Insert Mode (Insert Text)

i

Enter insert mode

I

Insert at the beginning of the line

a

Insert (append) after the cursor

A

Insert (append) at the end of the line

o

Append (open) a new line below the current line

O

Append (open) a new line above the current line

ea

Insert (append) at the end of the word

Esc

Exit insert mode

Change Case

~

Toggle case (Case => cASE)

gU

Uppercase

gu

Lowercase

gUU

Uppercase current line (also gUgU)

guu

Lowercase current line (also gugu)

Visual Mode (Mark Text)

v

Start visual mode, mark lines, then do a command (like y-yank)

V

Start linewise visual mode

vo

Move to other end of marked area

Ctrl v

Start visual block mode

vO

Move to other corner of block

vaw

Mark a word

vab

Mark a block with ()

vaB

Mark a block with {}

vib

Mark inner block with ()

viB

Mark inner block with {}

Esc

Exit visual mode

Visual Commands

>

Shift text right

--

--

Raziah Lauretta
Raziah Lauretta

Written by Raziah Lauretta

ITechBrand — Get the Latest and Technology Brand News, Internet Technology News, breaking news, Digital News, Mobile Technology, https://itechbrand.com/

Responses (2)