In netrw version 134 I could use the following work pattern:
open dir x
select file a
:b# back to dir x
select file b
:b# back to dir x
select file c
... etc ...
But in netw version 149 this doesn't work.
The b# refuses to redisplay the directory buffer, which is unlisted.
How can I convince b# to display the unlisted directory buffer?
Thanks!
Steve
You got used to a what looks a lot like a bug (there are many in netrw) or at least an oversight.
The correct way to go back to the netrw window is:
:Rex
Try netrw v153q: http://www.drchip.org/astronaut/vim/index.html#NETRW
I was unable to duplicate this problem with the latest version of netrw.
Related
I like using the file browser in gvim sometimes, however what I don't like is that the file filter is always set to the current file type being edited.
For example, if I have a .cpp file open in the current buffer and go to the file open dialog the file filter is set to "C++ source files (*.cpp *.c++)". I would prefer that headers are displayed too by default (say).
Is there a way to change this default behavior?
Thanks to #benjifisher, I found the help for :browse which shows how to do what I wanted.
More specifically, the default filetype plugin for C/C++ contains these lines:
let b:browsefilter = "C++ Source Files (*.cpp *.c++)\t*.cpp;*.c++\n" .
\ "C Header Files (*.h)\t*.h\n" .
\ "C Source Files (*.c)\t*.c\n" .
\ "All Files (*.*)\t*.*\n"
I copied the file into my local vim ftplugin directory and modified to my liking which now takes precedence over the system version.
If anyone, like me, wants a quick and simple way to disable this behaviour altogether in vimrc:
autocmd FileType * let b:browsefilter = ''
From first reply in this thread
I had a similar issue that I solved without having to copy the c.vim file to ~/.vim/ftplugin. To support *.cc as a C++ extension, in GVim on Ubuntu I edited the /usr/share/vim/vim74/ftplugin/c.vim file to add the extension:
let b:browsefilter = "C++ Source Files (*.cpp *.c++ *cc)\t*.cpp;*.c++;*.cc\n" .
\ "C Header Files (*.h)\t*.h\n" .
\ "C Source Files (*.c)\t*.c\n" .
\ "All Files (*.*)\t*.*\n"
Then restarted GVim and it worked without copying c.vim.
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
I want to use GVim as a merge tool for TFS 2010.
I can't figure out the Arguments for GVim.
Specifically the argument %4, when I use it I get an empty buffer for it. if I don't use it I get an error message that I must use it.
This may not be exactly to your liking, but here's how I use GVim for a merge tool.
I set it up to do a two-way merge: it has the 'source' on the left (where I'm merging from), and the merge file on the right (starts off as what my destination branch has for information).
I set it up like this:
command: C:\Program Files (x86)\Vim\vim73\gvim.exe
argument: -c "vert diffsplit %1 " %4 -c "wincmd l|0read %2 |diff"
What this does is as follows:
Reads in the 'source' file on the left, and splits the window (-c "vert diffsplit %1")
Opens up on the right side the merge result (%4)
Runs a quick script which:
Moves over the right window (wincmd l)
Reads in my existing changes in the branch (0read %2)
Re-runs the diff algorithm (diff)
This lets me "diff" my work against the incoming merge, and saving the right hand side will resolve the merge.
Your screenshot suggests you are using Vim 7.3 . According to Vim site:
http://vim.wikia.com/wiki/Running_diff
At some point, the MyDiff function provided by the "Vim without Cream"
installer has been modified. As of Vim 7.3.138 it is still broken.
However, You can try the following verbose-mode parameters
command : gvim
argument: -V -od %1 %2
I try to generate Turkish spell file for Vim from a word list with the following command:
mksp /tmp tr_TR.words
tr_TR.words resides in C:\Program Files\Vim\vim72
Vim starts reading the word file but the process is interrupted before completion. Vim gives the following error message:
Compressed 5110514 of 6389213 nodes; 1278699 (20%) remaining
Writing spell file /tmp/tr.utf-8.spl ...
E484: Can't open file/tmp/tr.utf-8.spl
I use Gvim 7.2 on Win 7. The word list file tr_TR.words contains lines of words such as:
aba
abaca
abacası
abacı
I couldn't find the cause of this error on internet. Do you have any suggestions?
Well if you are on windows, you should know, there is no /tmp directory. So try:
mksp YOUR_INPUT_FILE_PATH\FILENAME C:\tmp\tr_TR.words
Try to replace /tmp in the command with C:\Program Files\Vim.
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.