Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My overall goal here is simple, but the specifics are complex:

I want to maintain each vertical split in my MacVim window at exactly 115 columns, regardless of how many splits I add.

The story: I’m using the Janus distribution of MacVim (and am fairly new to the whole vim thing); it ships with NERDTree. I usually use NERDTree or the command-line to open a few related files in vertical splits. Currently, this results in me having to manually resize the MacVim window with the mouse, and then ⌃w= (or the equivalent wincmd =) to split the newly available space amongst my vertical splits. This annoys me.

The eventual goal is, upon the addition or removal of a vertical split (but not any new ‘vim viewport’, as I ocassionally utilize a horizontal split in a particular vertical split), as well as upon the opening of a new MacVim window/instance/whatever, to adjust the width of the entire MacVim window to ensure each existing vertical split (including the new one) has exactly N columns for its textual content. (I, personally, write code at N := 115, many people use N := 80.)

I realize it’s a complex and possibly impossible request, so anything approaching this solution would be appreciated. (=

share|improve this question
    
(And yes, I just put a bounty on this question that amounted to all of my reputation save 18 on this. It’s that important to me.) –  ELLIOTTCABLE Jun 7 '11 at 7:25

3 Answers 3

You can achieve what you want by using :vertical resize N where N is the width of the window you want, which is 115. So you can do the following:

command -complete=command -nargs=+ Vertical vertical <args> | vertical resize 115

This creates the user command :Vertical that acts just like the normal :vertical (it even has completion!) but will always resize the newly created vertical split to 115. Note: If you call :Vertical resize 25 it will not work as you expect. I leave that to the reader. :-)

share|improve this answer
    
It’s a start, but I specifically pointed out that it needs to operate in all of the situations where I get a new split; I never actually use :vsp or anything like that; about 50% of the time, I’m opening from the command-line via mvim a.c b.c, 45% of the time I’m using s in NERDTree, and 5% of the time it’s other methodologies. –  ELLIOTTCABLE Jun 7 '11 at 22:31
    
How about simply au WinEnter * vertical resize 115? It'll apply in all cases, which may be closer to what you want. –  evaryont Jun 8 '11 at 6:46
    
I think that’s pretty much exactly what I wanted. I don’t have time to test it, so I’m going to award the bounty before it expires, though. –  ELLIOTTCABLE Jun 13 '11 at 12:25
    
Okay, this is nothing like what I want, but it is ridiculously cool anyway. It results in “collapsing” splits that you can see a little bit of at a time, like this: ell.io/vyKc ⌃W lell.io/9otd –  ELLIOTTCABLE Jul 11 '11 at 1:29
    
Yeah, that's because you have a window that is <230 characters wide (two 115 wide windows) so vim tries to fit however much it can from the other windows while still trying to fulfil your request to have it 115 wide. Regardless, it's pretty damn cool. –  evaryont Jul 11 '11 at 5:21

You could try setting lines and columns in ~/.gvimrc so that it suits your needs. For example:

set lines= 50 columns= 115

to make a new window default to that.

share|improve this answer
  1. You can use Shift+A to zoom (maximize – minimize) the NERDtree window

  2. Let g:NERDTreeWinSize = 40 in your ~/.vimrc.

See this topic: NERDTree plugin side bar width

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.