How do you delete a file using NERDTree: vim plugin page?
I have put this into my .vimrc file:
set modifiable
but I don't know the command to delete!
This
How to create folders in Vim (by preference using NERDTree)?
should give an answer. Just type m in NERDTree window and a dialogue appears in a QuickFix window
In addition there has been made a plugin on top of nerdtree https://github.com/ivalkeen/nerdtree-execute which allows to execute files with m+x -> I use it to open pdfs I get from compiling LaTeX
Related
I'm starting to use vim's native explorer (:E). My doubt: when I press c to "make browsing directory the current directory" nothing happens.. When I used nerdTree and did the same operation (:NERDTreeCWD), that directory was placed at the top of the exporer and the directories upper were "hidden".
It just seems pressing c is not doing anything..
NOTE: Im using the tree view on explorer, instead of the default one. I pressed i to change the view.
Im using 7.4.52
The netrw command works different than NERDTree's. It doesn't apply to the directory under the cursor, but to the one currently being browsed. So if you want to make a subdir the current one, first go into it (via <Enter>), then press c.
To expand on Ingo's answer. If you always want netrw to make the current browsing directory the current vim directory, you can set the option let g:netrw_keepdir=0 in your .vimrc.
This allows you to use netrw to browse directories and use vim to operate in that directory. For example, you can use vim's command :e <filename> to create a new file instead of netrw's command % <filename>.
To learn more about netrw I recommend reading the help pages :help netrw-quickhelp
I have installed NERDTree plugin in my vim.
What I noticed is that when I create files via command prompt .. the newly created file does not get reflected in the NERDTree display.
Is there a add-on I am missing here ?
I would highly recommend to use NERDTree itself for file system manipulations, things like creating directories / files is done very easily from within NERDTree. Use the m within nerdtree to open the text based 'menu' for various operations you can perform on the file system.
Even if you need to create files outside of vim, or maybe the files are generated etc, just hit r mapping within NERDTree to refresh the nerdtree and it'll show your created files / directories correctly.
For quick help, hit ? within NERDTree buffer to have a look at it's API.
If you look into ? of the NerdTree (eg. go to the nerdtree window and type ?), you will the shortcut r to refresh the tree directory.
Nerdtree does not refresh the directory automatically but you can manually trigger it by pressing r on the directory.
Sometimes the refresh doesn't refresh properly.
Opening and closing the nerdtree directory will solve this issue.
I set VIM to open NERDTree whenever VIM is started by doing this: autocmd VimEnter * NERDTree
What changes should I make to my vimrc file so that the Bookmarks also open up whenever VIM & NerdTree are started?
let NERDTreeShowBookmarks=1 will display the bookmarks table on startup. If you wanted to actually open the files for editing, I'm not sure how to do that.
NERDTree provides a very nice documentation file. If you extracted the zip file in ~/.vim, it is located at ~/.vim/doc/NERD_tree.txt. If you want to use with vim's built in help, run :helptags ~/.vim/doc/ and then you'll be able to access it with :help NERDTree.
Of course, if you extracted the zip someplace else, replace ~/.vim with the folder you extracted it into.
From the help file of Nerdtree :
2.2.1. The Bookmark Table NERDTreeBookmarkTable
If the bookmark table is active (see |NERDTree-B| and |'NERDTreeShowBookmarks'|), it will be rendered above the tree. You can double click bookmarks or use the |NERDTree-o| mapping to activate them. See also, |NERDTree-t| and |NERDTree-T|
So I guess that
let NERDTreeShowBookmarks=1 in your .vimrc should work.
I know this question was asked a while ago but since it is at the top of the google results I thought I would give the proper answer.
In your .vimrc file NERDTreeFromBookmark will not op a bookmark name BUT it will open a hard path.
For example:
au VimEnter * NERDTreeFromBookmark /path/to/your/bookmark/folder/
This will open NERDTree at that location on VIM startup.
Hope that helps some people.
EDIT:
im guessing you could also do:
au VimEnter * NERDTree /path/to/a/folder/
Sorry to ask such a novice question but I am looking for a way to handle multiple files. I dont want to type huge file paths to open every file using :tabnew and :e commands
Fuzzy Finder is a handy plugin to quickly find and open files.
Basically you have to only type a few letters like test and you'll get a pop-up menu to open in your current path :
footest.c
bartest.h
footest.h
...
It is a bit slow when used on NFS but it is useful if you don't want to type long path and file names.
Alternatively if you don't want to use any plugin, by default gvim/vim includes a file browser called netrw.
To start it, just type :e . you'll get the content of your current directory, you can then navigate through the directory structure quite easily. (There is even commands to delete, rename, etc like a standard file explorer)
:help netrwfor more information.
A couple of tips that you might be interested in:
You can configure Vim so that the
current directory "follows" the
directory of the file you are
currently editing. That way you can
edit another file from the same
directory without having to type the
full path. This can be achieved by
putting either set autochdir or
autocmd BufEnter * lcd %:p:h in
your .vimrc
You can use wildcards with tab
completion. e.g. to edit
a_file_with_a_long_name.txt you could
do :e a*long and then press
Tab followed by
Return.
Usually, vim supports buffers for that. Use :badd to add buffer, :bdelete to remove it and :ls (or :buffers) to list all opened buffers. I believe, GVim supports these features too.
For example, if you wanna edit all .rb files in your app/controllers/pages dir (in the case of Rails project), you type vim app/controllers/pages/*.rb in your terminal and then edit the first file (buffer) in the vim window. When you've done with all changes, save changes as usual with :w (note: do not use q! option - this will close all your buffers you've opened) and then use :bn<tab> (or fully, :bnext) or :bprevious to switch to the next file (buffer). When you run :bnext on the last buffer, you'll be dropped to the first one.
You can open a directory in Vim, search for the file o directory you are looking for with '/' and type [enter] to open it.
I installed Nerd_tree plugin for vim on ubuntu 10.04. It is great plugin. But I met the following problems:
after open nerd_tree to browse the files in /etc/apache2/sites-available/, now I close it, and go on with my work. Later I want open nerd_tree again to edit another file in /etc/apache, but nerd_tree shows me always the user home directory /home/toledot, So I have to up dir->up-dir->up-dir again. Is there a way let nerd_tree to remember the path, which I have used at the last minute?
I opened nerd_tree and select one file to edit. After my update on this file, and want to select another file to make some change. But I can not go back to the nerd_tree. I tried to make double click and tab and so on. It doesn't work. What is the hotkey to switch nerd_tree and the opened files in vim?
I am absolute new with vim and plugins, so please help me and explain the solution in details. I am very thankful for any suggestion or infos.
A couple of points that may be helpful.
If you set autochdir the current working directory will be automatically be set to that of the current file. You can do this either interactively or in your .vimrc file.
The official way to open the NERDTree window seems to be with the command :NERDTree. You can map this to any convenient key sequence.
You should be able to view the helpfile with the command :help NERDTree. If you have trouble getting the help, change to the directory containing file NERD_tree.txt (in vim) and execute :helptags .
You can also add bookmarks for file/directories that you often use. See
:help NERDTreeBookmarkCommands.
What you need is a handy map to :NERDTreeToggle. Put this in your .vimrc
nmap <silent> <F4> :NERDTreeToggle<CR>
And just hit <F4> to open/close NERDTree, just like that, just as you last toggle-closed it.
You can also open a specific directory using :NERDTree /my/dir
I advise you to set autochdir so that whenever you open a file, working directory (you can find out this with :pwd) will be changed accordingly