Skip to content

Instantly share code, notes, and snippets.

@ivanhular
Last active March 20, 2024 03:57
Show Gist options
  • Select an option

  • Save ivanhular/18dd84fc18eda005113d6634d1277f81 to your computer and use it in GitHub Desktop.

Select an option

Save ivanhular/18dd84fc18eda005113d6634d1277f81 to your computer and use it in GitHub Desktop.
vim notes

https://vim.rtorr.com/ - Cheatsheet

https://www.openvim.com/ - interactive Tutorial

saving

:wq! - save and quit

:w - save withouth quit

:q - quit

:q! - quit withouth saving

i - insert mode esc - normal mode / esc to exit insert mode

v / V - visual mode

movement

h - left

j - down

k - up

l - right

word movement

w - next word

e - end of word

b - begining of word

number powered movement

e.g 5w

Insert Repeated Text

e.g 3iText then esc

find

f || F

search text

/

e.g

/test\c - c case insensitive | C sensitive

n - nex occurence

N - prev occurence

goto matching parenthesis

%

start/end of line

0 - start

$ - end

find word under cursor

* - next occurence

# - prev occcurence

Goto Line

gg - first line

G - last line

5g - specific line 5

Append text

a | A

Insert new line

o - insert after the current line

O - insert before the current line

Removing Character

x - remove the current char

X - remove the char before the pointed char

Replacing Character under cursor

r

find all and replace

:s/article\c/tutorial/g :%s/oldtext/newtext/gi :%s/old/new/g - replace all old with new throughout file :%s/old/new/gc - replace all old with new throughout file with confirmations

delete

d

can combine with word movement

de - delete the whole word

d$ - delete the whole line

repetition

. - repeat previous command

paste

p - all deleted text can be pasted

copy current line

yy

undo & redo

u - undo

ctrl + r - redo

clear current line

S

Delete end of line

D

@ivanhular
Copy link
Copy Markdown
Author

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