Nvim :help 页面,从 源代码 生成,使用 tree-sitter-vimdoc 解析器。
/* */,#if,#else,#endif。 [/ 转到前一个注释的开始。 ]/ 转到下一个注释的结束。 [# 回到未闭合的 #if,#ifdef 或 #else。 ]# 前进到未闭合的 #else 或 #endif。 [( 回到未闭合的 '(' ]) 前进到未闭合的 ')' [{ 回到未闭合的 '{' ]} 前进到未闭合的 '}'[{ 到 ]} 选择一个“块”,包括中括号 v_iB 从 [{ 到 ]} 选择一个“内部块”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
endfun要使用它,将光标放在一个词上,输入“_u”,vim 将加载包含该词的文件。使用“n”在同一文件中搜索该词的下一个出现位置。使用“_n”转到下一个文件。:inoremap <C-E> <C-X><C-E> :inoremap <C-Y> <C-X><C-Y>这样你将失去从光标上方/下方复制文本的能力 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 word你可能想要重置 'hlsearch' 或执行“:nohlsearch”。如果不想在没有匹配项时出现错误,请添加“e”标志。
:echo strlen(@")换行符计为一个字节。
:map <F2> msHmtgg/Last [cC]hange:\s*/e+1<CR>"_D"=strftime("%Y %b %d")<CR>p'tzt`s将保存位置分解:ms 将光标位置存储在“s”标记中。H 转到窗口的第一行。mt 将此位置存储在“t”标记中。*.c 重命名为 *.bla。我会这样做$ 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.vim请参阅 :argdo。
if ($?prompt == 0) then
exit 0
endif另一种方法是在 'shell' 选项中包含“-f”标志,例如:set shell=csh\ -f(反斜杠用于在选项中包含空格)。这将使 csh 完全跳过使用 .cshrc 文件。不过,这可能会导致某些功能停止工作。
:map ' `使单引号像反引号一样工作。将光标放在标记的列上,而不是转到行中的第一个非空白字符。
" 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>
: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(<> 符号 <>。注意,这些符号都是按字面意思输入的。^W 是“^” “W”,而不是|" 开头,因为“:execute”命令不直接接受注释。:set tw=70一个完成几乎相同功能的映射,但会从第一行获取列表的缩进(注意:此映射是一行很长的行,包含很多空格)
:map _f :set ai<CR>}{a <Esc>WWmmkD`mi<CR><Esc>kkddpJgq}'mJO<Esc>j: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) 在你的 vimrc 中添加以下行
set helpfile={dirname}/help.txt.gz其中 {dirname} 是帮助文件所在的目录。 gzip 插件将负责解压缩文件。你必须确保 $VIMRUNTIME 设置为其他 Vim 文件所在的目录,当它们不在与压缩的“doc”目录相同的位置时。请参阅 $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
" 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 i另一种方法,可能更好,是使用 ":execute" 命令。在字符串中,可以通过在前面加上反斜杠来使用 <> 符号。不要忘记将现有反斜杠的数量加倍,并在 '"' 前面加一个反斜杠。
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>"对于真正的缓冲区菜单,应该使用用户函数(参见 :function),但这样就不能使用 <> 符号,这使得它不适合用作此处的示例。
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 -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