12

If I map a command in vim using something like

map <f4> :! pdflatex %<cr>

Vim will ignore my alias for pdflatex (something like alias pdflatex='pdflatex --temp-dir=something'). Is it possible to make vim not ignore it?

1
  • Is it possible your vim shell or shelltype don't match your login shell? Commented Sep 30, 2009 at 16:18

1 Answer 1

17

Vim 'ignores' your aliases because your shell is not in a 'mood' to parse your .bash_profile/.bashrc (you did not specify, where your aliases are defined) because it is not started as a login/interactive shell (read here to find out more about what is read when and for what reason).

So, you have several options:

  1. Put the code you use in your pdflatex alias into a script and call that
  2. vimrc: 'set shell=/bin/bash\ -l', put your aliases to .bash_profile
  3. Call your shell as an interactive/login shell: :! bash -l -i -e 'pdflatex .'
4
  • 2
    Login/non-login doesn't matter for ~/.bashrc - only interactive/non-interactive does. Commented Sep 28, 2009 at 11:44
  • my aliases are in .bash_profile.. hmm I changed the question a little. I'd rather it run in the current shell. Your second solution seemed the most 'acceptable' however, it makes the % variable useless since opening a new shell usually starts at the home folder.
    – vonhogen
    Commented Sep 29, 2009 at 7:12
  • This is an amazing and thorough answer. Thanks!
    – Abel
    Commented Mar 30, 2011 at 21:52
  • set shell=/bin/bash\ -li in .vimrc did the trick. works fine on mac sierra. did not have to copy or move aliases at all thx! Commented Jul 10, 2020 at 21:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .