13 liens privés
:s/aa/bb
: remplace sur une ligne
:s/aa/bb/g
: remplace toute occurence sur une ligne
:25,30s/aa/bb/g
: remplace du texte de la ligne 25 à 30
:%s/aa/bb/g
: remplace toutes les occurrences dans le fichier
:%s/aa/bb/gc
: remplace toutes les occurrences dans le fichier avec confirmation
Ce chapitre est un incontournable de la maîtrise d’un système Linux. Dans 99,99 % des cas, l’éditeur VI est présent sur votre système. Pourquoi s’en passer ?
Une autre commande pour rechercher et remplacer du texte dans vi/vim.
:%s/rechercher/remplacer/g
Pour rechercher et remplacer toutes les occurrences d'une chaîne de caractère avec vi/vim, passer la commande suivante :
:g/rechercher/s//remplacer/g
{ and }
In normal mode, go to previous/next paragraph.
and <<
In normal or visual mode, shift the line (or selection) one indent to the right (>>) or left (<<).
Ctrl+n and Ctrl+p
In insert mode, complete the current word under the cursor from the word following it (Ctrl+n) or words preceding it (Ctrl+p).
Ctrl+j
In insert mode, join the current line with the next line.
zz (two lowercase z's in normal mode)
Center the buffer so that the current line you're editing is in the middle of the screen.
ZZ (two capital Z's in normal mode)
In normal mode, same as :wq!. Saves and exits vim.