2011-01-05 3 views
3

MacVim을 사용하고 있으며 대개 여러 개의 탭이 열려 있습니다. 열려있는 파일 중 하나에 마크를 떨어 뜨리고 파일 사이를 이동할 수 있기를 바랍니다. mK and 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 마커를 찾으려면 ... 더 좋은 방법이 있어야합니까?vim에서 다른 탭 내의 마커로 어떻게 이동합니까?

+5

이 줄이 맞지 않을 수도 있지만, 나는 재미 느낌 [이] (http://stackoverflow.com/questions/102384/using-vims-tabs-like-buffers/103590#103590) 대답을 여기에 적용됩니다. –

+0

예. 당신이 옳다고 생각합니다. 나는 이전 편집자로 vim을 만들려고 노력하고 있는데 실제로는 탭을 없애는 것이 더 나을 것입니다. –

답변

3

다음은 사용자의 필요에 신속하고 더러운 해킹입니다.

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, \', ang \*backtick*

  • 에 대한 매핑을 제공해야합니다. 분할 된 계정을 고려하지 않습니다.

관련 문제