I have been using NERDTree for a while. Every time I need to create a new directory I need to go to terminal. Is there a quick and easy way to create a directory using NERDTree.
I read the doc but could not find anything.
When in the NERDTree window, press 'm'; you should see a menu at the bottom. Type in 'a' for add childnode. Now input the directory you want to create, making sure to add a '/' at the end, otherwise the script would create a file.
AFAIK NERDTree cannot create parent directories like 'mkdir -p' does.
Pressing m would open a menu below and you can select from a list of actions.
NERDTree Menu. Use j/k/enter and the shortcuts indicated
==========================================================
> (a)dd a childnode
(m)ove the current node
(d)elete the current node
(r)eveal in Finder the current node
(o)pen the current node with system editor
(q)uicklook the current node
(c)opy the current node
Add a childnode
==========================================================
Enter the dir/file name to be created. Dirs end with a '/'
/Library/WebServer/Documents/new-teacher-center/app/Model/
Pressing a would let you add a childnode. A childnode can be a file or folder depending if you add a forward slash ( / ) or not.
If you don’t add a forward slash like below, it would create a file.
Add a childnode
==========================================================
Enter the dir/file name to be created. Dirs end with a '/'
/Library/WebServer/Documents/new-project/app/Model/file
If you add a forward slash like below, it would create a folder.
Add a childnode
==========================================================
Enter the dir/file name to be created. Dirs end with a '/'
/Library/WebServer/Documents/new-project/app/Model/folder/
Related
I'm using fzf for a few weeks now and it really changed my workflow. I'm working on a big project with multiple things interconnected.
I'd like to use :Tags command to have an overview of all existing tags in the whole project (not to have multiple tags files) in the folder /home/ctags/ (ctags bin being here).
My command in the vimrc is
let g:fzf_tags_command='/home/ctags/bin/ctags -R --extra=+qf --excmd=pattern --exclude=Makefile -f /home/ctags/tags /home/work/project/'
Because of something I don't understand, while I use :Tags, tags file is generated where I want to, but the error "Failed to create tags" occurs..
The question becomes more simple : how to force fzf to use a specific tag file ?
Bonus
I added
set tags=./tags;
set tags+=/usr/include
To also include import tags, but it doesn't seem to work. Any idea ?
EDIT
Found the solution !
This has to be added on top of .vimrc file
set autochdir
set tags=/home/work/tags,tags;
And the command for :Tags is
let g:fzf_tags_command='/home/ctags/bin/ctags -R -f /home/work/tags --extra=+qf --excmd=pattern --exclude=Makefile /home/work/project/'
This way, only one tag file will be generated and it will be updated each time you invoke fzf.
My current project file structure looks like this:
When I trigger CtrlP and start typing the file name "index.js" it will find too many results. And when I prefix the letters with the foldername then there are none.
How can I configure Vim CtrlP to search for directory name instead of file name and deliver as a result the index.js inside the directory (that's the default behavior in Atom's fuzzy finder)?
Apparently it's an issue of my vim ctrl-p configuration:
ctrl-p doesn't match foldernames
Ah, as Andy and hobbs noted, ctrl-p should match against foldernames.
In my config it was overwritten with:
" Default to filename searches - so that appctrl will find application
" controller
let g:ctrlp_by_filename = 1
By replacing 1 with 0, the default behavior of ctrl-p could be restored and it matches foldernames.
The title sums it up, really. I'd like to know how to set the current root of the tree when browsing files using netrw in vim.
Any ideas?
You can also use "gn" mapping to change the current directory to the folder under your cursor.
CHANGING TREE TOP netrw-ntree :Ntree netrw-gn
{{{2
One may specify a new tree top for tree listings using
:Ntree [dirname]
Without a "dirname", the current line is used (and any leading depth
information is elided). With a "dirname", the specified directory name
is used.
The "gn" map will take the word below the cursor and use that for
changing the top of the tree listing.
Per the documentation for netrw, use the ex command
:Ntree [dirname]
Assuming you have netrw installed, one can obtain more information on this using help
:help Ntree
Often times, I will just change the current work directory using the ex command
:cd [dirname]
Next, I start the explorer (ex command again)
:Exp
***Addendum***********
To update your version of netrw, I would just follow the directions that the author, Charles Campbell, posted on www.vim.org.
quite old thread, but maybe someone find this information useful that currently you can use c to change to current dir.
If you want to always change pwd while browsing around with netrw you could use:
let g:netrw_keepdir = 0
What do you mean by "the current root of the tree"?
Do you want a faster or more deterministic way to browse directories in netrw than the usual --/foo<CR><CR>/bar<CR><CR>/baz<CR><CR>?
Or do you want to be able to open netrw in a specific directory?
Or something else?
netrw v151 supports changing the treetop (root of tree):
:Ntree [directory]
and one may use the "-" key to have the treetop become the parent of the current tree. See http://www.drchip.org/astronaut/vim/index.html#NETRW for the latest netrw.
As of the doc of netrw, just type cd to make the browsing directoyr the current directory:
*netrw-c* : This map's name has been changed from "c" to cd (see |netrw-cd|).
This change was done to allow for |netrw-cb| and |netrw-cB| maps.
Note: the doc seems inconsistent, because the quick reference has a line with
c Make browsing directory the current directory |netrw-c|
... but cd works as explained above.
You can also press "C" while the cursor is on the directory you'd like to make the current home.
From NerdTree help
" Filesystem mappings~ |~
" C: change tree root to the |~
" selected dir |~
" u: move tree root up a dir |~
" U: move tree root up a dir |~
" but leave old root open |~
" r: refresh cursor dir |~
" R: refresh current root |~
" m: Show menu |~
" cd:change the CWD to the |~
" selected dir |~
" CD:change tree root to CWD
Is it possible to change the way Vim names its swap/backup/undo files?
To avoid clutter, I've set options in my ~/.vimrc to dump these files in ~/.vim/tmp/{swap,backup,undo}; however, as I routinely edit files in different directories with the same name, I often end up with lots of otherwise indistinguishable files and Vim sometimes has trouble recovering.
Ideally, I'd like to use the naming scheme that the persistent undo has (%path%to%file.undo) for all these auxiliary files; there's no obvious way to set it, but can it be done with Buf{Read,Write} macros?
I have this in my .vimrc and it names the swap files with full path names and percent signs just as you describe:
" Store swap files in fixed location, not current directory.
set dir=~/.vimswap//,/var/tmp//,/tmp//,.
The key is the // at the end of the directories. See this note from :help dir:
For Unix and Win32, if a directory ends in two path separators "//"
or "\\", the swap file name will be built from the complete path to
the file with all path separators substituted to percent '%' signs.
This will ensure file name uniqueness in the preserve directory.
Here's part of my .vimrc from github.
This sets the undodir (and turns it on), sets the backupdir, and directory (used for .swp files). Note that it creates the directories if they don't already exist.
" Save your backup files to a less annoying place than the current directory.
" If you have .vim-backup in the current directory, it'll use that.
" Otherwise it saves it to ~/.vim/backup or .
if isdirectory($HOME . '/.vim/backup') == 0
:silent !mkdir -p ~/.vim/backup >/dev/null 2>&1
endif
set backupdir-=.
set backupdir+=.
set backupdir-=~/
set backupdir^=~/.vim/backup/
set backupdir^=./.vim-backup/
set backup
" Save your swap files to a less annoying place than the current directory.
" If you have .vim-swap in the current directory, it'll use that.
" Otherwise it saves it to ~/.vim/swap, ~/tmp or .
if isdirectory($HOME . '/.vim/swap') == 0
:silent !mkdir -p ~/.vim/swap >/dev/null 2>&1
endif
set directory=./.vim-swap//
set directory+=~/.vim/swap//
set directory+=~/tmp//
set directory+=.
" viminfo stores the the state of your previous editing session
set viminfo+=n~/.vim/viminfo
if exists("+undofile")
" undofile - This allows you to use undos after exiting and restarting
" This, like swap and backup files, uses .vim-undo first, then ~/.vim/undo
" :help undo-persistence
" This is only present in 7.3+
if isdirectory($HOME . '/.vim/undo') == 0
:silent !mkdir -p ~/.vim/undo > /dev/null 2>&1
endif
set undodir=./.vim-undo//
set undodir+=~/.vim/undo//
set undofile
endif
Hopefully, it's commented well enough to understand what's going on. If not, add a comment and I'll fix it.
Ciao!
Update [07/16/2012]
I got an email from Rob Kine asking these questions about the backupdir section that I wanted to answer for everyone:
It looks like you are removing the current directory, and then re-adding it. what does that do?
What does the ^= operator do?
How does the order of precedence in the use of folders checked work in Vim? (Like is the last folder added the first one it checks for?)
The first thing is to describe the different operators. These operators have different meanings for non-string-list options, so be warned!
-= removes the value from a string list;
+= appends the value to a string list;
^= prepends the value to a string list.
So the backupdir has the following operations applied:
Remove the current directory from the list.
Append the current directory to the list (this ensures it is the last thing checked).
Remove the home directory from the list (I don't like stuff being saved there).
Prepend ~/.vim/backup/.
Prepend ~/.vim-backup/.
When Vim looks for where to save the backups, it checks from first to last; so it'll check for ~/.vim-backup/, then check for ~/.vim/backup, then check the default list (except for . and ~/ which were removed), and finally check .
You can get help for all these in Vim by using (for example) :help ^= or :help backupdir.
Create the directory undo
$ mkdir ~/.vimundo
Set up your .vimrc file
set undodir=~/.vimundo
I am using Vim and I have set the path (set path+= c:/work/etc/etc) to my project directory (for C#), but still using command 'gf' give me error:
E:447 Can't find file.
Is there anything I am doing wrong over here?
G'day,
To get a bit more detail on your current path settings you can see what's being included and the files vim can't find by entering the command:
:checkpath
and you'll get a dump of the files not found, e.g.
--- Included files not found in path ---
<io.h>
vim.h -->
<functions.h>
<clib/exec_protos.h>
Or you can get a listing of all included files, both found and not found, by entering
:checkpath!
Enter
:help path
to get more info on the path syntax.
Edit: Don't forget that using the syntax
set path=/work
will completely reset your path variable to what you've just declared. I'd suggest using
set path+=/work
instead. This won't clobber the current path and will just add your /work directory instead.
HTH
I also found out that
:set path+=./foo/bar
adds a search location relative to the directory of the current file, just like '.' does.
My vim didn't want to search for such include
#include <common/util/string.h>
So what I needed to do was
:set path+=foo/bar
instead of
:set path+=./foo/bar
The former adds a search path relative to current working directory. Hopefully it helps someone.
First can you open the file using :find file.name ? (:help find for more info). If this does not work then your path is wrong. If :find does locate your file then do the following:
Insure that you are not in Visual/Insert mode
Place cursor on the first letter of the filename and press gf
I know this is an old question, but I also had some troubles with this for another reason and it took me some time to find out why. I hope this might be helpful to someone.
When a directory is matched with wildignore, gf does not work for files in it, nor does :find.
This is obvious if you read wildignore's documentation, but I forgot I ever changed this variable, and what it was for exactly. Also I used a glob, and it was not immediately apparent to me that the directory I was using gf in, was also matched with this glob.
Make sure there is no leading character to the file name if you press gf, i.e. using gf when the cursor is on help.txt will not work here:
file=help.txt
If you are talking about the gf tool wri††en by tomnomnom then here's how to set-up:
Setting PATH for GO (if you have not setup yet).
export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/bin
Step 1: Download tool from github
Step 2: cp -r path/to/tomnomnom/gf/examples ~/.gf
Step 3: source ~/tools/gf/gf-completion.bash
Now gf should work along with auto-completion from anywhere.
Source: Original sources are present at his repo.