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

VimPluginsEditorNerdtree

Vim Problem Overview


I installed NerdTree plugin.

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

Vim Solutions


Solution 1 - Vim

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.

Solution 2 - Vim

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.

Solution 3 - Vim

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 <leader>n<leader>n 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.

Solution 4 - Vim

Not sure if anyone else is still struggling with this, but here's how I dealt with it.

You can use

:ls 

to list the available buffers. Which would look something like:

1 "foo.txt"
2 "blame_the_user.java"

:b1 to select foo.txt

:b2 for blame_the_user.java

This method can be done from any window setup using :sp or :vs.

Open the buffers you want to split first.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionshiblyView Question on Stackoverflow
Solution 1 - VimPrince GoulashView Answer on Stackoverflow
Solution 2 - VimgrimgavView Answer on Stackoverflow
Solution 3 - VimBen KushigianView Answer on Stackoverflow
Solution 4 - VimCloudEmberView Answer on Stackoverflow