Neovim Tutor
After going through Programming in Lua, I started watching a video series on learning Neovim. It really got me wanting to try out Neovim, so I started with the tutor. I’ll probably just throw in a few of the most important things I learn in each chapter of the tutor.
Chapter 1
- Moving can be done with the arrows or
h,j,k, andlto move left, down, up, and right respectively - You can open any file in Neovim with
nvim FILENAME. - Exiting Neovim is done with
:q!to discard changes, and:wqto keep changes - Deleting characters outside of
insertmode can be done with hittingx - Entering
insertmode can be done by hittingi- You can append to any line by hitting
A
- You can append to any line by hitting
- Hitting
Escbrings you back tonormalmode
Chapter 2
- The
deleteoperator can be used to quickly get rid of wordsdwto delete from your cursor to the next wordd$to delete from your cursor to the end of a lineddto delete an entire line
- You can use numbers before operators to repeat operations
wmoves word to word by the first letteremoves word to word by the last letter
- Change command syntax is as follows,
operator [number] motion 0moves to the beginning of a line- Undo changes with
u- Undo all changes to a line with
U- Go forward in time with
Ctrl+r
- Go forward in time with
- Undo all changes to a line with
Chapter 3
- After deleting anything, you can put it anywhere with
p, placing it after the cursor - Replace any character with
rand the character you want cis the change operator; it replaces a section with putting you intoinsertmode to make changesceorc#ewill delete from the cursor to the end of the word or # amount of words
Chapter 4
- If you want to display your current line location, you can with
Ctrl+gggbrings your cursor to the first line#Gbrings your cursor to line number #Gbrings your cursor to the end of the file
- You can search for text using
/and text to search forward in the file- You search backwards using
? - When searching, press
nfor the next occurrence andNfor the previous
- You search backwards using
- Use
%to bring your cursor to the opening or closing of a pair of brackets - Use
:s/old/newto substitute the first occurrence ofoldwithnew- You can specify what lines you want to effect with
:#,#s - You can use
:s/old/new/gto replace an entire linesoldwithnew - Use
:%s/old/newto replace alloldwithnew
- You can specify what lines you want to effect with
Chapter 5
- You can use external commands using the
!operator;:!lswill runls- Usually opens it up in a smaller window
- We can create new files easily with
:w FILENAME, and just as easily remove it with:!rm FILENAME - Traditional highlighting can be accomplished using
vorVisual Selection- After highlighting a section of text, you can use
dto simply delete the selection - You can even save and move selected text into a separate file, writing
:w FILENAME- You’ll notice after writing the
:, some more characters appeared after it,'<, '>. I don’t know why this happens, but it does let you know nicely that you are in some modifier mode
- You’ll notice after writing the
- After highlighting a section of text, you can use
- You can retrieve and place the contents of any file using
:r FILENAME- A cool trick is reading the output of external commands; you can use
:r !lsto read in the output ofls
- A cool trick is reading the output of external commands; you can use
Chapter 6
- Open is a command you can use to insert a new line under or above an existing line
- On a line, type
oto insert a new line under the line your cursor exists on - Typing
Owill do the same but above the line your cursor is on
- On a line, type
- You can append to any line
abrings you to the end of the word of your cursorAbrings you to the end of the line your cursor is on
- A new mode,
Replacemode, can be entered not usingr, butR. It works likeInsertmode but replaces over characters instead of inserting them into the line - Copy using
yand paste withp- You can use
vto select andyto copy it - You could also use
yankas an operator, like usingywto copy a word Pplaces before your cursor instead of after
- You can use
- The
:setoperator can be used to configure other commands:set icignores casing when searching:set isshows partial matches:set hlshighlights all matching phrases- Use
noin front of any of these options to switch them off
- Use