Reputation: 9288
In vimscript, if I want to get the value of current working directory for current buffer (could be changed by :lcd
), which variable or expression would I use to fetch that?
Upvotes: 11
Views: 9961
Reputation: 53604
let cwd = getcwd()
or
let cwd = fnamemodify('.', ':p')
. Both always return effective value for the current buffer, but determination of whether this is working directory local to buffer (i.e. changed by :lcd
/'autochdir'
) or global one (i.e. changed by :cd
/untouched since vim start) is the more interesting question. I do not know the answer for it.
Upvotes: 15