7

&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


5

Variables are not expanded in the context of a set command. So use let: let &titlestring = $TTY . ' %-25.55F %a%r%m' set titlelen=17


5

You can capture output with execute() function and then pump it through sort(). The whole command could be then: command! -bang -nargs=1 -complete=command Sorted \ echo join(sort(split(execute(<q-mods> . ' ' . <q-args>), "\n"), \ {s1, s2 -> <bang>(s1 ># s2) - <bang>(s1 <# s2)}), "\n") Now you can do :Sorted ...


4

The specific path you're using (pack/vendor/start/nerdtree) is using the "packages" feature, which is a new Vim 8 feature that automates manipulation of 'runtimepath' in a way similar to how plug-in managers have been implemented. That's why your attempt setting 'runtimepath' from --cmd doesn't work, since packages actually use a separate 'packpath' setting....


4

For this particular case where $TTY is constant and not likely to change, @Ralf's answer of using let &titlestring to compose the setting string value is recommended. Another possible approach is to use a %{...} group inside the setting value, which will evaluate it every time the setting is used. In this case, this would work: set titlestring=%{$TTY}\...


3

I tried to use backtick expansion, but that does not seem to be working on Windows. So I think the easiest solution is something like this: :exe ":e" $ABC."foobar.txt"


3

Linux view, for more details see Doktor OSwaldo answer. The installation directory is defined during build (to be exact: It is defined when configuring the build.). The default value of $VIM is a subdirectory below the installation directory and is compiled in (<inst-dir>/share/vim on Linux). You can override this by setting the environment variable ...


3

In vim dot is a concatenation operator: let repo = $Project . '/cfora' To "refer" variable in the string, well, in your case it is just a concatenation again: exe '!cmake ' . repo PS I would suggest to use built in make facilities for this. And vim lcd instead of exe '!cd ...


3

The TERM environment variable is generally set by the terminal emulator you're running in, and it tells programs using curses (like Vim and Neovim) what sequences to send to the screen to do things like moving the cursor and setting colors. When you're using a graphical environment, Vim and Neovim don't need this environment variable to be set, since they're ...


2

The whole process can be read under :h $VIM: To avoid the need for every user to set the $VIM environment variable, Vim will try to get the value for $VIM in this order: The value defined by the $VIM environment variable. You can use this to make Vim look in a specific directory for its support files. Example: setenv VIM /home/paul/...


2

Starting from Patch 7.4.1384 Vim has 'packpath' option for searching plugins. By default 'packpath' is equal to 'runtimepath' (until 'runtimepath' finally gets inflated by the plugins loaded), so you must keep them sync in your vimrc. For Vim 8, I'm calling it like this: /usr/local/bin/vim8 -u "${HOME}/.vim8/vimrc". You can add the following lines on top ...


2

Here is a different approach. :filter let will only look for matching variable names, so you can re-implement it using filter() function and sort the resulting dict and output all matches afterwards. This is using the new method functionality of Vim 8.1 and a lambda expression. for val in sort(keys((copy(g:)->filter({k -> k =~# 'python'}))))|echo ...


2

As any child process inherits the environment from its parent, you can temporarily redefine Vim's own environment before executing your tool: let [temp, $ENV_VAR] = [$ENV_VAR, ''] %!cmd let $ENV_VAR = temp


2

FYI, I'm taking a "Vim learning" approach and demonstrating how to take what OP has already (for the most part) and properly move much of it into a function. As a couple of the comments above show, though, there certainly could be nice alternative approaches that also solve the problem in question. There are a few ways you could go about it. They ...


1

You don't need environment variables for your use case. As filbranden said, you can directly use Vim variables, through :exe. Using an environment variable would make sense only if you use a variable that is being set before starting Vim, or if you expect to execute (from Vim) an external program that relies on that environment variable. In that latter case :...


1

Here are the commands I use to create a python 3.6.0 pyenv on a Mac using homebrew. Please note that I use neovim but the process to create a pyenv will not be much different for vim. Install readline and xz along with pyenv and pyenv-virtualenv brew install pyenv pyenv-virtualenv readline xz Install python 3.6.0 CFLAGS="-I$(brew --prefix openssl)/...


1

After saving a session to a file you can edit it and replace parts of the path with the environment variables: Original: set ... edit C:\Users\yourname\Some\Path\file.txt set ... Modified: set ... edit $HOME\Some\Path\file.txt set ...


1

Make sure the environment variable TERM is set. For example set the environment variable from bash via export TERM=xterm THEN open vim. Once in vim you can check that it worked by doing set term. Apparently vim checks the environment variable TERM to decide what how to handle terminal control characters (more info on vim handling terminal control characters ...


1

I'd better create an "empty" GPG encrypted file with the proper recipient and open it. echo "" | gpg -a -e -r <GPG ID/mail> > doc.asc vim doc.asc


1

In that case, you could simply use the good old exists() :let foo = exists('$FOO') ? $FOO : 'default' There is also empty(), IMO it only makes sense if you want to undefine environment variables from within Vim. Indeed, as :unlet $FOO isn't possible, yet, we have to use :let $FOO='' To obtain all environment variables, you could use getcompletion() on ...


1

$VIM_DATA_DIR already gives you the environment variable, so you can do let $VIM_DATA_DIR = !empty($VIM_DATA_DIR) ? $VIM_DATA_DIR : "default" If you really need all environment variables take a look at this answer on stackoverflow: function! Env() redir => s sil! exe "norm!:ec$\<c-a>'\<c-b>\<right>\<right>\<del>'\&...


1

At least on neovim, something like this should work. It uses stdpath() in order to handle XDG env variables and filereadable() which is more readable that empty(glob()): " Bootstrap Plug let autoload_plug_path = stdpath('data') . '/site/autoload/plug.vim' if !filereadable(autoload_plug_path) silent execute '!curl -fLo ' . autoload_plug_path . ' --create-...


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