E.g., it I do:
or any other
!, it first prints:
syntax error near unexpected token ( ls() ( /* my alias */ )
and then the actual command.
The problem only happens in GVIM, not in Vim.
Ubuntu 16.10, vim 7.4.1829.
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.Sign up to join this community
Instead of adding
shellcmdflags and reading your entire
.bashrc just for loading aliases, keep your aliases in a separate file, like
~/.bash_aliases for Ubuntu, and add to your vimrc:
let $BASH_ENV = "~/.bash_aliases"
From the bash manual,
When Bash is started non-interactively, to run a shell script, for example, it looks for the variable
BASH_ENVin the environment, expands its value if it appears there, and uses the expanded value as the name of a file to read and execute. Bash behaves as if the following command were executed:
if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
but the value of the
PATHvariable is not used to search for the filename.
Since Vim still invokes bash non-interactively, bash doesn't enable aliases. You can do so by adding to the file:
shopt -s expand_aliases
This is harmless in an interactive shell, so adding it won't cause problems.
The default bashrc for Ubuntu, contains the following lines at the beginning:
if $TERM_IS_COLOR ... ... else alias ls="ls -F" alias ll="ls -lF" fi
which I had kept.
Then at some point I added:
i to have access to my aliases from vim commands.
But the GVIM shell cannot show colors, and only in that case the default
alias comes before my command, and messes things up.
For now, I will just remove the lines:
alias ls="ls -F" alias ll="ls -lF"
and see some raw shell color commands from time to time on GVIM.