Global

  • :h[elp] cuvant keye - ajutor pentru cuvantul keye
  • :sav[eas] fisier - salveaza fisierul ca
  • :clo[se] - inchide panoul current
  • :ter[minal] - open a terminal window
  • K - global.commands.K
Tip Run vimtutor in a terminal to learn the first Vim commands.

Mutarea cursorului

  • h - muta cursorul la stanga
  • j - muta cursorul la dreapta
  • k - muta cursolul in sus
  • l - muta cursolul in jos
  • gj - move cursor down (multi-line text)
  • gk - move cursor up (multi-line text)
  • H - dute la inceputul ecranului
  • M - dute la mijlocul ecranului
  • L - dute la sfarsitul ecranului
  • w - sari la inceputul cuvantului
  • W - sari la inceputul cuvantului (cuvintele pot contine semne de punctuatie)
  • e - sari la sfarsitul cuvantului
  • E - sari la sfarsitul cuvantului (cuvintele pot contine semne de punctuatie)
  • b - sari inapoi la inceputul cuvantului
  • B - sari inapoi la inceputul cuvantului (cuvintele pot contine semne de punctuatie)
  • ge - jump backwards to the end of a word
  • gE - jump backwards to the end of a word (words can contain punctuation)
  • % - cursorMovement.commands.percent
  • 0 - sari la inceputul liniei
  • ^ - sari la primul caracter care nu e liber de la inceputul liniei
  • $ - sari la sfarsitul liniei
  • g_ - sari la ultimul caracter non-blank al liniei
  • gg - dute la prima linie a documentului
  • G - dute la ultima linie a documentului
  • 5gg or 5G - dute la linia 5
  • gd - move to local declaration
  • gD - move to global declaration
  • fx - dute la urmatoarea referinta a caracterului x
  • tx - dute la referinta precendenta a caracterului x
  • Fx - cursorMovement.commands.Fx
  • Tx - cursorMovement.commands.Tx
  • ; - cursorMovement.commands.semicolon
  • , - cursorMovement.commands.comma
  • } - sari la urmatorul paragraf (sau functie/bloc, cand editezi cod)
  • { - cursorMovement.commands.openCurlyBrace
  • zz - cursorMovement.commands.centerCursor
  • zt - position cursor on top of the screen
  • zb - position cursor on bottom of the screen
  • Ctrl + e - cursorMovement.commands.CtrlPluse
  • Ctrl + y - cursorMovement.commands.CtrlPlusy
  • Ctrl + b - mergi inapoi un ecran intreg
  • Ctrl + f - mergi inainte un ecran intreg
  • Ctrl + d - mergi inainte jumatate de ecran
  • Ctrl + u - mergi inapoi jumatate de ecran
Tip Prefixeaza comanda de miscare a cursorului cu un numar pentru a o repeta. De exemplu, 4j muta cursorul cu 4 linii in jos.

Modul de inserare - inserare/adaugare text

  • i - insereaza inainte de cursor
  • I - insereaza la inceputul liniei
  • a - insereaza (adauga) dupa cursor
  • A - insereaza (adauga) la sfarsitul liniei
  • o - adauga (deschide) o noua linie sub linia curenta
  • O - adauga (deschide) o noua linie inaintea liniei curente
  • ea - insereaza (adauga) la sfarsitul cuvantului
  • Ctrl + h - delete the character before the cursor during insert mode
  • Ctrl + w - delete word before the cursor during insert mode
  • Ctrl + j - begin new line during insert mode
  • Ctrl + t - indent (move right) line one shiftwidth during insert mode
  • Ctrl + d - de-indent (move left) line one shiftwidth during insert mode
  • Ctrl + n - insert (auto-complete) next match before the cursor during insert mode
  • Ctrl + p - insert (auto-complete) previous match before the cursor during insert mode
  • Ctrl + rx - insert the contents of register x
  • Ctrl + ox - Temporarily enter normal mode to issue one normal-mode command x.
  • Esc or Ctrl + c - iesi din modul inserare

Editare

  • r - inlocuieste un singur caracter
  • R - replace more than one character, until ESC is pressed.
  • J - lipeste lina curenta cu cea dedesubt
  • gJ - editing.commands.gJ
  • gwip - editing.commands.gwip
  • g~ - switch case up to motion
  • gu - change to lowercase up to motion
  • gU - change to uppercase up to motion
  • cc - schimba (inlocuieste) toata linia
  • c$ or C - schimba (inlocuieste) pana la sfarsitul liniei
  • ciw - editing.commands.ciw
  • cw or ce - schimba (inlocuieste) pana la sfarsitul cuvantului
  • s - sterge caracterul si inlocuieste
  • S - sterge linia si inlocuieste (asemeni cc)
  • xp - transpune 2 caractere (sterge si lipeste)
  • u - undo (anulare)
  • U - restore (undo) last changed line
  • Ctrl + r - redo (refacere)
  • . - repeta comanda anterioara

Marcarea textului (modul vizual)

  • v - incepe modul vizual, marcheaza linii, apoi trimite o comanda (precum <kbd>y</kbd>-copie)
  • V - incepe modul vizual in relatie cu liniile
  • o - dute la sfarsitul sectiunii marcate
  • Ctrl + v - incepe modul vizual de tip sectiune
  • O - dute la celalat colt al sectiunii
  • aw - marcheaza un cuvant
  • ab - o sectiune cu ()
  • aB - o sectiune cu {}
  • at - a block with <> tags
  • ib - sectiunea interioara cu ()
  • iB - sectiunea interioara cu {}
  • it - inner block with <> tags
  • Esc or Ctrl + c - iesi din modul vizual
Tip Instead of b or B one can also use ( or { respectively.

Commandes du mode visuel

  • > - muta textul la dreapta
  • < - muta textul la stanga
  • y - copie textul markat
  • d - sterge textul marcat
  • ~ - schimba capitala caracterului (majuscula/litera mica)
  • u - change marked text to lowercase
  • U - change marked text to uppercase

Registre

  • :reg[isters] - arata continutul registrelor
  • "xy - copie in registrul x
  • "xp - lipeste continutul registului x
  • "+y - yank into the system clipboard register
  • "+p - paste from the system clipboard register
Tip Registrele sunt salvate in ~/.viminfo, si vor fi incarcate din nou la urmatorul restart
Tip Special registers:

0 - last yank
" - unnamed register, last delete or yank
% - current file name
# - alternate file name
* - clipboard contents (X11 primary)
+ - clipboard contents (X11 clipboard)
/ - last search pattern
: - last command-line
. - last inserted text
- - last small (less than a line) delete
= - expression register
_ - black hole register

Insemne

  • :marks - lista insemnelor
  • ma - seteaza pozitia curenta pentru insemnul A
  • `a - sari la pozitia insemnului A
  • y`a - copie textul pana la pozitia insemnului A
  • `0 - go to the position where Vim was previously exited
  • `" - go to the position when last editing this file
  • `. - go to the position of the last change in this file
  • `` - go to the position before the last jump
  • :ju[mps] - list of jumps
  • Ctrl + i - go to newer position in jump list
  • Ctrl + o - go to older position in jump list
  • :changes - list of changes
  • g, - go to newer position in change list
  • g; - go to older position in change list
  • Ctrl + ] - jump to the tag under cursor
Tip To jump to a mark you can either use a backtick (`) or an apostrophe ('). Using an apostrophe jumps to the beginning (first non-blank) of the line holding the mark.

Macros

  • qa - inregistreaza macro-ul a
  • q - termina inregistrea macro-ului a
  • @a - ruleaza macro a
  • @@ - ruleaza ultimul macro

Copiere/taiere si lipire

  • yy - copie o linie
  • 2yy - copie 2 linii
  • yw - copie un cuvant
  • yiw - copie cuvantul de sub cursor
  • yaw - copie cuvantul de sub cursor si spatiul dinaintea lui
  • y$ or Y - copie pana la sfarsitul liniei
  • p - lipeste din clipboard dupa cursor
  • P - lipeste inainte de cursor
  • gp - put (paste) the clipboard after cursor and leave cursor after the new text
  • gP - put (paste) before cursor and leave cursor after the new text
  • dd - sterge (taie) o linie
  • 2dd - sterge (taie) 2 linii
  • dw - sterge (taie) un cuvant
  • diw - sterge (taie) cuvantul de sub cursor
  • daw - sterge (taie) cuvantul de sub cursor si spatiul de dinainte si dupa el
  • :3,5d - delete lines starting from 3 to 5
Tip You can also use the following characters to specify the range:
e.g.

:.,$d - From the current line to the end of the file
:.,1d - From the current line to the beginning of the file
:10,1d - From the 10th line to the beginning of the file

  • :g/{pattern}/d - delete all lines containing pattern
  • :g!/{pattern}/d - delete all lines not containing pattern
  • d$ or D - sterge (taie) pana la sfarsitul liniei
  • x - sterge (taie) un caracter

Indent text

  • >> - indent (move right) line one shiftwidth
  • << - de-indent (move left) line one shiftwidth
  • >% - indent a block with () or {} (cursor on brace)
  • <% - de-indent a block with () or {} (cursor on brace)
  • >ib - indent inner block with ()
  • >at - indent a block with <> tags
  • 3== - re-indent 3 lines
  • =% - re-indent a block with () or {} (cursor on brace)
  • =iB - re-indent inner block with {}
  • gg=G - re-indent entire buffer
  • ]p - paste and adjust indent to current line

Iesire

  • :w - salveaza fisierul, dar nu iesi
  • :w !sudo tee % - salveaza fisierul folosind sudo
  • :wq or :x or ZZ - salveaza fisierul si iesi din program
  • :q - iesi din program (nu iese daca fisierul nu este salvat)
  • :q! or ZQ - iesi si sterge modificarile din fisier
  • :wqa - exiting.commands.colonwqa

Cauta si inlocuieste

  • /pattern - cauta dupa sablon
  • ?pattern - cauta inapoi dupa sablon
  • \vpattern - sablon 'foarte magic': caracterele non-alfanumerice sunt interpretate ca symboluri regex (nu e nevoie de escaping)
  • n - repeta cautarea inainte
  • N - repeta cautarea inapoi
  • :%s/old/new/g - inlocuieste peste tot old cu new in fisier
  • :%s/old/new/gc - inlocuieste peste tot old cu new in fisier cu confirmare
  • :noh[lsearch] - sterge highlightul cuvintelor potrivite

Cauta in fisiere multiple

  • :vim[grep] /pattern/ {`{file}`} - cauta dupa sablon in fisiere multiple
e.g. :vim[grep] /foo/ **/*
  • :cn[ext] - sari la urmatoarea potrivire
  • :cp[revious] - sari la potrivirea anterioara
  • :cope[n] - deschide o fereastra care contine lista de potriviri
  • :ccl[ose] - close the quickfix window

Taburi

  • :tabnew or :tabnew {page.words.file} - deschide fisierul intr-un tab nou
  • Ctrl + wT - muta fereastra curenta in propriul tab
  • gt or :tabn[ext] - dute la urmatorul tab
  • gT or :tabp[revious] - dute la tabul anterior
  • #gt - dute la tabul cu numarul <kbd>#</kbd>
  • :tabm[ove] # - dute la tabul din pozitia <kbd>#</kbd>
  • :tabc[lose] - inchide tabul curent si toate ferestrele lui
  • :tabo[nly] - inchide toate taburile in afara de cel curent
  • :tabdo command - ruleaza comanda in toate taburile (ex :tabo q - inchide toate taburile deschise)

Editarea fisierelor multiple

  • :e[dit] fisier - editeaza fisierul respectin intr-un nou buffer
  • :bn[ext] - dute la urmatorul buffer
  • :bp[revious] - dute la bufferul anterior
  • :bd[elete] - sterge un buffer (inchide fisierul)
  • :b[uffer]# - go to a buffer by #
  • :b[uffer] file - go to a buffer by file
  • :ls or :buffers - arata o lista cu bufferele deschise
  • :sp[lit] fisier - deschide fisierul intr-un buffer now si imparte fereastra
  • :vs[plit] fisier - deschide fisierul intr-un buffer now si imparte fereastra vertical
  • :vert[ical] ba[ll] - edit all buffers as vertical windows
  • :tab ba[ll] - edit all buffers as tabs
  • Ctrl + ws - imparte fereastra orizontal
  • Ctrl + wv - imparte fereastra vertical
  • Ctrl + ww - schimba fereastra
  • Ctrl + wq - iesi din fereastra
  • Ctrl + wx - exchange current window with next one
  • Ctrl + w= - make all windows equal height & width
  • Ctrl + wh - muta cursorul in fereastra din stanga (vertical)
  • Ctrl + wl - muta cursorul in fereastra din dreapta (vertical)
  • Ctrl + wj - muta cursorul in fereastra de sus (orizontal)
  • Ctrl + wk - muta cursorul in fereastra de jos (orizontal)
  • Ctrl + wH - make current window full height at far left (leftmost vertical window)
  • Ctrl + wL - make current window full height at far right (rightmost vertical window)
  • Ctrl + wJ - make current window full width at the very bottom (bottommost horizontal window)
  • Ctrl + wK - make current window full width at the very top (topmost horizontal window)

Diff

  • zf - manually define a fold up to motion
  • zd - delete fold under the cursor
  • za - toggle fold under the cursor
  • zo - open fold under the cursor
  • zc - close fold under the cursor
  • zr - reduce (open) all folds by one level
  • zm - fold more (close) all folds by one level
  • zi - toggle folding functionality
  • ]c - jump to start of next change
  • [c - jump to start of previous change
  • do or :diffg[et] - obtain (get) difference (from other buffer)
  • dp or :diffpu[t] - put difference (to other buffer)
  • :diffthis - make current window part of diff
  • :dif[fupdate] - update differences
  • :diffo[ff] - switch off diff mode for current window
Tip The commands for folding (e.g. za) operate on one level. To operate on all levels, use uppercase letters (e.g. zA).
Tip To view the differences of files, one can directly start Vim in diff mode by running vimdiff in a terminal. One can even set this as git difftool.