Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

vim

tags

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).

alt text

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 if 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.

like image 579
Pierre-Antoine LaFayette Avatar asked Feb 16 '10 00:02

Pierre-Antoine LaFayette


People also ask

How do I split a window in Vim?

To split the vim screen horizontally, or open a new workspace at the bottom of the active selection, press Ctrl + w , followed by the letter 's' . In the example below, the left section has been split into two workspaces. To navigate to the bottom section hit Ctrl + w , followed by the letter 'j' .

How do you split windows on Neovim?

You can move to the left window again by pressing <Crtl>+<w> and then pressing <h>. To open a new VIM window on the bottom of the currently selected window, press <Ctrl>+<w> then press <s>. You currently selected window should be split vertically as shown in the screenshot below.


2 Answers

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

like image 88
Amjith Avatar answered Oct 07 '22 15:10

Amjith


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

like image 21
michael Avatar answered Oct 07 '22 17:10

michael