Tags: #vim #beginner
There are many ‘motions’ and things you can do but I would probably say there are some essential motions you’ll use a lot…
:<LINE_NUMBER>
to jump to a specific line number (e.g. :10
)gg
to go to the top of the file (G
to go to the bottom)Ctrl+d
to go down half a page (Ctrl+u
to go up half a page){
and }
to jump back and forth between paragraphsf<CHARACTER>
to jump forward on the current line to a specific character (use F
to search backwards in the line).^
to go to the start of the line (0
if you want to specifically go back to the zero column)$
to go to the end of the line/<PATTERN>
to search for text in the current buffer (see https://www.vimregex.com/ or use \v
flag to make regexes a bit more sane, e.g. /\v<PATTERN
)The typical structure for doing something like “delete the text inside parentheses” is… “operation, placement, pattern” (not sure if that’s the correct terminology to use, I’ve not had to think about that sort of stuff in a long time 😅) but an example would be di(
where d
is the operation (i.e. delete), i
is the placement (i.e. inside), (
is the pattern (i.e. the parenthesis).
For the “operation”: you have d
for delete, v
for select, c
for change.
For the “placement”: you have i
for inside, a
for around.
Example: if I have the text myFunction(something)
and my cursor is inside the parentheses then I can do…
ci(
to remove the text inside the parentheses and put me into INSERT
mode so I can type new textvi(
to select the text inside the parentheses, where I can then y
to “yank” the text into my clipboarddi(
to get myFunction()
da(
to get myFunction
Of course there’s a lifetime of motions/movement/modal stuff you can learn but I’d definitely say the above is my “bread and butter” of things I use a lot (outside of features from plugins).
Good luck!
EDIT: the following Neovim plugins can help you https://github.com/jinh0/eyeliner.nvim + https://github.com/folke/which-key.nvim