ranger.vim icon indicating copy to clipboard operation
ranger.vim copied to clipboard

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

Open Migacz85 opened this issue 5 years ago • 6 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 !

Migacz85 avatar Feb 22 '19 11:02 Migacz85

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.

francoiscabrol avatar Mar 01 '19 19:03 francoiscabrol

Workaround :)

Migacz85 avatar Mar 01 '19 20:03 Migacz85

Fair enough.

xuta avatar Mar 04 '20 15:03 xuta

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.

andyjessop avatar Sep 23 '20 09:09 andyjessop

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.

raghavmallampalli avatar Oct 06 '20 19:10 raghavmallampalli

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.

ahmedfawzy98 avatar Jan 08 '21 23:01 ahmedfawzy98