Neovim

Recently switched from Vim to Neovim, this is now out of date

Vim

vim +PluginUpdate +qall

:set paste

:qall
  • Vundle
  • PluginInstall
  • PluginUpdate

Motions

$       end of the line
^       start of the line
w       word
e       end of word

Commands

CTRL-D      show list of commands using autocompletion
TAB     autocompletion of commands
d       Delete
p       Put line BELOW cursor
u       Undo last command
U       Undo line
r       Replace char
R       Replace more chars
c       Change
o       Open new line BELOW cursor
O       Open new line ABOVE cursor

Visual mode

v       visual mode
y       yank highlighed text

Commands continued

:!ls        EXTERNAL command with pause
:r FILENAME INSERT file BELOW cursor
:r !ls      INSERT output below cursor
CTRL-G      Location in file
G       Bottom of file
g       Begining of file
number+G    Goto line number
:set hls    highlight
:set is     show partial matches
:set ic     ignore case
:set noic   no ignore case
/       Forward search
/WORD\c     forward search for WORD ignoring CASE
?       Backwards search
n       Next in direction
N       Next in OPPOSiTE direction
CTRL-O      Go back to where came from (Repeat to go futher)
%       Matching Parentheses search (Closing/Begining () {} etc tags)

Regex

:s/old/new/ Replace FIRST instance old with new on current line
:s/old/new/g    Globally in the LINE
:#,#s/old/new/g RANGE of lines
:%s/old/new/g   every occurrence in the whole FILE
:%s/old/new/gc  with PROMPT 
:s/old/new/ Replace FIRST instance old with new on current line
:s/old/new/ Replace FIRST instance old with new on current line

Window management

CTRL-W  jump window

Auto Increment SOA records for bind

"~/.vim/plugin/soa.vim
"--- .../plugins/named.vim ----
function! UPDSERIAL(date, num)
if (strftime("%Y%m%d") == a:date)
return a:date . a:num+1
endif
return strftime("%Y%m%d") . '01'
endfunction

"command Soa :%s/\(2[0-9]\{7}\)\([0-9]\{2}\)\(\s*;\s*serial\)/\=UPDSERIAL(submatch(1), submatch(2)) . submatch(3)/gc
command Soa :%s/\(2[0-9]\{7}\)\([0-9]\{2}\)\(\s*;\s*serial\)/\=UPDSERIAL(submatch(1), submatch(2)) . submatch(3)/g
"---- eof ---------------------

Last modified: Sun Jul 14 23:19:33 2024