I want to set it so that when I write a text file and save it - it is saved to a default folder called TEXT which will be in my main Vim folder eg. C:\Program Files\Vim\vim73\TEXT
at the moment they are saved by default in the vim73 folder mixed in with everything else. so if I type :W^M the file gets saved there and I want it to go to the folder named TEXT
When you save a file vim will default it to your current working directory. You can use the command :pwd
to verify this. To change it you can use :cd SomeDirectoryPath
.
You could also add the cd command to your .vimrc (or the equivalent for windows) to automatically change your current directory every time you start vim.
Another possible approach would be to intercept the writing process with an autocmd for a writing event, probably BufWriteCmd. Have the autocmd function check to see if the file has a .txt extension (or whatever you use) and bypass the normal write process to save however/wherever you want. For docs see:
:h BufWriteCmd
Here's some code you could put in vimrc, not thoroughly tested to make sure behavior is exactly what you'd want, but it does basically work:
function! WriteTextFile()
execute 'write! c:\text\'.expand("%:p:t")
set nomodified
endfunction
au BufWriteCmd *.txt call WriteTextFile()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With