gpt4 book ai didi

vim - 如何跳转到vim中不同选项卡内的标记?

转载 作者:行者123 更新时间:2023-12-02 00:35:53 25 4
gpt4 key购买 nike

我正在使用 MacVim,并且通常会打开许多​​选项卡。我希望能够在我打开的任何文件中放置标记并在它们之间跳转。 mK 和 K work great when the mark is in the same tab but I've got to use gt to find the tab and then K 找到标记...一定有更好的方法吗?

最佳答案

这是一个快速而肮脏的黑客,可以满足您的需求。

let s:marks = {}

function! s:Mark(name)
echomsg "new mark: " a:name
" todo: record the winnr/bufnr as well
let s:marks[a:name] = tabpagenr()
exe 'normal! m'.a:name
endfunction

function! s:Jump(how, name)
if has_key(s:marks, a:name)
let nr = s:marks[a:name]
tabfirst
let first = tabpagenr()
while tabpagenr() != nr
tabnext
if tabpagenr() == first
break
endif
endwhile
if tabpagenr() == nr
exe 'normal! '.a:how.a:name
" nominal termination
return
endif
endif
echoerr "tab-mark " . a:name . " not set"
endfunction

nnoremap m :call <sid>Mark(nr2char(getchar()))<cr>
nnoremap ` :call <sid>Jump('`', nr2char(getchar()))<cr>
nnoremap ' :call <sid>Jump("'", nr2char(getchar()))<cr>

问题:
  • 每个缓冲区的标记通常是不同的。在这里,所有标记都是全局的。也许,我们应该提供到 \m 的映射。 , \' , 昂 \*backtick*
  • 这不考虑拆分窗口。
  • 关于vim - 如何跳转到vim中不同选项卡内的标记?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4603745/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com