francoiscabrol / ranger.vim

Ranger integration in vim and neovim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to open file in the same window in Vertical or Horizontal split ?

Migacz85 opened this issue · comments

Hi I just can't figure it out how I can open another file that will be open vertically or horizontally in new window ? I checked ranger tab methond and that is working fine. But still could not find the way how to open file in new window without closing original file where ranger method was triggered. Maybe this was just not coded ?
Thanks !

yes there is no command for doing that currently. The way to open a file in a splitted window is to first create the new splitted window and then run ranger inside.

Workaround :)

Fair enough.

I'm trying to get this to work too.

If I call :split then :Ranger, it opens in the full window rather than the split even if though split is focussed.

Edit: sorry, I misread the issue. I'm asking about opening the explorer itself. I can open a new issue if necessary.

A very simple one line map for what you want:

map <leader>r :vnew<CR>:RangerWorkingDirectory<CR>

To remap the existing command as recommended in the README.md:

let g:ranger_map_keys = 0
map <leader>f :vnew<CR>:RangerWorkingDirectory<CR>

Using :new instead of :vnew will let you open a horizontal split instead of a vertical one.

Incidentally @andyjessop consider switching to neovim since I don't have that issue in neovim. Make sure to install the additional dependency if you do.

Just in case anyone wants to open the current working directory rather than the working directory, we can modify the line map that @raghavmallampalli mentioned to open split from the current buffer:

map <leader>r :sp<cr>:RangerCurrentDirectory<cr> " for horizontal split

and :vs instead of :sp for vertical split.