Vim - saving from insert mode - no confirmation - help?
Hi,
I use the 'zz' key combination to save the file without exiting vim. To make it work in both normal and insert mode I use the following 2 lines in my .vimrc file: Code:
imap zz <Esc>:w<CR>i<right> Is there some kind of a time delay function in vim so that I can have a line like this: Code:
imap zz <Esc>:w<CR>:echo "Saved."<CR> timedelay(500ms) i<right> (I am using vim in a terminal - not a GUI.) |
In vim, you may also write without quiting with this command: :w!
When I used this option in a test, there was a statement displayed which gave the number of characters written to the file. The vim manpage says this: Code:
:w[rite]! [++opt] Like ":write", but forcefully write when 'readonly' is Within a vim session, give the command ":help write" (without quotes) for more information. |
Why would you want a key sequence like zz to work from within insert mode? Do you never expect to type "jazz" or "fuzz" and are OK with wiping them out of the dictionary now and forever?
Why not save without exiting in command mode by using :w like the majority of everyone else? And NOT try to save while in insert mode, like everyone else? There are already about ten bazillion alternate ways you can accomplish something in vi, why try to add even more non-standard ones? That's like modifying your car so that pushing the accelerator to the floor actually applies the brakes. Because you never push the accellerator to the floor yourself, and desire an alternate and "more intuitive" (for you) way of applying the brakes. Then you get into somebody elses car that doesn't have your custom modifications and you are set up for a significant crash and burn. |
The default status line shows "[+]" on the for modified buffers, or you could keep a running changes-since-saved count displayed using the `statusline` option, the `changedtick` variable and a `bufwrite` autocommand to track its value at the last save.
|
Quote:
|
Quote:
Imagine I am editing an HTML document. As soon as I am done I am pressing 'zz' with my right hand (Dvorak) while my left is reaching for the Alt-Tab to go to the browser to refresh. Total 2 "movements" - I count 'zz' as one and Alt-Tab as one. Compare that to 'jj'+:+w+<CR>+Alt-Tab = 5 by the same standard plus I have to press 'i' for insert mode when I get back = 6. You are right, though, that if I move to someone else's computer I would be typing junk. |
Quote:
|
All times are GMT -5. The time now is 08:56 AM. |