Here are the relevant parts of my setup:
enable the wildmenu,
make filename-completion skip these files and directories,
The following enables fuzzy file search (i.e :find script.js) through every file in your project root while excluding the node_modules dir and its contents.
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 11 2017 13:57:34)
"Current directory" and "directory of the current file" are two different things.
The "current directory" is by default the directory in which you started Vim. You ask Vim what it is with :pwd and change it with :cd or :lcd or by setting the autochdir option. If you never change it, it will stay the same until you close the current session.
The "directory ...
let &path += fnamemodify(tagfiles(), ':p:h')
should add the path of your tags file's parent directory to the path option.
Updating path each time you enter a buffer is probably a good idea:
autocmd BufNewFile,BufRead,BufEnter * set path&vim | let &path += fnamemodify(tagfiles(), ':p:h')
does the same thing as :e %:h, and is shorter to type.
If you look up :help :Explore, you can see that there are also variations to open the directory of the current file in a new tab or split instead of in the current window.
The directory of the current file and current directory are two
entirely different things (that may, on occasion, have the same value).
cd /tmp; vim /etc/bash.bashrc
Unless I have autochdir (or something similar) set, the current directory is /tmp, yet the directory of the current file is /etc.
Edit If need to get the filename of your script I haven't found a good way to do that in the doc, so here is the solution I would suggested:
At the beginning of your script define a script-variable (see :h script-variable) like this:
The variable will be locale to the script so it is accessible and modifiable only from ...
&path has nothing to do with $PATH.
Also $PATH is set and used. See :echo $PATH.
You should also be able to change its value with :let $PATH = $PATH.':some/path' -- there are a few write only things, $PATH is not one of them IIRC
You can add ** to your path:
This way it will find every file recursively based on your current directory.
But apparently it's not recommended.
If you want to add other paths, you can just add them as follow:
You cannot configure the path that :read will use. It will always start from the current directory. :read is not affected by the path variable in vim (see :h path). Although, see the workaround sections below.
Note that once you input :read into the prompt you can use tab for file and directory completion, including going up (with ..) and down the ...
I think you’ve misunderstood 'path'. The path option determines which directories are searched for included files.
But what files are included are determined by the options include, suffixesadd, and includeexpr. These are used in combination to detect that the current file includes/imports some other filename; then that filename is searched for in the ...
Would be nice to see the full error, on which line it complains. Nevertheless you have error in the script, the set command requires no spaces around =, or spaces at all after = sign. You should also use setlocal, since set works globally (it will set for all buffers). And whole auto-command expression should be enclosed in execute with concatenation with ...
Google for vim to find their homepage. You find http://www.vim.org .
Look on their homepage, where is their upstream source. If you have luck, they are on the github.
On the "Download" section, they show many of their upstreams, first is the github one.
They say, git clone https://github.com/vim/vim.git is the clone command what you want, however you want ...
packpath, the option
packpath is an option, which means it can be altered using the set command. The set command already does de-duplication for appending values. For example,
It even adds/strips commas for you. It is not always possible, but if you can, use the ...
Yes, it's possible. You can run the command in a sub-shell (assuming that you're running in Unix and not Windows) and include a cd command at the start of the sub-shell. For example,
:!(cd /usr/local; ls)
Or even simpler,
:!cd /usr/local; ls
See :h :command-completion-custom
We can adapt the last example to complete only files listed by git.
command! -nargs=1 -bang -complete=customlist,GitFindComplete
\ GitFind edit<bang> <args>
function! GitFindComplete(ArgLead, CmdLine, CursorPos)
let search_pattern = "*" . a:ArgLead . "*"
let shell_cmd = "git ls-files " . shellescape(...
Make and Ninja offer a -C flag. From Ninja:
-C DIR change to DIR before doing anything else
If I run Ninja in a shell with the -C flag pointing somewhere that isn't the working directory, then the reported paths are the same as if I had cd'd over to the build directory. Nonetheless, Vim knows to become more intelligent when you use this flag in your ...
Another alternative is to use a plugin for file search that automatically adds all directories in your project. I like to use the CtrlP plugin to navigate to files in my project. I open file under cursor by <Leader>gf. You will need this in your vimrc
" Leader gf copies word under cursor to ctrlp
nmap <leader>gf :CtrlP<CR><C-\>w
You can use the :find command to locate a file by name and open it for editing.
:find will search for the file in the directories listed in 'path', which by default includes the current directory. You can add more directories to 'path' that you want to look up, and you can use wildcards, including ** to traverse multiple subdirectories.
In particular, to ...
How about using an input abbreviation? E.g. using iabbrevv ~~ /home/duck, when you type ~~/ it will be expanded to /home/duck/ immediately and you can continue as normal.
Or maybe just a mapping:
inoremap <C-x><C-f> <C-[>viW:s/\~/\/home\/duck/<CR>Ea<C-x><C-f>
This will simply substitute the tilde of the WORD you're ...
This is probably impossible without any plugins, as mentioned on the comments.
But you wouldn't have to start from the scratch if you want to implement such functionality using VimL, you could use the BufNameComplete plugin as a starting point (note that it uses the CompleteHelper : Generic functions to support custom insert mode completions plugin, which ...
There are a lot of commands in netrw for directory navigation. Some that come to mind: :Rexplore (to return from a file to netrw); :help netrw-qb will inform you of netrw's history mechanism (u, U), :help g:netrw_keepdir, etc.
:e %:h navigates to the directory of the current file. See :help expand() for more info. Tim Pope's Vinegar plugin essentially binds - to this, and introduces a few small other conveniences.
You could also use <c-o> to navigate to the previous jump/file shown in the current window.
That's not a nitpicky concern. You should expect an editor to behave consistently.
As @Raziman points out, buffer names are relative to the current working directory, unless the associated file is NOT even a descendant of the current working directory. If this is not your problem, read on...
If the associated file is definitely a descendant of the current ...
Rather than explicitly specifying paths to the files you have in mind, try using built-in file path handling functions like expand() (potentially with <sfile>) or glob()/globpath().
For instance, if you're looking for the root directory of your own plugin, you might try
let s:plugin_dir = expand("<sfile>:h:h")
I'm not sure how glob will work, ...