Vimrc - current working directory

I would like to have access to the current working directory in my vimrc. For example, I can access the current file using%.

In particular, I have the following line in my vimrc: card, l :! latex%

When it starts, everything works fine, except that as a result, dvi and other files are stored in my home directory, and not in the current working directory.

Any suggestions?

+5
source share
3 answers

See :help autochdir. Vim can automatically change the current working directory to the directory in which the file you are editing lives.

Otherwise, if you want to do this manually, see :help cdand :help lcd.

+6

. :he filename-modifiers

:!latex % -output-directory %:h
+2

, vim , . , latex, vim, .

You probably know this and want to simply extract the path from the file name and provide it as an argument to the -ocommand option latex. Just use the shell features:

:!latex % -output-directory `dirname "%"`

I'm not sure if this is a parameter -output-directory, but you get what you asked for - the directory name of the file you are editing.

+1
source

All Articles