Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am new to vim,

Usually I find myself wanting to save and stay in insert mode, rather than hit escape key, :w and back into insert mode.

please help me

share|improve this question

migrated from stackoverflow.com Dec 28 '09 at 8:57

This question came from our site for professional and enthusiast programmers.

2  
I think it should stay here. Most vim questions are asked on SO, and by starting to divide them amongst sites accomplishes nothing except giving a user more work in terms of searching for them in all three sites. Vim is also an editor more often found at programmer's then average(or super:) users's machines. –  ldigas Dec 26 '09 at 23:26
    
I agree. SO has 1,199 questions tagged vim. SU has 106. –  zen Dec 28 '09 at 22:11

4 Answers 4

Ctrl+O, then :w and Enter.

share|improve this answer
    
Yup, that's how I'd do it too. –  David Wolever Dec 26 '09 at 20:40
    
Which is actually more complicated than the usual way, IMHO. –  ldigas Dec 26 '09 at 20:41
    
@Idigas: why is that? –  akira Jun 1 '10 at 19:47
1  
It is the same number of key strokes, but seems not very vimish. –  Seamus Aug 16 '10 at 18:32

You could add an alias like inoremap <F3> <c-o>:w<cr> in you .vimrc.

share|improve this answer
2  
+1, but <f2> ;-) –  Michael Krelin - hacker Dec 26 '09 at 21:06

Without getting into a debate about the right or the wrong way, if you use a graphical Vim like MacVim or GVim, you should be able to use Cmd-s or Ctrl-s for saving. I can say that it works on OS X with MacVim and Cmd-s and so you can save your stuff in the insert mode.

share|improve this answer

Apart from that suggestion which Juliano mentioned (which should be taken out and shot <- the suggestion, not Juliano), it really is THE WRONG WAY TO DO IT. It would be actually more "normal" to try and do everything from command mode, instead of insert. But using them interchangeably is the usual vim's way and if one doesn't like it one should really stay clear of vim.

If you really don't like not being able to save from I mode, may I suggest an editor called Cream - it is a variant of vim, modified in a way that emulates nowadays's editors (so to say, it stays in I mode all the time, and has usual windows shortcuts).

share|improve this answer
1  
While I agree on the general rule, I don't think it applies to this case. If you're just writing a long text and want to save often, mapping some key to <C-o>:w<CR> ain't really that bad. –  Matteo Riva Dec 26 '09 at 20:47
    
I've tried cream (which is not exactly an editor, but just a vim bastardizer) a few years ago and still wonder why not just switch from vim to something "more appropriate"? –  Michael Krelin - hacker Dec 26 '09 at 21:05
    
@Michael Krelin ... - I agree. But he said he wants insert mode, so there it is. Personally, I thought at first about suggesting Notepad2 (or some other particular flavour) but that would've just been downvoted as non answerin gthe question. –  ldigas Dec 26 '09 at 23:22
    
@kemp - No. If you're writing a long text and you want to save often you use vim's capabilities in terms of: backup, writebackup and swapfile (you can :help any of them for details). Vim is -the way it is-, and although I (like all others) like a bit of customization now and then, trying to avoid several modes is just wrong. And it will not end well. Better to use something else then. After all, there are some pretty powerful alternative editors nowadays. –  ldigas Dec 26 '09 at 23:24
1  
I read it as "I do not want to leave insert mode just to save file". –  Michael Krelin - hacker Dec 27 '09 at 10:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.