⬆️ ⬇️

Another crib

VIM contains hundreds of commands, it is impossible to learn them all, and in truth, “memorization” is a thankless task. Reading various fakie and tutorials, I took it a rule to put new commands for me into a separate file, accompanied by a brief description. In the process of working with the editor, I often look into this file and over time, many of the commands from it add to my standard set. I want to share my cheat file with you.



Command descriptions are as concise as possible, often at the expense of accuracy. Detailed information about the team can be found in the documentation (: help cmd). Additions are welcome.



Search


* - Search for a word under the cursor. As with any other search, n and N allow you to move between matches.

# - the same, but in the opposite direction.

gd - go to local ad. Goes to the first mention of the word under the cursor within the function, ignoring comments.

gD - the transition to the global ad. Similar to gd , except that the first reference is searched for within the file.

[[ - go to the beginning of the function.



Replacement


% s / foo / bar / c - replacement with confirmation.

perldo s / foo / bar / g - perl regular expressions.

')

Move


fx - move the cursor to the first character x in the current line.

tx - set the cursor before the x character.

Fx , Tx - in the opposite direction.

; - repeat the last move.

`. - go to the last edited line.

`` - go to the last active line.

% - go to the double bracket.



miscellanea


= - in the visual mode formats the selected text.

] p - inset with indents.

ga - display the character code under the cursor in the status bar.

xp - swap adjacent letters.

J - the merging of two adjacent lines.

u - visually converts the selection to lower case.

U - to the top.

! sort - visually sorts the selection. Similarly, any external command can be applied.

di { - remove text inside active curly braces. Works for any other brackets and quotes (thanks to bbbb ).

da { - the same with brackets (thanks paul ).



In conclusion, an alternative to the standard replacement with confirmation, which I often use: * or / - search for a candidate for replacement, cw - delete a word, enter a new word, n - go to the next match,. - Repeat the previous command (word replacement).

Source: https://habr.com/ru/post/109613/



All Articles