I'm new to Vim (almost new) and have some questions.
The problem came from the following:
I have NERDTree and MiniBufExplorer plugins (I like them very much!).
I have mapped Ctrl-F to show up MiniBufExplorer window.
So when I focus on tree window, then push Ctrl-F, find a file I want and then press Enter, the resulting file opens in tree window (which was previous one). So, I want to have a window with a specific Name/ID and tell MiniBufExplorer to always open buffers there. In most cases I don't use split windows so it would not be a problem for me to open buffers always in same window.
I have looked into manual of Vim but didn't found any reference to window's ID, so I wonder if there is a way to give an ID to window and then configure buffer explorer to always open buffers there.
Thanks for help in advance.
There is a switch to tell MiniBufExplorer to try to open files in a buffer that is modifiable (that is to say, not NERDTree):
let g:miniBufExplModSelTarget = 1
Prevent opening files inside NERDTree or MiniBuffExplorer
Related
My setup is Vim + Tmux. And I use NERDTree for simple navigation.
I'm often in a situation where I have two files open side by side, and I want to open a third file for reference in full size and being able to switch between the side by side view of the two first files and the full-size view of the third file.
So now, I would have to:
open a new Tmux window
open vim
find and open the third file
, then I can use tmux to switch between the side by side view and the full-size view.
I wonder if it's possible to open a file in NERDTree and show it in a new tmux window? Or how do you deal with this situation?
Maybe something like the plugin tmux-open but, don't know if it allows to open in new panel/window/session.
I think you're missing the concept of vim tabs.
You can open a file, then split using something like :vnew for example.
Then, you can use :tabnew filename.smt and that will be opened in a new full-size view (that you can either split again or keep as it is).
Then, with :tabp you can go to the previous tab and with :tabn to the next.
Obviously it's easier if you map some shortcuts, but you get the idea.
I have been using vim NerdTree for sometime now. One thought came to my mind and i am not sure if it is possible so seeking the help of experts.
Can Nerdtree show the list of open buffers say something like :NerdtreeBuffers
I know there is BufferExplorer but i dont like it for the simple fact that i have to pre-define if i want the buffer in a tab/split/vsplit
Nerdtree is awesome ... i just need one command and then from the list i can open it however i want.
No, NERDTree doesn't have any buffer list/exploration properties. I like Buffergator (GitHub) for quick buffer listing & selection. By default, it operates similarly to NERDTree, opening a left vertical split and allowing you to navigate to a buffer and hit enter to jump to it. It also supports opening buffers in vertical/horizontal splits, and other basic functionality. CtrlP is also handy. It does fuzzy find on files, but can also limit itself to open buffers.
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 usually:
Choose the needed file.
Open it in a tab(t character, by default).
But how I can jump back to NERDTree to open one more file in a tab?
Temporary solution I use now in my .vimrc file:
map <F10> :NERDTree /path/to/root/of/my/project
But it's not very useful to start navigation again and again from the root directory.
Ctrl-ww
This will move between open windows (so you could hop between the NERDTree window, the file you are editing and the help window, for example... just hold down Ctrl and press w twice).
Ctrl+ww cycle though all windows
Ctrl+wh takes you left a window
Ctrl+wj takes you down a window
Ctrl+wk takes you up a window
Ctrl+wl takes you right a window
NERDTree opens up in another window. That split view you're seeing? They're called windows in vim parlance. All the window commands start with CTRL-W. To move from adjacent windows that are left and right of one another, you can change focus to the window to the left of your current window with CTRL-w h, and move focus to the right with CTRL-w l. Likewise, CTRL-w j and CTRL-w k will move you between horizontally split windows (i.e., one window is above the other). There's a lot more you can do with windows as described here.
You can also use the :NERDTreeToggle command to make your tree open and close. I usually bind that do t.
If you use T instead of t there is no need to jump back because the new tab will be opened, but vim's focus will simply remain within NERDTree.
You can focus on a split window using # ctrl-ww.
for example, pressing:
1 ctrl-ww
would focus on the first window, usually being NERDTree.
Since it's not mentioned and it's really helpful:
ctrl-wp
which I memorize as go to the previously selected window.
It works as a there and back command. After having opened a new file from the tree in a new window press ctrl-wp to switch back to the NERDTree and use it again to return to your previous window.
PS: it is worth to mention that ctrl-wp is actually documented as go to the preview window (see: :help preview-window and :help ctrl-w).
It is also the only keystroke which works to switch inside and explore the COC preview documentation window.
ctrl-ww Could be useful when you have limited tabs open. But could get annoying when you have too many tabs open.
I type in :NERDTree again to get the focus back on NERDTree tab instantly wherever my cursor's focus is. Hope that helps
The top answers here mention using T to open a file in a new tab silently, or Ctrl+WW to hop back to nerd-tree window after file is opened normally.
IF WORKING WITH BUFFERS: use go to open a file in a new buffer, silently, meaning your focus will remain on nerd-tree.
Use this to open multiple files fast :)
You can change the tabs by ctrl-pgup and ctrl-pgdown. On that tab you came from the NERDTree is still selected and you can open another tab.
In more recent versions of NERDTree you can use the command :NERDTreeFocus, which will move focus to the NERDTree window.
gt = next Tap
gT = previous Tab
if you want you can enable the mouse support editing ~/.vimrc file.
put set mouse=a
after that you enable files click in NERDTree.
All The Shortcuts And Functionality is At
press CTRL-?