I hope that you use the motion commands at least, because that’s the whole point of the separate modes. If not, you should look them up and add some of them to your workflow little by little.
The most basic ones are wand b to go a word forward or back; 0 and $ to go to the start or end of the line, or g0 and g$ for the visual line. f to jump to a particular letter forward. { and } to go to the start/end of the paragraph.
V is useful for selecting whole lines.
% can jump or select to the matching parenthesis or brace. With matchit installed, it also jumps to matching keywords like end or HTML tags.
For pasting, you should use p in the normal mode. Also P pastes before the cursor. This is useful for moving text around by deleting it with something like daw, jumping elsewhere, and doing p.
This is all very advanced to me. I use Home and End to go forward and back in the line, but w and b sound good to m (just wish they made more intuitive sense), also p and P.
Vim has a built-in tutorial on the motion commands and such. I don’t remember how it’s invoked, but probably something like :help tutorial. You’ll get an overview of the commands and see which ones might be useful to you right away. As I mentioned, I recommend getting the hang of them one or a few at a time, so they are incorporated in your toolbox.
Speaking of help, it’s generally useful in Vim to use :help {something} when you want to recall how something works. It has consistent naming for the help pages for various functionality, e.g. :help:s shows the page about the :s command, and there are pages for every motion command, etc. — I don’t remember the prefixes as it’s been a while since I used Vim proper, but just :help should give you an index.
Also, if you’re coding in Vim, there are ways to integrate documentation for your language, so that K would show help for the function or whatever under the cursor. Back in the day I’ve had PHP docs plugged into Vim, but it’s been a while, so idk how it’s done now. Iirc there are dumps of docs from the Dash app, which might be available as vimdocs.
I keep thinking that as I use vim, I’ll feel the need to learn more commands, but I hardly do anything except:
What are your vim GOTOs?
I hope that you use the motion commands at least, because that’s the whole point of the separate modes. If not, you should look them up and add some of them to your workflow little by little.
The most basic ones are
wandbto go a word forward or back;0and$to go to the start or end of the line, org0andg$for the visual line.fto jump to a particular letter forward.{and}to go to the start/end of the paragraph.Vis useful for selecting whole lines.%can jump or select to the matching parenthesis or brace. With matchit installed, it also jumps to matching keywords likeendor HTML tags.For pasting, you should use
pin the normal mode. AlsoPpastes before the cursor. This is useful for moving text around by deleting it with something likedaw, jumping elsewhere, and doingp.This is all very advanced to me. I use Home and End to go forward and back in the line, but w and b sound good to m (just wish they made more intuitive sense), also p and P.
I should print out a ref sheet.
Vim has a built-in tutorial on the motion commands and such. I don’t remember how it’s invoked, but probably something like
:help tutorial. You’ll get an overview of the commands and see which ones might be useful to you right away. As I mentioned, I recommend getting the hang of them one or a few at a time, so they are incorporated in your toolbox.Speaking of help, it’s generally useful in Vim to use
:help {something}when you want to recall how something works. It has consistent naming for the help pages for various functionality, e.g.:help :sshows the page about the:scommand, and there are pages for every motion command, etc. — I don’t remember the prefixes as it’s been a while since I used Vim proper, but just:helpshould give you an index.Also, if you’re coding in Vim, there are ways to integrate documentation for your language, so that
Kwould show help for the function or whatever under the cursor. Back in the day I’ve had PHP docs plugged into Vim, but it’s been a while, so idk how it’s done now. Iirc there are dumps of docs from the Dash app, which might be available as vimdocs.ctrl+n while typing activates the builtin autocomplete.
Wat.
My most used commands are also just the classics
cw - delete the next word amd enter insert mode
dd - delete line
gg - go to first line
G - go to last line
:s/searchphrase/replacephrase - search and replace
And a couple of visual mode commands do cut and paste blocks or comment out blocks of code
Those might also work in the normal mode with motions, depending on the text. E.g.
gcapwould comment out the current paragraph (iirc).Oh sick I will try that
gccis the most typical, works on the current line.These look real useful, especially :cw
Thanks!
To build on cw:
ciw works when the cursor is anywhere in the word
ci( to delete everything between brackets and enter insert mode. Also ci" ciW or whatever
If editor-specific binds count, then g-. is my favorite in Zed.