Wikia

Vim Tips Wiki

Changes: Protecting a file from accidental changes

Edit

Back to page

(Move categories to tip template)
(Change <tt> to <code>, perhaps also minor tweak.)
 
Line 4: Line 4:
 
|previous=425
 
|previous=425
 
|next=427
 
|next=427
|created=February 13, 2003
+
|created=2003
 
|complexity=basic
 
|complexity=basic
 
|author=zzapper
 
|author=zzapper
Line 15: Line 15:
   
 
Solution: Set the master file to read only, and change its color scheme.
 
Solution: Set the master file to read only, and change its color scheme.
 
 
<pre>
 
<pre>
 
:set nomodifiable
 
:set nomodifiable
Line 21: Line 20:
 
</pre>
 
</pre>
   
Non-modifiable is better than <tt>:set ro</tt> as <tt>nomodifiable</tt> won't even let you start changing stuff, whereas <tt>:set ro</tt> will only warn you once.
+
Non-modifiable is better than <code>:set ro</code> as <code>nomodifiable</code> won't even let you start changing stuff, whereas <code>:set ro</code> will only warn you once.
   
 
==Comments==
 
==Comments==
 
You can permanently protect a file by setting a suitable modeline {{help|modeline}}.
 
You can permanently protect a file by setting a suitable modeline {{help|modeline}}.
+
<pre>
// vim:noma
+
// vim:noma
+
</pre>
----
 

Latest revision as of 05:30, July 13, 2012

Tip 426 Printable Monobook Previous Next

created 2003 · complexity basic · author zzapper · version 5.7


A common programmimg situation, you are comparing two versions of the same file. One is the "reference file" which you don't want to update. However they look so similar that you can get confused.

Solution: Set the master file to read only, and change its color scheme.

:set nomodifiable
:colorscheme peachpuff

Non-modifiable is better than :set ro as nomodifiable won't even let you start changing stuff, whereas :set ro will only warn you once.

CommentsEdit

You can permanently protect a file by setting a suitable modeline :help modeline.

// vim:noma

Around Wikia's network

Random Wiki