Type set -o vi
. This will allow you to use vim
keybindings. Hit Esc
then v
and you get
the vim editor.
:autocmd BufWritePost * !echo hi there
In insert mode, hit ^R
followed by =
. Then type
in 1+2
and hit enter.
:r !ls
. We could have ran the calculator example
using :r !echo "1+2" | bc
.
vim -MR filename.extension
In normal mode start recording a macro by hitting q
followed by a character
name the macro. To play the macro hit @
followed by the character you used.
Hit m
followed by any character. To jump to the mark hit backtick followed by
the character you chose.
In normal mode hit /your_search_query
.
:%s/foo/bar/g
:call cursor(12,5)
or :12
then hit enter followed by 5l
.
This is where vim will search when using :find file_name
.
Just type :set path?
. Pro tip: get vim to search subfolders by using :set path+=**
.
In visual mode select text and hit !
followed by the external command you
want to run on the selection. Some cool external commands are figlet
,
column
, cowsay
in addition to others.
In insert mode use ^x
followed by ^f
. Try this: in insert mode
type /
then hit ^x
followed by ^f
. To cycle through choices
using ^f
or ^p
and ^n
. Learn more about usage with :h ins-completion
.
Try :b intro
. Pro tip: see opened buffers using :ls
.