如何循环通过vim标记
要转到带有(小写)标记的下一行,我可以执行以下操作:如何循环通过vim标记,vim,Vim,要转到带有(小写)标记的下一行,我可以执行以下操作: ]" 要转到上一个标记,我可以做: [' 但是,假设我在文件中有10个标记,我是最后一个标记。是否有方法从最后一个标记循环到第一个标记(例如搜索如何“搜索到底部。从顶部继续”) 有没有办法从最后一个标记循环到第一个标记 提供较大的计数。例如,26['。要将其包装到脚本中: " our mappings with counter support nnoremap <silent>[' :<C-U>call Nex
- ]"
- ['
26['
。要将其包装到脚本中:
" our mappings with counter support
nnoremap <silent>[' :<C-U>call NextMark(-v:count1)<CR>
nnoremap <silent>]' :<C-U>call NextMark(v:count1)<CR>
function! NextMark(incr) abort
" save current line number
let l:lnum = line('.')
" go to the next lowercase mark
execute printf("normal! %d%s'", abs(a:incr), a:incr > 0 ? ']' : '[')
if l:lnum == line('.')
" no move, assume it's the last (or the first) one
if stridx(&shortmess, 's') < 0
" print message as with n/N
echohl WarningMsg
echo printf("search hit %s, continuing at %s",
\ a:incr > 0 ? 'BOTTOM' : 'TOP', a:incr > 0 ? 'TOP' : 'BOTTOM')
echohl NONE
endif
" jump to the first (or last) lowercase mark
execute printf("normal! 26%s'", a:incr > 0 ? '[' : ']')
endif
endfunction
“我们的映射与计数器支持
nnoremap[':调用下一个标记(-v:count1)
nnoremap]':调用下一个标记(v:count1)
函数!下一个标记(增量)中止
“保存当前行号
设l:lnum=直线('.')
“转到下一个小写标记
执行printf(“正常!%d%s’”,abs(a:incr),a:incr>0?']':'[')
如果l:lnum==行('.')
“不要动,假设这是最后一次(或第一次)
如果stridx(&shortmess,'s')<0
“将邮件打印为带有n/n
echohl警告消息
echo printf(“搜索命中%s,在%s继续”,
\a:incr>0?“底部”:“顶部”,a:incr>0?“顶部”:“底部”)
无回声
恩迪夫
“跳转到第一个(或最后一个)小写标记
执行printf(“正常!26%s',a:incr>0?'[':']”)
恩迪夫
端功能
有没有办法从最后一个标记循环到第一个标记
提供较大的计数。例如,26['
。要将其包装到脚本中:
" our mappings with counter support
nnoremap <silent>[' :<C-U>call NextMark(-v:count1)<CR>
nnoremap <silent>]' :<C-U>call NextMark(v:count1)<CR>
function! NextMark(incr) abort
" save current line number
let l:lnum = line('.')
" go to the next lowercase mark
execute printf("normal! %d%s'", abs(a:incr), a:incr > 0 ? ']' : '[')
if l:lnum == line('.')
" no move, assume it's the last (or the first) one
if stridx(&shortmess, 's') < 0
" print message as with n/N
echohl WarningMsg
echo printf("search hit %s, continuing at %s",
\ a:incr > 0 ? 'BOTTOM' : 'TOP', a:incr > 0 ? 'TOP' : 'BOTTOM')
echohl NONE
endif
" jump to the first (or last) lowercase mark
execute printf("normal! 26%s'", a:incr > 0 ? '[' : ']')
endif
endfunction
“我们的映射与计数器支持
nnoremap[':调用下一个标记(-v:count1)
nnoremap]':调用下一个标记(v:count1)
函数!下一个标记(增量)中止
“保存当前行号
设l:lnum=直线('.')
“转到下一个小写标记
执行printf(“正常!%d%s’”,abs(a:incr),a:incr>0?']':'[')
如果l:lnum==行('.')
“不要动,假设这是最后一次(或第一次)
如果stridx(&shortmess,'s')<0
“将邮件打印为带有n/n
echohl警告消息
echo printf(“搜索命中%s,在%s继续”,
\a:incr>0?“底部”:“顶部”,a:incr>0?“顶部”:“底部”)
无回声
恩迪夫
“跳转到第一个(或最后一个)小写标记
执行printf(“正常!26%s',a:incr>0?'[':']”)
恩迪夫
端功能