follow_link: reuse existing tabs with tab drop (closes #238)
Replaces :e in `vimwiki#base#follow_link()` with :drop, making this the default behavior for pressing <CR> on a link. Checks for the existence of :drop first, since this isn't available in some builds. Adds a new :VimwikiTabDropLink and makes this a default for the keybindings formerly occupied by :VimwikiTabnewLink; leaving :VimwikiTabnewLink available for backwards compatibility and anyone who still wants the old behavior. Doesn't touch the split window reuse functionality, or the :VimwikiGoBackLink behavior, although I can see an argument for adding :drop to the latter. I've wanted this for a while and happened to notice @davidlmontgomery's patch from 2016 in #238. Code has moved around a little since, but I think this is correct.
This commit is contained in:
committed by
Brennen Bearnes
parent
3ac8e1ae14
commit
8e4202847f
@@ -312,6 +312,8 @@ command! -buffer -nargs=? VimwikiNormalizeLink call vimwiki#base#normalize_link(
|
||||
|
||||
command! -buffer VimwikiTabnewLink call vimwiki#base#follow_link('tab', 0, 1)
|
||||
|
||||
command! -buffer VimwikiTabDropLink call vimwiki#base#follow_link('tabdrop', 0, 1)
|
||||
|
||||
command! -buffer -nargs=? VimwikiGenerateLinks call vimwiki#base#generate_links(1, <f-args>)
|
||||
|
||||
command! -buffer -nargs=0 VimwikiBacklinks call vimwiki#base#backlinks()
|
||||
@@ -418,6 +420,8 @@ vnoremap <silent><script><buffer> <Plug>VimwikiNormalizeLinkVisualCR
|
||||
\ :<C-U>VimwikiNormalizeLink 1<CR>
|
||||
nnoremap <silent><script><buffer> <Plug>VimwikiTabnewLink
|
||||
\ :VimwikiTabnewLink<CR>
|
||||
nnoremap <silent><script><buffer> <Plug>VimwikiTabDropLink
|
||||
\ :VimwikiTabDropLink<CR>
|
||||
nnoremap <silent><script><buffer> <Plug>VimwikiGoBackLink
|
||||
\ :VimwikiGoBackLink<CR>
|
||||
nnoremap <silent><script><buffer> <Plug>VimwikiNextLink
|
||||
@@ -448,8 +452,8 @@ if str2nr(vimwiki#vars#get_global('key_mappings').links)
|
||||
call vimwiki#u#map_key('n', '+', '<Plug>VimwikiNormalizeLink')
|
||||
call vimwiki#u#map_key('v', '+', '<Plug>VimwikiNormalizeLinkVisual')
|
||||
call vimwiki#u#map_key('v', '<CR>', '<Plug>VimwikiNormalizeLinkVisualCR')
|
||||
call vimwiki#u#map_key('n', '<D-CR>', '<Plug>VimwikiTabnewLink')
|
||||
call vimwiki#u#map_key('n', '<C-S-CR>', '<Plug>VimwikiTabnewLink', 1)
|
||||
call vimwiki#u#map_key('n', '<D-CR>', '<Plug>VimwikiTabDropLink')
|
||||
call vimwiki#u#map_key('n', '<C-S-CR>', '<Plug>VimwikiTabDropLink', 1)
|
||||
call vimwiki#u#map_key('n', '<BS>', '<Plug>VimwikiGoBackLink')
|
||||
call vimwiki#u#map_key('n', '<TAB>', '<Plug>VimwikiNextLink')
|
||||
call vimwiki#u#map_key('n', '<S-TAB>', '<Plug>VimwikiPrevLink')
|
||||
|
||||
Reference in New Issue
Block a user