wincent / command-t

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

No longer possible to open the same file in multiple splits #310

Closed dcollinsn closed 6 years ago

dcollinsn commented 6 years ago

vim a.txt :vsp <leader>t b.txt <enter> <leader>t a.txt <enter>

Expected:

'a.txt' will be open in both splits

Actual:

'a.txt' will be open in the left split, 'b.txt' will be open in the right split, and the left split will have "focus"

This used to work as I expected, I think it changed around the same time as you fixed #295? I'd like to be able to open the same file in multiple splits so that I can view one part of a file while editing a different part.

Is there a configuration option to restore the old behaviour?

wincent commented 6 years ago

Look at the settings listed under :CommandTOpen:

https://github.com/wincent/command-t/blob/c5882de56f0ca3ce8e891c434f192519aca5c7bb/doc/command-t.txt#L616-L626

If you override g:CommandTAcceptSelectionSplitCommand and friends, you can implement arbitrary logic. The simplest version would be to set it to sp instead of CommandTOpen sp (the latter goes to great lengths to re-open things in their existing splits if the item in question is already open, which in your case is not what you want).

tap349 commented 6 years ago

@dcollinsn I have this setup in my vimrc:

let g:CommandTAcceptSelectionCommand = 'e'
let g:CommandTAcceptSelectionSplitCommand = 'sp'
let g:CommandTAcceptSelectionTabCommand = 'CommandTOpen tabe'
let g:CommandTAcceptSelectionVSplitCommand = 'vs'

here CommandTOpen command is used only when opening file in a new tab since usually I don't need to "intelligently find" file in current tab - I see all the files in current tab and if I open file, say, via <Enter> I usually mean to open that file in currently focused window without trying to find it in other windows (just like in your case). Same for opening file in either horizontal or vertical split.

wincent commented 6 years ago

Closing as I believe this is covered by the settings.