tags:

views:

180

answers:

3

I want to learn vim documentation given in standard help file. But I stuck on navigating issue - I just cannot go to the next tag without positioning cursor manually. I think you would agree that it is more productive to:

  1. go to the next tag with some keystroke
  2. press Ctrl-] to read corresponding topic
  3. press Ctrl-o to return
  4. continue reading initial text

PS. while I war writing this question, I tried some ideas how to resolve this. I found that searching pipe character with /| is pretty close to what I want. But tag is surrounded with two pipe '|' characters, so it's still not really optimized to use.

+2  A: 

Use the :tn and :tp sequences to navigate between tags.

If you want to look for the next tag on the same help page, try this search:

/|.\{-}|

This means to search for:

  • The character |
  • Any characters up to the next |, matching as few as possible (that's what \{-} does).
  • Another character |

This identifies the tags in the VIM help file.

Nathan Fellman
This does not work. Mentioned combinations work only for tags searching. I'm talking about navigation without previous search
altern
That's an extension of what I mentioned in the topic. I think I could map this to the <kbd>tab</kbd> and then it might work, thanks
altern
+1  A: 

Well, I don't really see the point. When I want to read everything, I simply use <pagedown> (or <c-f> with some terminals)

" .vim/ftplugin/help/navigate.vim
nnoremap <buffer> <tab> /\*\S\+\*/<cr>zt

?

Or do you mean:

nnoremap <buffer> <tab> /\|\zs\S\{-}\|/<cr><c-]>

?

Luc Hermitte
yes, I meant the second.But, speaking frankly, I was sure that vim has builtin command for this purpose and I just cannot find it.
altern
A: 

You could simply remap something like:

nmap ^\ /<Bar><Bslash>zs<Bslash>k<Bslash>+<Bar><CR>

where ^\ is entered as (on my keyboard) Ctrl-V Ctrl-#: choose whatever shortcut you want.

This does a single key search for a | followed by one or more keyword characters and then a |. It puts the cursor on the first keyword character. The and bits are there due to the way map works, see

:help :map-special-chars

As an aside, I imagine that ctrl-t would make more sense than ctrl-o as it's a more direct opposite of ctrl-], but it's up to you. Having said that, ctrl-o will allow you to go back to before the search as well.

Al
No need for <Bar> and <Bslash> here. | and \ are more than enough in this context.
Luc Hermitte
Al
My mistake. It needs to be `\|`
Luc Hermitte