Stopping vim from encrypting your files

I usually use :x to exit and save in vi and vim; there's no great reason for it, it just happens to be what I started using. The problem comes when I don't release the shift key fast enough, and end up typing :X instead, which offers to encrypt my file for me, and prompts for a key. It's only happened twice in my career, but twice too many, that I am typing ahead past the :X, enter a key I have no idea what it might be, and manage to be confused enough to save the file anyway...encrypted...with an unknown key.

Now of course I always have current backups, even of the changes I just made with the editor. Not.

In vi, I disabled this whenever I could by deleting the /usr/bin/crypt command (which I didn't need for anything else, as far as I could tell). However, vim has its own builtin cryptographic functions, so another method was necessary:

in my .vimrc, I put

:cmap X echo "no I won't encrypt, it just makes trouble"<CR>

presto, no more :X, and a handy message as to why.

Comments:

I had the same problem until I mapped :X to :x in my .exrc file years ago:

map! X\^M x\^M

NOTE: do not paste the line above - the \^M characters above are actually line return chars created by pressing [CTRL-V][ENTER].

The .exrc is sourced by both vi and vim, so this solution fixes the problem for both editors.

Posted by sean walmsley on March 31, 2009 at 04:11 AM PDT #

Post a Comment:
Comments are closed for this entry.
About

user12614486

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today