====== Vim ====== {{tag>editing regex text}} [[.:|{{mdi>arrow-left-circle}}]] Record a macro into register ''a'': qa When done with adding actions to the macro stop the recording: q Execute the macro with @a Execute the previously executed macro again with @@ ==== Capitalize the first letter of every word ==== s/\<./\u&/g ==== Lookahead / Lookbehind ==== |\@<= | positive lookbehind | |\@ ==== Syntax highlighting ==== Syntax highlighting in general can be controlled by **:set syntax=[on|off]** temporarely on vim's cmdline or vimrc file. In shell scripts variables are sometimes dark blue for example. Depending on several circumstances this can be very hard to read. It is possible to change vim's behavior of highlighting things with the **hi[light]** command. Variables's look can be controlled with the **PreProc** hightlight group and the groups arguments. :hi PreProc ctermfg=28 Would set the color of the PreProc group to green - 28 in terms of 256 color table. * :help hi * :help attr-list * :help cterm * :help term Sometimes (especially in the case that you use vim in tmux) it can be very helpful to configure **set t_Co=256** ((this is a matter of bce: background color erase. You may wish to read [[https://github.com/tmux/tmux/issues/699| this thread]] )) ==== Create directories for backups, swapfiles and undofiles ==== for f in ['backups', 'swapfiles', 'undofiles'] if !isdirectory($HOME . "/.vim/" . f) call mkdir($HOME . "/.vim/" . f , "p", 0700) endif endfor This - combined with set backupdir=$HOME/.vim/backups set directory=$HOME/.vim/swapfiles set undodir=$HOME/.vim/undofiles ensures that vim collects backupfiles, swapfiles and undofiles in single locations if backups, swapfiles and undofiles are **not** deactivated by set noundofile set nobackup set noswapfile **This can lead to filename collisions**