Wikia

Vim Tips Wiki

Changes: Some tips on saving the document

Edit

Back to page

(Tip is OK, merge only comment into article.)
(adjust previous/next navigation + minor manual clean)
 
Line 2: Line 2:
 
|id=897
 
|id=897
 
|previous=896
 
|previous=896
|next=898
+
|next=899
|created=March 18, 2005
+
|created=2005
 
|complexity=basic
 
|complexity=basic
 
|author=Salman Halim
 
|author=Salman Halim
|version=5.7
+
|version=6.0
 
|rating=12/11
 
|rating=12/11
 
|category1=
 
|category1=
Line 12: Line 12:
 
}}
 
}}
 
I use the following mappings to save my document -- they do away with the need for hitting escape when I'm in visual or insert modes.
 
I use the following mappings to save my document -- they do away with the need for hitting escape when I'm in visual or insert modes.
 
 
<pre>
 
<pre>
 
nmap <c-s> :w<CR>
 
nmap <c-s> :w<CR>
Line 22: Line 21:
   
 
In most Unixes you can disable control-S by doing this:
 
In most Unixes you can disable control-S by doing this:
 
 
<pre>
 
<pre>
 
/bin/stty stop undef
 
/bin/stty stop undef
Line 28: Line 26:
   
 
The F2 series of mappings are different; they only write if needed (performing an update) and return you to where you were: insert mode, visual selection etc.
 
The F2 series of mappings are different; they only write if needed (performing an update) and return you to where you were: insert mode, visual selection etc.
 
 
<pre>
 
<pre>
 
nmap <F2> :update<CR>
 
nmap <F2> :update<CR>

Latest revision as of 05:26, August 11, 2011

Tip 897 Printable Monobook Previous Next

created 2005 · complexity basic · author Salman Halim · version 6.0


I use the following mappings to save my document -- they do away with the need for hitting escape when I'm in visual or insert modes.

nmap <c-s> :w<CR>
vmap <c-s> <Esc><c-s>
imap <c-s> <Esc><c-s>

However, control-s will freeze some computers; if that happens, hit control-q to get out it.

In most Unixes you can disable control-S by doing this:

/bin/stty stop undef

The F2 series of mappings are different; they only write if needed (performing an update) and return you to where you were: insert mode, visual selection etc.

nmap <F2> :update<CR>
vmap <F2> <Esc><F2>gv
imap <F2> <c-o><F2>

So, if you're done with a particular operation, hit control-s (or whatever you come up with as a replacement); if you're not done, but want to save (just to be safe), use the F2 series of mappings.

CommentsEdit

Around Wikia's network

Random Wiki