I’m working with several files in gvim in Windows 7. I need to test the files (Python scripts) in linux. So apart from their original location I want to also save the files in a folder called linux. I want to do this with new files that I will be creating/modifying. That’s why I want to use a mapping with the % sign to get the name of the current file Into the new path.
The problem I’m having is that the % sign is escaped with a backslash, so this doesn’t work :
:w C:\projects\linux\%:t
Being the original location:
C:\projects\foo\
Is there a simple way to just save the current file in a different folder? (I have read that the % sign is a filename character, so I could erase it from the string isfname and it should work but I think I am making it more complicated than what it really is.)
You might be able to do this sort of thing fairly automatically using the
autocmdfeature.The following (untested) line in your platform’s equivalent of
~/.vimrcwill update a copy of a file whengvimmakes modifications:The
:twill take just the tail of the pathname; if you’re working with multi-level directories, perhaps:p:.would be better. See the documentation for more details.