1

Although this question is similar, answer given over there changes the working directory only temporarily i.e. whenever I close and reopen gVim and write a new file given just the filename, it saves it in the home directory.

Here is another similar question, but I didn't get what the answer is trying to say. I found a _vimrc file at C:\Program Files (x86)\Vim. But I don't know what to do with it.

I want to achieve this:
Whenever I open vim and write a new file, given only the filename, it should save it in C:\Users\Sourav Kannantha B\Documents\Vim Projects instead of C:\Users\Sourav Kannantha B

I just downloaded gVim today from their website. So I am new to this.

Sourav Kannantha B
  • 2,860
  • 1
  • 11
  • 35
  • The `.vimrc` file is a sort of "config' file for vim. It's really a vim _script_ and it gets invoked whenever you first open vim. I'm not familiar with gvim, but I'd imagine that if your goal is to set your working directory to a fixed location at all times, you can add a line to your .vimrc to do that... i.e. `cd /path/to/dir/`. That being said, if you're opening a file that exists or that you've just created, it's going to write to that file still, regardless of your cwd... – David Goldstein Jan 19 '21 at 14:31
  • If you only care about new files that you create _within_ vim, then I think setting your working directory with a `cd` command in your vimrc would probably do the trick. Keep in mind that opening an existing or new file from outside of vim, with vim, is going to save that file in whatever location you specified from outside of vim as you've already specified a path. – David Goldstein Jan 19 '21 at 14:41

0 Answers0