Coc.nvim: Goto Definition in Vsplit?

Created on 9 Oct 2019  路  8Comments  路  Source: neoclide/coc.nvim

How would I "Goto Definition" in a separate tab? Here's my .vimrc config:

nmap <silent> \ge <Plug>(coc-definition)
nmap <silent> \gs :split<CR><Plug>(coc-definition)
nmap <silent> \gv :vsplit<CR><Plug>(coc-definition)
nmap <silent> \gt :tabnew<CR><Plug>(coc-definition)

The first three options work, (open, open in split, open in vsplit) but not the last.

I see that there is a Config setting ("coc.preferences.jumpCommand") but am hoping there is a way set a keybinding in my vimrc.

Any ideas?

Most helpful comment

@chemzqm thanks for the hint. Here's the syntax that worked for me:

:call CocAction('jumpDefinition', 'split')
:call CocAction('jumpDefinition', 'vsplit')
:call CocAction('jumpDefinition', 'tabe')

All 8 comments

OK this seems to work:

nmap <silent> \ge <Plug>(coc-definition)
nmap <silent> \gs :sp<CR><Plug>(coc-definition)
nmap <silent> \gv :vsp<CR><Plug>(coc-definition)
nmap <silent> \gt :vsp<CR><Plug>(coc-definition)<C-W>T

:h coc-action-jumpDefinition

@chemzqm thanks for the hint. Here's the syntax that worked for me:

:call CocAction('jumpDefinition', 'split')
:call CocAction('jumpDefinition', 'vsplit')
:call CocAction('jumpDefinition', 'tabe')

I've tried:

nmap <silent> gd <Plug>(coc-action-jumpDefinition)

but it does not work, how can i set the "jumpDefinition" to open on a new "vsplit"?

@rafa-acioly you need to understand function and key-mapping of vim.

Hey @rafa-acioly,

take a look at :help n_coc-definition@en I think that's what you are looking for.

@rafa-acioly you need to understand function and key-mapping of vim.

one of many good example url guides

@rafa-acioly you need to understand function and key-mapping of vim.

what is the best video to learn that

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lanox picture lanox  路  3Comments

czepluch picture czepluch  路  3Comments

skylite21 picture skylite21  路  3Comments

FrankLA0203 picture FrankLA0203  路  3Comments

iago-lito picture iago-lito  路  3Comments