Hot answers tagged

19

Unlike :source, :runtime doesn't need an absolute path to work. It is much better than :source for building portable setups. See :help :runtime. In the following example, we tell Vim to look for a vimrc file in the directories given by the runtimepath variable. Since ~/.vim/ is the first directory in the list, runtime vimrc works just like :source ~/.vim/...


7

First I did a :helpgrep included files, then went through the most promising matches until I found: From :help included-search: 6. Include file searches *include-search* *definition-search* *E387* *E388* *E389* These commands look for a string in the current file and in all encountered included files (recursively). This ...


5

The answer should depend on what you want to scatter in several files. There are a few different ways to have a configuration in several files. Note: the difference between runtime and source has been described, I won't say anything again on this subject. So. You'll also have to take into account the what. Nowadays, we seldom have a need to use so or ru ...


5

@romainl's answer is the best practice. But as an additional example I have these lines in my vimrc which might interest you. I use them to source a local vimrc which I don't keep in my dotfiles source control: " Source a local vimrc {{{ if has('win32') let $MYLOCALVIMRC = $HOME . "/_local.vim" else let $MYLOCALVIMRC = $...


3

Yes, or even just so somefile. See :help so.


3

You could use dictionary completion to do this. Basically it completes what you type from a file (as you want). By default it is mapped to i_ctrl-x_ctrl-k and the dictionary file can be set using set dictionary=fname where fname is the name of the file containing the words (either absolute or relative to the current directory). If you really want the mapping ...


3

That feature is built-in, it has nothing to do with that "node" plugin. It's called "include search" and you can read all about it in :help include-search. You have a few ways to jump to an item in the list: :136<CR> will jump to line 136 but it is obviously restricted to the current buffer and you only jump to the line, not the match, :ijump 3 <C-...


2

The default php ftplugin already does that for you: setlocal include=\\\(require\\\|include\\\)\\\(_once\\\)\\\? Add filetype plugin indent on to your ~/.vimrc if it's not already there to benefit from Vim's filetype detection.


2

Version 8.2.935 introduced a flatten() function (and version 8.2.937 fixed a bug in that function). With this function you can also write let s:asciiart = flatten(["", "", systemlist("command params"), "", ""]) to insert the elements of the inner list into the outer list.


2

If you can guarantee your original format, you can use split(system(command), ',\s\+') But CSV (as in the self-answer) is probably cleanest. Alternatively, have the outputs on their own lines and use systemlist(command) Vim unfortunately doesn't have an "explode" operator that I am aware of.


1

Vim is separating out the @ when extracting the filename. Why? Per :h gf... [Vim] uses the 'isfname' option to find out which characters are supposed to be in a file name. You can demonstrate this another way by putting your cursor on the filename and running :echo expand('<cfile>') The response is "mynamespace/footer/footer.twig". <cfile>...


1

As an alternative, you can use :h eval(). For example: let s:asciiart = eval('["", "", ' . trim(system("command args")) . ', "", ""]') Note that system() output includes extra newline(s), so you have to deal with it.


1

Use either [d or [i. :help include-search is a built-in but sadly overlooked feature.


Only top voted, non community-wiki answers of a minimum length are eligible