Nvim :help
pages, generated
from source
using the tree-sitter-vimdoc parser.
CTRL-]
command.
:tselect Select one tag out of a list of matching tags./* */
, #if, #else, #endif.
[/ Go to previous start of comment.
]/ Go to next end of comment.
[# Go back to unclosed #if, #ifdef, or #else.
]# Go forward to unclosed #else or #endif.
[( Go back to unclosed '('
]) Go forward to unclosed ')'
[{ Go back to unclosed '{'
]} Go forward to unclosed '}'[{
to ]}
, including brackets
v_iB Select "inner block" from [{
to ]}
map _u :call ID_search()<Bar>execute "/\\<" .. g:word .. "\\>"<CR> map _n :n<Bar>execute "/\\<" .. g:word .. "\\>"<CR> function! ID_search() let g:word = expand("<cword>") let x = system("lid --key=none " .. g:word) let x = substitute(x, "\n", " ", "g") execute "next " .. x endfunTo use it, place the cursor on a word, type "_u" and vim will load the file that contains the word. Search for the next occurrence of the word in the same file with "n". Go to the next file with "_n".
CTRL-X
CTRL-E
and CTRL-X
CTRL-Y
to scroll the screen.
i_CTRL-X_CTRL-E:inoremap <C-E> <C-X><C-E> :inoremap <C-Y> <C-X><C-Y>You then lose the ability to copy text from the line above/below the cursor i_CTRL-E.
:map <C-U> <C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y><C-Y> :map <C-D> <C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E><C-E>
:ab teh the :ab fro for
:%s/./&/gn characters :%s/\i\+/&/gn words :%s/^//n lines :%s/the/&/gn "the" anywhere :%s/\<the\>/&/gn "the" as a wordYou might want to reset 'hlsearch' or do ":nohlsearch". Add the 'e' flag if you don't want an error when there are no matches.
count-bytes
:echo strlen(@")A line break is counted for one byte.
:map <F2> msHmtgg/Last [cC]hange:\s*/e+1<CR>"_D"=strftime("%Y %b %d")<CR>p'tzt`sBreaking up saving the position: ms store cursor position in the 's' mark H go to the first line in the window mt store this position in the 't' mark
*.c
*.bla
. I'd do it like this:$ vim :r !ls *.c :%s/\(.*\).c/mv & \1.bla :w !sh :q!
:%s/Jones/Smith/g :%s/Allen/Peter/g :update
vim *.let argdo source subs.vimSee :argdo.
if ($?prompt == 0) then exit 0 endifAnother way is to include the "-f" flag in the 'shell' option, e.g.:
:set shell=csh\ -f(the backslash is needed to include the space in the option). This will make csh completely skip the use of the .cshrc file. This may cause some things to stop working though.
map-backtick
:map ' `Make the single quote work like a backtick. Puts the cursor on the column of a mark, instead of going to the first non-blank character in the line.
emacs-keys
" start of line :cnoremap <C-A> <Home> " back one character :cnoremap <C-B> <Left> " delete character under cursor :cnoremap <C-D> <Del> " end of line :cnoremap <C-E> <End> " forward one character :cnoremap <C-F> <Right> " recall newer command-line :cnoremap <C-N> <Down> " recall previous (older) command-line :cnoremap <C-P> <Up> " back one word :cnoremap <Esc><C-B> <S-Left> " forward one word :cnoremap <Esc><C-F> <S-Right>
format-bullet-list
:let m = ":map _f :set ai<CR>" " need 'autoindent' set :let m ..= "{O<Esc>" " add empty line above item :let m ..= "}{)^W" " move to text after bullet :let m ..= "i <CR> <Esc>" " add space for indent :let m ..= "gq}" " format text after the bullet :let m ..= "{dd" " remove the empty line :let m ..= "5lDJ" " put text after bullet :execute m |" define the mapping(<> notation <>. Note that this is all typed literally. ^W is "^" "W", not
|"
, because the ":execute" command
doesn't accept a comment directly.:set tw=70A mapping that does about the same, but takes the indent for the list from the first line (Note: this mapping is a single long line with a lot of spaces):
:map _f :set ai<CR>}{a <Esc>WWmmkD`mi<CR><Esc>kkddpJgq}'mJO<Esc>j
collapse
:map ;b GoZ<Esc>:g/^$/.,/./-j<CR>Gdd :map ;n GoZ<Esc>:g/^[ <Tab>]*$/.,/[^ <Tab>]/-j<CR>Gdd
:%s=\(\t.*\.txt\)\t=\1.gz\t=(3) Add this line to your vimrc:
set helpfile={dirname}/help.txt.gzWhere
{dirname}
is the directory where the help files are. The gzip plugin
will take care of decompressing the files.
You must make sure that $VIMRUNTIME is set to where the other Vim files are,
when they are not in the same location as the compressed "doc" directory. See
$VIMRUNTIME." vim -b : edit binary using xxd-format! augroup Binary autocmd! autocmd BufReadPre *.bin set binary autocmd BufReadPost *.bin \ if &binary \ | execute "silent %!xxd -c 32" \ | set filetype=xxd \ | redraw \ | endif autocmd BufWritePre *.bin \ if &binary \ | let s:view = winsaveview() \ | execute "silent %!xxd -r -c 32" \ | endif autocmd BufWritePost *.bin \ if &binary \ | execute "silent %!xxd -c 32" \ | set nomodified \ | call winrestview(s:view) \ | redraw \ | endif augroup END
map-self-destroy
" This is for automatically adding the name of the file to the menu list. " It uses a self-destroying mapping! " 1. use a line in the buffer to convert the 'dots' in the file name to \. " 2. store that in register '"' " 3. add that name to the Buffers menu list " WARNING: this does have some side effects, like overwriting the " current register contents and removing any mapping for the "i" command. " autocmd BufNewFile,BufReadPre * nmap i :nunmap i<CR>O<C-R>%<Esc>:.g/\./s/\./\\./g<CR>0"9y$u:menu Buffers.<C-R>9 :buffer <C-R>%<C-V><CR><CR> autocmd BufNewFile,BufReadPre * normal iAnother method, perhaps better, is to use the ":execute" command. In the string you can use the <> notation by preceding it with a backslash. Don't forget to double the number of existing backslashes and put a backslash before '"'.
autocmd BufNewFile,BufReadPre * exe "normal O\<C-R>%\<Esc>:.g/\\./s/\\./\\\\./g\<CR>0\"9y$u:menu Buffers.\<C-R>9 :buffer \<C-R>%\<C-V>\<CR>\<CR>"For a real buffer menu, user functions should be used (see :function), but then the <> notation isn't used, which defeats using it as an example here.
let s:paren_hl_on = 0 function s:Highlight_Matching_Paren() if s:paren_hl_on match none let s:paren_hl_on = 0 endif let c_lnum = line('.') let c_col = col('.') let c = getline(c_lnum)[c_col - 1] let plist = split(&matchpairs, ':\|,') let i = index(plist, c) if i < 0 return endif if i % 2 == 0 let s_flags = 'nW' let c2 = plist[i + 1] else let s_flags = 'nbW' let c2 = c let c = plist[i - 1] endif if c == '[' let c = '\[' let c2 = '\]' endif let s_skip ='synIDattr(synID(line("."), col("."), 0), "name") ' .. \ '=~? "string\\|comment"' execute 'if' s_skip '| let s_skip = 0 | endif' let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip) if m_lnum > 0 && m_lnum >= line('w0') && m_lnum <= line('w$') exe 'match Search /\(\%' .. c_lnum .. 'l\%' .. c_col .. \ 'c\)\|\(\%' .. m_lnum .. 'l\%' .. m_col .. 'c\)/' let s:paren_hl_on = 1 endif endfunction autocmd CursorMoved,CursorMovedI * call s:Highlight_Matching_Paren() autocmd InsertEnter * match none
:HelpCurwin
command:
command -bar -nargs=? -complete=help HelpCurwin execute s:HelpCurwin(<q-args>) let s:did_open_help = v:false function s:HelpCurwin(subject) abort let mods = 'silent noautocmd keepalt' if !s:did_open_help execute mods .. ' help' execute mods .. ' helpclose' let s:did_open_help = v:true endif if !empty(getcompletion(a:subject, 'help')) execute mods .. ' edit ' .. &helpfile set buftype=help endif return 'help ' .. a:subject endfunction