0

When I use CTRL+] to jump to a tag, the cursor will be placed at the center of the window. How can I make it stop at the top of the window? Now I do this by pressing CTRL+D after each jump. I was wondering whether vim can do this for me automatically.

  • You can remap everything; e.g. :nnoremap <C-]> <C-]><C-d>. But Vim should already put the cursor at the top of the screen with just <C-]>. it does for me, anyway. Which filetype are you using? Make use a custom implementation. Also see: How do I debug my vimrc file?. – Martin Tournoij May 25 '17 at 1:57
  • @Carpetsmoker Oh I didn't realize this, but vim does place the cursor at the top when jumping in help files. The filetype I'm using is C++. – Michael Ma May 25 '17 at 2:13
  • vim does place the cursor at the top but your question says the cursor will be placed at the center? – Martin Tournoij May 25 '17 at 2:15
  • Yeah the behaviours are different in help files and C++ files. – Michael Ma May 25 '17 at 3:07
  • 2
    Note that <C-d> will leave the cursor where it is in the window, but scroll the buffer, so the cursor will no longer be on the tag. zt (and related commands zz and zb) will move the cursor and buffer together, so both will be at the top (or middle or bottom) of the window. – 8bittree May 25 '17 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.