wiswit
wiswit

Reputation: 5925

How to show constantly current working directory in vim

A very simple question, is there some way to show constantly the current working directory at the bottom of the file opened by vim? Thanks.

Note this is a different question as here: How can I permanently display the path of the current file in Vim?

There we want to show the full path of the current file viewed, but what I am thinking is to show both, maybe two lines on the bottom of file: one for full path currently viewed; the other for the current working directory. These two could be different as we can open a file that's not in the current working directory.

Upvotes: 10

Views: 9234

Answers (1)

ryuichiro
ryuichiro

Reputation: 3865

You can do it by adding these lines in your .vimrc

set laststatus=2
set statusline=%!getcwd()

The first setting is to configure statusline to be always visible, second one is to add a current working directory to statusline.

More on


Edit: This is an answer to OP's changed question:

It is not possible to have two-line statusline (at least to my knowledge). But it is possible to add e.g. some formatting. So

set laststatus=2
set statusline=%F
set statusline+=%=
set statusline+=%{getcwd()}

To further study I recommend to read help I mentioned before. Also this question might be of some interest.

Upvotes: 14

Related Questions