Question

I'd like to remap Ctrl+] to attempt it's default behavior (ie., jump to a tag if possible), but if that fails to try opening a link using the Utl plugin. My fingers are too hard-wired into trying Ctrl+] to jump that creating a different mapping isn't working out very well. I'm no good at VimL, but this is what I'd like to achieve in pseudo-code:

function TryJump()
  try
    normal ctrl-]
  catch
    normal Utl
  endtry
endfunction
noremap <c-]> :call TryJump()<cr>

Any ideas?

Was it helpful?

Solution

I haven't used utl, but assuming you just want it to do :Utl, this should work:

function! TryJump()
  try
    execute "normal! \<c-]>"
  catch
    Utl
  endtry
endfunction
nnoremap <c-]> :call TryJump()<cr>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top