I have NERDTree configured to open on the right side with
let g:NERDTreeWinPos = "right"
This works when I open a new buffer. However, when I close a buffer on the left side with :bd, NERDTree takes the whole window and loses it's split. It looks like this.
Is there a way to keep NERDTree at the right side?
And secondly, can I force that new buffers are always opened at the left side with Ctrl-P? Sometimes it pretty annoying when the focus is inside NERDTree on the left side, I press Ctrl-P, and the file is displayed within the small buffer in which NERDTree was displayed.
As a Nerdtree user myself, I'd say, that this is normal behaviour. If you close the last open buffer, the remaining buffer (in this case Nerdtree) will take the full screen.
I imagine, this is annoying and the remedy is usually something like this:
map <F2> :NERDTreeToggle<CR> to toggle Nerdtree only when needed.
The other "trick" is to close it automatically, when opening a file via
let NERDTreeQuitOnOpen = 1.
Related
I start NERDTree every time I fire up vim and keep it that way. However, when I open a window for reference, and move it to the bottom, my NERDTree shrink and the window fills in, like this
How can I make the NERDTree stay on the left side and not shrink?
Control W + r will do that for you. There are more combinations that will help you with similar things in this similar thread: https://stackoverflow.com/a/4571319
Unfortunately this is not exactly what you want. First of all you should consider to open the second file by pressing i while you are in the NERDTree. Then you don't have to move your window to the bottom because it splits your window on the right. Secondly you may want to have a look at this vim plugin. Even this one won't solve your problem but ensures a more IDE like behavior with showing a NERDTree on all tabs on the left side.
My current use case is:
I have a buffer open with a NERDTree (Left) and 1 with a file being edited (Right)
Lets also assume 2 other files in background buffers are open as well.
If i press c (shortcut for closing buffer, basically :bd), the Right side is gone and only the left side is displayed. But when closing a buffer, i would expect that vim will close the current file buffer and keep the right side to open one of the buffers that are in the background.
How do I achieve the expected behavior?
You can use
nnoremap c :bp\|bd #<CR>
Which will first go to the previous buffer, then delete the last buffer. This way it will both close the buffer and go to the previous one.
May be bufkill can solve this issue for you.
I like to have two or three vertical windows with code and a NERDTree to the left, among other things. From any of these windows I'd like to instantly jump to the NERDTree window, and when I choose to edit a file, I'd like that file to show up in the window I was in.
Are these things possible with the current state of the NERDTree plugin? It seems to me that :NERDTreeToggle is supposed to do the first thing I ask for according to the help, but no matter how I open a file, it always shows up in the window right next to my NERDTree.
Try :NERDTreeFocus to jump to the NERDTree window from any open window. This was added relatively recently, it seems:
https://github.com/scrooloose/nerdtree/pull/132
When using NERDTree, I often have the situation where I close all existing buffers (except the NERDTree buffer), and then start opening fils from NERDTree again.
When doing this, NERDTree opens the files in a new split window, i.e. I have NERDTree at the left side, and on the right side two windows on top of each other, an emtpy buffer and the file I wanted to open.
What I want to happen is that NERDTree opens the file in the right window without splitting it.
Is there a way to tell NERDTree to never open a new window, if there is already one it could use? I tried using the "o" command, but that works exactly like the Enter command.
Have you checked all the mappings from the documentation
o.......Open files, directories and bookmarks....................|NERDTree-o|
go......Open selected file, but leave cursor in the NERDTree.....|NERDTree-go|
t.......Open selected node/bookmark in a new tab.................|NERDTree-t|
T.......Same as 't' but keep the focus on the current tab........|NERDTree-T|
i.......Open selected file in a split window.....................|NERDTree-i|
gi......Same as i, but leave the cursor on the NERDTree..........|NERDTree-gi|
s.......Open selected file in a new vsplit.......................|NERDTree-s|
gs......Same as s, but leave the cursor on the NERDTree..........|NERDTree-gs|
O.......Recursively open the selected directory..................|NERDTree-O|
x.......Close the current nodes parent...........................|NERDTree-x|
X.......Recursively close all children of the current node.......|NERDTree-X|
e.......Edit the current dif.....................................|NERDTree-e|
I finally got around to look at the nerdtree code, and I found the fix for my problem: I had to change the plugin.
I created a pull request for my changes on github:
https://github.com/scrooloose/nerdtree/pull/102
Update: Actually, the problem was a script I was using that set buftype=nofile for an empty buffer (it should set buftype=). After changing that, my problem went away.
I installed NerdTree plugin.
How can i open a file at right side as vsplit from a left side NerdTree panel ?
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.
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.
This is a bit of a hack, but how I do it is this:
Put cursor in window I want to open file into
Hit <leader>n<leader>n (this closes NERDtree and then opens it again with the cursor in NERDtree)
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 into.
Hit <leader>n<leader>n to close and reopen NERDTree
Select the file you want!
A quick C-w = will get your windows back to proper proportions.
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.