Skip to content

Instantly share code, notes, and snippets.

@amiteshore
Created December 28, 2021 06:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amiteshore/7a665349e17997622e77b06582b810e2 to your computer and use it in GitHub Desktop.
Save amiteshore/7a665349e17997622e77b06582b810e2 to your computer and use it in GitHub Desktop.

Moving within the screen


H ⇒ Move to the top of the screen

M ⇒ Move to the middle of the screen

L ⇒ Move to the bottom of the screen

Moving within the line


fi ⇒ Jump forward on i

f( ⇒ Jump forward on (

f" ⇒ Jump forward on "

Fi ⇒ Jump backward on i

F( ⇒ Jump backward on (

F" ⇒ Jump backward on "

ti ⇒ Jump forward before i

t( ⇒ Jump forward before (

t" ⇒ Jump forward before "

ti ⇒ Jump backward before i

t( ⇒ Jump backward before (

t" ⇒ Jump backward before "

0 ⇒ Move to the beginning of the line

$ ⇒ Move to the end of the line

^ ⇒ Move to the first non-blank character of the line

Advanced

  • Buffers
  • Registers
  • Splits
  • Marks

Cursor movement


h ⇒ Move cursor left

j ⇒ Move cursor down

k ⇒ Move cursor up

l ⇒ Move cursor right

w ⇒ Jump forwards to the start of the next word

W ⇒ Jump forwards to the start of the next word (words can contain punctuation)

b ⇒ Jump backwards to the start of a word

B ⇒ Jump backwards to the start of a word (words can cantain punctuation)

e ⇒ Jump forwards to the end of the current word (words can contain punctuation)

E ⇒ Jump forwards to the end of the current word (words can contain punctuation)

0 ⇒ Jump to the start of the line

$ ⇒ Jump to the end of the line

gg ⇒ Go to the first line of the document

G ⇒ Go to the last line of the document

#gg ⇒ Go to line #

#G ⇒ Go to line #

ctrl+d ⇒ Move forward half screen

ctrl+u ⇒ Move backward half screen

ctrl+f ⇒ Move forward one full screen

ctrl+b ⇒ Move backward one full screen

{ ⇒ Jump to previous block

} ⇒ Jump to next block

( ⇒ Jump to the previous sentence

) ⇒ Jump to the next sentence

% ⇒ Move to matching pair

Insert mode


i ⇒ Insert before the cursor

I ⇒ Insert at the beginning of the line

a ⇒ Insert after the cursor

A ⇒ Insert at the end of the line

o ⇒ Insert a new line below the cursor

O ⇒ Insert a new line above the cursor

Copy, cut and paste


  • d means delete or cut
  • y means yank or copy
  • x means delete or cut

dd ⇒ Cut a line

yy ⇒ Copy a line

#dd ⇒ Cut # of lines

#yy ⇒ Copy # of lines

dw ⇒ Cut the characters of the words from the cursor position to the start of the next word

yw ⇒ Copy the characters of the word from the cursor position to the start of the next word

d#w ⇒ Cut # of words from the cursor

y#w ⇒ Copy # of words from the cursor

p ⇒ Paste after the cursor

P ⇒ Paste before the cursor

#p ⇒ Paste # of times before the cursor

#P ⇒ Paste # of times after the cursor

x ⇒ Cut the character under the cursor

#x ⇒ Cut # of characters from the cursor

Editing


Case

~ ⇒ Toggle case of the character under the cursor

g~ ⇒ Switch case up to motion

gu ⇒ Change to lowercase up to motion

gU ⇒ Change to uppercase up to motion

Vu ⇒ Change the current line to lowercase (V means select current line on Visual mode)

VU ⇒ Change the current line to uppercase (V means select current line on Visual mode)

Replace / Change

r ⇒ Replace a single character

R ⇒ Replace more than one character (press <esc> to leave replace mode)

The change operator is used with the same motions as delete.

Format for CHANGE: c [number] motion

ce ⇒ Change word (Deletes the word and places you in Insert mode)

cc ⇒ Change the whole line

Misc


u ⇒ undo

U ⇒ undo all changes in a line

ctrl+r ⇒ redo

. ⇒ repeat last command

Tabs


:tabnew ⇒ Open a file in a new tab

gt ⇒ Go to the next tab

gT ⇒ Go to the previous tab

#gt ⇒ Go to tab number #

:tabm # ⇒ Move current tab to the #th position (0-indexed)

:tabc ⇒ Close the current tab

:tabo ⇒ Close all tabs except for the current one

:tabdo COMMAND ⇒ Run the COMMAND on all tabs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment