I'd like to call the VCSStatus function passing the current working directory (whatever :pwd
returns) to it. It has to be the full path, and no special characters such as "." are accepted.
Asked
Active
Viewed 2,437 times
5

cyberguijarro
- 715
- 3
- 9
- 21
-
IIRC I believe that only works with a special modification to NERDtree. I'll look around for the right information... – Michael Berkowski Nov 22 '12 at 13:13
-
Oh [here it is](http://stackoverflow.com/questions/4072472/how-do-i-use-the-vim-plugin-vcscommand-to-diff-commit-etc-on-a-directory-or) It's not a modification to NERDtree, but rather that you can't have NERDtree active since it looks for netrw. The modification I was misremembering was to bind a keystroke to disable NERDTree temporarily while using VCSCommand. – Michael Berkowski Nov 22 '12 at 13:15
-
I don't have NERDtree, so that shouldn't be a problem here. All I want is to expand the current directory when executing a command. Also, I'm on windows. – cyberguijarro Nov 22 '12 at 13:17
-
Hmm, I wonder if it is a Windows issue. I just tested `:VCSStatus .` (for a svn project) and I got the correct output for the current working dir. – Michael Berkowski Nov 22 '12 at 13:20
-
What version of VCSCommand do you have? – Michael Berkowski Nov 22 '12 at 13:21
-
The latest from vim.org/scripts. The thing is, I want to perform operations on entire directories, and not just on the current active buffer... like "commit this_folder" or "status that_folder". – cyberguijarro Nov 22 '12 at 13:23
-
@MichaelBerkowski It works as long as your don't open a file in a subdirectory. – cyberguijarro Nov 22 '12 at 13:25
-
So, is there nothing like "%" but for the current working directory? – cyberguijarro Nov 22 '12 at 13:26
-
`:VCSCommit ./subdir` works for me on Linux too... – Michael Berkowski Nov 22 '12 at 13:28
1 Answers
6
:execute 'VCSStatus' getcwd()
should do the trick. Should you wish to use the current file's directory instead, it'd be:
:execute 'VCSStatus' expand('%:p:h')
(%
refers to the current file, :p
modifies to a full absolute path, and :h
cuts off the filename; cp. :help filename-modifiers
)

Ingo Karkat
- 167,457
- 16
- 250
- 324
-
1The directory of the current file is not the same as the current directory. – Roman Cheplyaka Nov 22 '12 at 13:43
-
Ah, sorry, I have `'autochdir'` set, so it doesn't make a difference for me :-) The fix is even easier; I've added it to my answer. – Ingo Karkat Nov 22 '12 at 13:47