config/vim

82 lines
1.8 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Save
:w !sudo tee %
Navg
entre plusieur fichier ouvert (e.g. vim /etc/passwd /etc/group)
:n
e go to the end of the current word.
E go to the end of the current WORD.
b go to the previous (before) word.
B go to the previous (before) WORD.
w go to the next word.
W go to the next WORD.
192.168.1.1 single WORD
192.168.1.1 seven words
% Go to the matching braces, or parenthesis inside code.
SUB
:[range]s[ubstitute]/{pattern}/{string}/[flags] [count]
flags:
[c] Confirm each substitution.
[g] Replace all occurrences in the line.
[i] Ignore case for the pattern.
range:
%
1,10
Visual :
You can also select a specific lines by visually selecting those lines. Press CTRL + V in command mode, use navigation keys to select the part of the file you want to be substituted. Press : which will automatically formed as :<,> Then you can use the normal substitute as
:'<,'>s/helo/hello/g
"<" ">" delimiter de debut et fin de mot. e.g.
:s/\<his\>/her/
When the string starts with \=, it should be evaluated as an expression. Using the line function we can get the current line number. By combining both the functionality the substitution does the line numbering of all lines.
:%s/^/\=line(".") . ". "/g
\=submatch(0) get the 1st matched pattern
BOOKMARK
local bookmark (dans un fichier)
créer : m{macro-name} e.g. ma
acces : `{macro-name} e.g. `a
acces debut ligne : '{macro-name} 'a
list : :marks
global bookmark
meme chose mais avec macro-name en majuscule
RECORDS
Start:
Type: Esc q followed by a
q indicates to start the recording
a indicates to store the recordings in register a
When you do q a, it will display “recording” at the bottom of the vi.
DO STUFF....
Stop:
Type: q
Repeat:
98@a : repeat 98 times whats in macro a