How can I create a mapping that opens the selected file in a vertical/horizontal split?

  1. anonymous

    I am switching to Command-T for file searching. I am trying to setup shortcuts such that I can type leader vv to launch command-T starting in app/views, find the desired file, and open it in a vertical split.

    I found the following which works to narrow the command-t search to app/views:

    map <leader>gv :CommandTFlush<cr>\|:CommandT app/views<cr>

    How can I change that so that it opens in a vertical/horizontal split when I hit enter on the file?

  2. Greg Hurrell

    You can't really do both of those in a single mapping.

    All you can really do is open Command-T in app/views, and then open in a vertical split using <CTRL-v> or some other mapping of your choosing. (The idea is, first find the file, then decide where you want to open it.) You could of course patch Command-T to provide this feature, but I don't really want to increase the already large number of customizable mappings.

    By the way, I think you shouldn't need the :CommandTFlush in that mapping above, as changing directories like that starts with an empty cache.

    (The version currently on the master branch optionally caches multiple directories, so you wouldn't have an implicit flush in that case, but rather separate caches for ., app/views, and any other directory you invoke Command-T in.)

Reply

This topic is now closed.