vim

Created 2022-07-23 Updated 2024-06-09

Turn off highlighting

Until next search:

Turn it off completely:

Tips

no splits - current window as [o]nly window

ctrl w o

swap windos

ctrl w x

split opened buffers (horz)

ctrl w s

split opened buffers (vert)

ctrl w v

go to split

ctrl w h/j/k/l

open new file as split

:sp <file>

:vsp <file>

Bits and pieces

cc change line

=i{ Format code block

gg=G Format file

date insertion:

:r !date

movement:

H top of screen

M middle

L bottom

Start editor at end of file:

vim -c '$' filename

Modeline

These are commands that you can embed in the files themselves. Force ino files to have C++ syntax:

// vim: ft=cpp

or possibly:

// vim: syntax=cpp

Actually, neither of the above seem to work properly. ... that's becuae /usr/share/vim/vim82/debian.vim has the line

set nomodeline

(Modeline not working)

To fix this, in ~/.vimrc:

set modeline

To convert tabs into spaces, e.g. for use in Zig, add the modeline:

// vim: set tabstop=4 sts=4 sw=4 sta et :

Substitution

Entire file, c to confirm:

:%s/x/y/gc

& - repeat last substitution

:s will repeat :s/x/y/

:sg - repeat :s/x/y/g

xlink

See also

unicode/digraphs

zettel 6

EXITS

Digraph cheatsheet

Leader mechanism