开发者

Vim as a note taking platform: Jump to tag in vertically split windows

In the past, I have used Vim as a note taking platform by creating an index.txt file with a list of tags using the Vim help file format and then creating a bunch of text files that have the normal *Help_Tag* link syntax so that using CTRL-] on a tag in the index.txt file will jump to the respective tag in an arbitrary notes text file. You need to do :helptags dir to generate the tags for the directory (where dir is the path to the notes directory).

Vim as a note taking platform: Jump to tag in vertically split windows

What I am looking for is a simple way to be on the left split window and open the tag under the cursor in the right split window. Something like CTRL-W v but for tag jumping and using the already open vertical split window.

The problem is if you do CTRL-] it will open the tag in the left pane and 开发者_如何学Goif you do CTRL-W CTRL-] it creates a horizontally split window in the left pane.

There must be a way to do this that I'm overlooking.


map <A-]> :vsp<CR>:exec("tag ".expand("<cword>")) " Open the definition in a new vsplit


Probably the easiset would be an autocommand local mapping

au FileType index.txt nnoremap <buffer> <cr> 
    \ :vert belowright split 
    \ |tag <c-r><c-w>
    \ |vert resize 130<cr>

Note I use return


Try this mapping:

nmap <buffer> <C-]> :let word=expand("<cword>")<CR><C-W>l:exe "tag" word<CR>

It stores the word under the cursor in the variable word, then swaps the window and goes to the tag with that name. The <buffer> bit makes this mapping only apply to the current buffer.


If you're using headings as note titles, you could use Vim VOoM, which automatically outlines based on sytax and allows for easy navigation with the standard navigation keys.

Vim VOoM also works with foldmarkers, like in the example screenshot.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜