Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VIM: How can i open a file at right side as vsplit from a left side NerdTree panel?

I installed NerdTree plugin.

How can i open a file at right side as vsplit from a left side NerdTree panel ?

like image 960
shibly Avatar asked Oct 27 '11 05:10

shibly


3 Answers

To make vsplit put the new buffer on the right of the current buffer:

set splitright

Similarly, to make split put the new buffer below the current buffer:

set splitbelow

I haven't tried this with NerdTree, however.

like image 97
Prince Goulash Avatar answered Nov 09 '22 14:11

Prince Goulash


There's a s command, but it opens a file split to the left of current buffer. Though you can press Ctrl+W r to swap windows then.

like image 94
grimgav Avatar answered Nov 09 '22 14:11

grimgav


This is a bit of a hack, but how I do it is this:

  1. Put cursor in window I want to open file into
  2. Hit <leader>n<leader>n (this closes NERDtree and then opens it again with the cursor in NERDtree)
  3. Select the file

On my system this opens it on the last window I was just on if the file isn't already open on my screen. Start in the window you want to open your file in

Start in the window you want to open your file into.

After <code><leader>n<leader>n</code> you will be back in NERDTree

Hit <leader>n<leader>n to close and reopen NERDTree

Select the file you want to open!

Select the file you want!

A quick C-w = will get your windows back to proper proportions.

like image 4
Ben Kushigian Avatar answered Nov 09 '22 13:11

Ben Kushigian