vim-cheet-sheet/new-info.txt

119 lines
5.6 KiB
Plaintext
Raw Normal View History

2025-05-01 06:28:28 +00:00
Commands:
ZZ -- write out and exit
75 i ! <Esc> -- insert "!" 75 times
75 a ! <Esc> -- append "!" 75 times
Ctrl-] -- move to |hyperlink|
Ctrl-O -- come back from hyperlink
2025-05-01 07:31:26 +00:00
Help:
:help index -- complete index of all Vim commands
:help Ctrl-W -- find help with window management command
:help usr_toc.txt -- all user manuals breef look
2025-05-01 06:28:28 +00:00
2025-05-01 13:53:35 +00:00
Word / file navigation (3):
2025-05-01 06:28:28 +00:00
fh | 3fl -- move cursor to the "h" letter of the current line
f<Esc> -- aborts search
Fh | 3Fl -- like above, but searches to the left
tl | 3tl -- like fh, but cursor stops before the letter
Tl | 3Tl -- like above, but searches to the left
ge -- moves to the previous end of the word
$ | 5$ -- to the end of the line
^ -- to begin of the first word in line
0 -- to begin of the line
2025-05-01 07:16:50 +00:00
25% -- moves you to the 1/4 of the file
H -- move cursor to the top line of the current window
M -- move cursor to the middle line of the current window
L -- move cursor to the bottom line of the current window
Ctrl-G -- get where you are in the file
zt -- like below, but to the top
zz -- moves context to the middle of the current cursor pos
zt -- like above, but to the bottom
* -- finds word under cursor in the file
# -- same like above, but to the other direction
/the\> -- finds only words that ends in "the "
/\<the\> -- finds only " the " matches
`` -- go to the prev position (mark, mark -- pos before jump)
Ctrl-O -- go to the previous jump (mark)
Ctrl-I -- go to the next jump (mark)
m[a-z] -- set mark with letter name
'[a-z] -- move to the row with the mark
`[a-z] -- move to the row and column with the mark
:set hlsearch -- will highlight all matches
:set ignorecase -- to ignore letter case during searches
:set number -- show line numbers
:set nonumber -- unshow line numbers
:set ruler -- show in the bottom right corner where is your cursor
2025-05-01 07:31:26 +00:00
:marks -- see all available marks
2025-05-02 04:24:48 +00:00
:marks p -- to see where mark are specified
:marks pF -- to see where several marks are specified
2025-05-01 07:31:26 +00:00
2025-05-01 13:53:35 +00:00
Making small changes (4):
2025-05-01 07:31:26 +00:00
d$ -- deletes to the end of the line
cc -- like dd, but changes line
c$ -- changes all to the end of the line
X -- delete prev symbol
D -- delete to the end of the line
C -- change to end of the line
s -- change one character
S -- change a whole line
2025-05-01 13:53:35 +00:00
r | 4rx -- replace current symbol, not enters in insert mode
. -- repeat the change
O | o -- in visual mode goes to the other corner of selected
y -- yank operator. yw - yank word, y2w - yank 2 words
Y | yy -- yank whole line
y$ -- yank to the end of the line
iw | aw -- Call to word text object. iw - "Inner word",
2025-05-02 04:24:48 +00:00
aw - "A word" (Try to use in visual mode or delete).
2025-05-01 13:53:35 +00:00
daw -- delete a word. You can use it even in a mid of the word
is | as -- Call to sentence text object. "as" includes space after
is - "Inner Sentence", as - "A Sentence"
cis -- change whole sentence
R -- enter in replace mode. backspace works like undo.
~ -- Change case of the character under cursor
I -- insert to the begin of the line
A -- append to the end of the line
Editing more than one file (7):
:edit foo.txt -- opens other file instead of current
:write -- save current file delta
:edit! foo.txt -- force to discard your changes
vim one.c two.c three.c -- open a sequence of files
:next -- switch to next file
:next! -- like above, but not save changes
:wnext -- like above, but save changes
2025-05-02 04:24:48 +00:00
:args -- see the files you started Vim with
:previous
:wprevious
:last
:first
:2next
:set autowrite -- always write to modified files after switch
:set noautowrite -- turn off write to modified files
:args one.c six.c -- redefine the list of files without the need to
exit Vim and start it again
:args! -- abandon the changes
Ctrl-^ -- back to previous file
`. -- jump to position where you did the last change
"fyas -- use f register for yank to in sentence
"l3Y -- yank three whole lines to the l register
"fp -- put register buffer to the cursor position
"wdaw -- delete text to register
:write >> myfile -- append current file to another file
2025-05-01 06:28:28 +00:00
2025-05-01 07:31:26 +00:00
Window management:
Always starts from Ctrl-W
Ctrl-W h -- to the left window
Ctrl-W j -- to the bottom window
Ctrl-W l -- to the top window
Ctrl-W l -- to the right window
Ctrl-H H -- move window to left
Ctrl-H J -- move window to bottom
Ctrl-H K -- move window to top
Ctrl-H L -- move window to right
2025-05-01 06:28:28 +00:00
2025-05-02 04:24:48 +00:00
Hints:
There is lowercase and uppercase marks. Uppercase marks are global, they
can help you to switch between the files. Lowercase marks are local for
one file.