sponsor Vim development Vim logo Vim Book Ad

basic Tip #582: Quick way to write to your file.

 tip karma   Rating -6/26, Viewed by 2162 

created:   October 9, 2003 17:07      complexity:   basic
author:   somebody      as of Vim:   5.7

Put this in your .vimrc
map , :w^M

When you need to save your file instead of typing :w and hitting enter, just hit the comma (,) Note that with vim you may need to type CTRL-Q first to get the verbose CTRL-M character in your file.  For those who have earlier versions or non-PC compatible, CTRL-V before CTRL-M will get that character in there.  Has been life-changing for me :-).  I can't take the credit as I found this one years back when scanning info about building html pages.  The author had a little script that checked the update of the file and sent a message to the browser to re-read the file when the file was written.  He's the one who suggested mapping an unmapped button to do this.

 rate this tip  Life Changing Helpful Unfulfilling 

<<Using vim to view source and edit textarea in mozilla/firebird | Vim as XML Editor >>

Additional Notes

Anonymous, October 10, 2003 13:27
I think this would break all those scripts that use a comma as a leading character.  
Anonymous, October 13, 2003 4:46
See ":help :update"

  map , :update<cr>
misof, December 16, 2003 13:06
also useful is :set autowrite, usually I want to save the file exactly before I try to compile / tex it, autowrite does it for me...
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
    stats
Sponsored by Web Concept Group Inc. SourceForge.net Logo