vim 101 hacks
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Buyer: xiujuan lu (luxiujuan@gmail.com)<br />
Transaction ID: 85W16630AD8515549<br />
Vim <strong>101</strong> Hacks<br />
www.thegeekstuff.com<br />
Hack 54. Setup Quit Confirmation<br />
If you forgot to save changes and execute :q you’ll get the following message.<br />
In this case, you have to save the file and then do the :q again.<br />
:q<br />
E37: No write since last change (add ! to override)<br />
To get a save confirmation dialog when exiting Vim, do the following.<br />
:confirm q<br />
Save changes to "test.txt"?<br />
[Y]es, (N)o, (C)ancel:<br />
Note: You can map the :q command to the “:confirm q” command using the<br />
Vim map feature explained in Hack 80.<br />
Hack 55. Use :up and Avoid :w<br />
When you execute :w , it will save the file. The main problem with :w is that<br />
when you type :w, it will update the file timestamp even if the file has not<br />
been changed.<br />
Luckily,:up will save the file and update the timestamp only when changes<br />
have been made to the file.<br />
:up<br />
91