Search code examples
vivimctags

vi command line equivalent to CTRL-]?


I'm trying to map my own shortcuts in vi. I want to be able to open a splitted window containing the declaration of the function I'm calling the shortcut on. something like this in my vimrc:

nmap <unique> <silent> <Leader>tg :exe 'vsplit'\| equivalent of <C-]>

but what's the equivalent of C-] in command mode ?


Solution

  • To open vim at the line containing the tag foobar type this at the shell commandline:

    vim -t foobar
    

    To jump to the same tag on the vim commandline type:

    :tag foobar
    

    If you want to split the window and jump to the tag in the new window type this in vim's commandline:

    :stag foobar
    

    If you want a keystroke that specifies "the word under the cursor", then according to this question, you can use the CTRL+R CTRL+W to get that:

    :tag CTRL+R CTRL+W

    You can also use :

    :nmap <leader>w :tag <c-r>=expand("<cword>")<c-r>
    

    Now typing <leader>+w (which is \ in my setup, so I'd press \w) will be the same as typing :tag <word under the cursor>