wincent / command-t

⌨️ Fast file navigation for Neovim and Vim
BSD 2-Clause "Simplified" License
2.74k stars 317 forks source link

Add g:CommandTDontGoto option #379

Closed alfred-sa closed 3 years ago

alfred-sa commented 3 years ago

Hello,

In my workflow, I wanted to disable the "goto or open" behaviour of command-t, so I proprose a new configuration option "g:CommandTDontGoto", off by default of course.

Set to "on", the behaviour will be to always open, so one can have multiple windows with the same buffer (which I often happen to have as I use a lot of tabs and jumps).

wincent commented 3 years ago

I'd rather not have the clutter of another option. I think you can probably achieve what you want by putting this in ~/.vim/after/plugin/command-t.vim:

function! CustomGotoOrOpen(command_and_args) abort
  let l:command_and_args = split(a:command_and_args, '\v^\w+ \zs')
  let l:command = l:command_and_args[0]
  let l:file = l:command_and_args[1]

  execute l:command . l:file
endfunction

command! -nargs=+ CommandTOpen call CustomGotoOrOpen(<q-args>)

(ie. just overwrite the function) — In light testing, that works for me. If you wanted to have this toggle on or off at runtime, you could add an if in there.

What do you think?

alfred-sa commented 3 years ago

Well if it is not a common use case, feel free to ignore my rp. I will stick on my fork and rebase, I prefer to have this one line diff, it is easier to manage for me.

Thanks

wincent commented 3 years ago

Ok. And if demand for this shows up in the form of other requests we can resurrect it.