francoiscabrol / ranger.vim

Ranger integration in vim and neovim
664 stars 58 forks source link

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

Open Migacz85 opened 5 years ago

Migacz85 commented 5 years ago

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 !

francoiscabrol commented 5 years ago

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.

Migacz85 commented 5 years ago

Workaround :)

xuta commented 4 years ago

Fair enough.

andyjessop commented 4 years ago

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.

raghavmallampalli commented 4 years ago

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.

ahmedfawzy98 commented 3 years ago

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.