sudoedit.com!

vim - notes

Handy Dandy Cheat Sheet

vim cheat sheet

:set incsearch 

jumps

The :jumps command gives a list of positions you jumped to.

Jump to last

ctrl + o

Open vim with backup copy

vim -c "set backupcopy=yes" <file_name>

vim remove starting spaces

:%s/^\s\+

or use left align command

:%le

vim remove trailing white space

:%s/\s\+$//

Open multiple files in vim

vim -d file1 file2

Create a new file

:e name-of-file.extension

Show buffers (other open files)

:ls

Switch between buffers

:b <number>
:b 2

Next buffer / previous buffer

bn
bp

Split windows

:split file_name
:vsplit filename
:vsp filename
:vs
:sp

move between windows or splits

control + w 2times
or
ctrl + w [h/j/k/l] --> vim movements 

Vim tabs

open multiple files in tabs

vim -p file1 file2
tabnew path/to/file
tabedit file

Move between tabs

gt --> move to next tab
gT --> move to previous tab

Vim file explorer

:Explore - opens netrw in the current window
:Sexplore - opens netrw in a horizontal split
:Vexplore - opens netrw in a vertical split

List registers

:reg

If you found this useful please consider supporting the blog.

Fastmail

I use Fastmail to host my email for the blog. If you follow the link from this page you'll get a 10% discount and I'll get a little bit of break on my costs as well. It's a win win.


Backblaze

Backblaze is a cloud backup solution for Mac and Windows desktops. I use it on my home computers, and if you sign up using the link on this page you get a free month of service through backblaze, and so do I. If you're looking for a good backup solution give them a try!

Thanks!

Luke

#notes #vim