Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

in VIM, How to set the initial window size via file browser?

Tags:

vim

I'm using vim to browse through different folders. (i.e., issue :tabe . command in vim)

However, when I open the file either in split window (pressing 'o') or in vertical split window(pressing 'v'), the newly opened window size is really small. (while meanwhile, vim's file browser's windows stays pretty big which I don't really need).

I know that I can manually change the window size by Ctrl+W with either -/+ or split, or for vertical split, or '=' to make the window sizes equal; but that's too troublesome.

I want to check if there're existing ways to set the default size of the window opened using "o" or "v" to be bigger?

Thanks a lot ;)

like image 605
songyy Avatar asked May 20 '13 07:05

songyy


3 Answers

The new window should take half of the height or half of the width of the current window which can give you small windows pretty quickly.

The option that defines that proportion can be found in :help netrw:

let g:netrw_winsize = 75

Note that using this method will make any further split even smaller than before:

let g:netrw_winsize = 50 (default)
|-netrw--------------------------------------------|
|-netrw------------------|-file--------------------|
|-netrw------|-file------|-file--------------------|

let g:netrw_winsize = 75
|-netrw--------------------------------------------|
|-netrw------|-file--------------------------------|
|-netrw|-file|-file--------------------------------|

The "problem", here is that netrw splits its own window, not the previous window.

Netrw can be used to open the file under the cursor in the current window, in a split window or in another tab but the way it splits its own window makes it hard to use it the way you want. AFAIK, the most common usage is:

  1. open netrw with :Ex,
  2. navigate,
  3. hit <CR> to open the file under the cursor in the current window,
  4. edit,
  5. re-open netrw in its latest state with :Rex (for Peter Rincker),
  6. GOTO 2

An alternative is to use :Vex to open netrw in a vertical split and use P to open the file in the previous window.

I'm afraid Netrw is not really designed to work like what you seem to want it to work. IMO, netrw is more like an "open…" dialog than the kind of file explorer pane you can see in most editors/IDEs. I'd suggest you either get used to it or try NERDTree which has only a subset of netrw's features but is designed to be more like those file explorer panes.

like image 184
romainl Avatar answered Oct 08 '22 07:10

romainl


Actually the split size is not relative to netrw, it's the default size vim sets for newly created splits, so if you want to resize the actual split which is in you case the navigator (netrw) you can use this commend:

:vertical resize 30
like image 5
ZEE Avatar answered Oct 08 '22 06:10

ZEE


There is :Lex now to open a left explorer. You can place let g:netrw_winsize=30 in your vimrc file to keep the explorer small.

like image 3
isar Avatar answered Oct 08 '22 05:10

isar