Tux

...making Linux just a little more fun!

2 cent tip: Prevent Vim to accidentally write to opened file

Mulyadi Santosa [mulyadi.santosa at gmail.com]


Wed, 15 Aug 2007 16:46:51 +0700

Hello everybody

Most of us use "view" or "vim -R" in order to execute Vim in readonly mode. However, sometimes we accidentally force writing by issuing ":w!" command.

To prevent this, you can try: $ vim -m <file>

It really stops you from writing the modified buffer back to the backing file. The only exception is when you manually turn write mode on via: :set write

have fun!

NB: Mr. Okopnik, please include this tip in the next LG release if you think this tip is useful for the LG audience. Thanks in advance.

regards,

Mulyadi.


Top    Back


Ben Okopnik [ben at linuxgazette.net]


Thu, 16 Aug 2007 11:18:43 -0400

On Wed, Aug 15, 2007 at 04:46:51PM +0700, Mulyadi Santosa wrote:

> Hello everybody
> 
>    Most of us use "view" or "vim -R" in order to execute Vim in 
> readonly mode. However, sometimes we accidentally force writing by 
> issuing ":w!" command.
> 
> To prevent this, you can try:
> $ vim -m <file>
> 
>    It really stops you from writing the modified buffer back to the 
> backing file. The only exception is when you manually turn write mode on 
> via:
> :set write
> 
> have fun!
> 
> NB: Mr. Okopnik, please include this tip in the next LG release if you 
> think this tip is useful for the LG audience. Thanks in advance.

That's already done - and you did it yourself. :) Kat, our Mailbag Editor, separates the Mailbag into publishable sections at the end of each month; anything with a subject that indicates what it is - e.g., 'TIPS' or '2-cent tip' is rather obvious - makes her life easier, and makes sure that your contribution goes into the right section.

-- 
* Ben Okopnik * Editor-in-Chief, Linux Gazette * https://LinuxGazette.NET *

Top    Back