0

There is a comment by Carpetsmoker which suggests a way to prevent Vim from recording events for certain filetypes:

I would not recommend using a separate vimrc file, for the simple reason that it's so easy to forget. Something like this autocmd: au BufRead * if &cryptmethod != "" | setlocal nobackup noundofile ... | endif should do the magic for you, and it's impossible to forget.

I am not sure if I understand how it is suppose to work.

Questions:

Do I have to basically start Vim with an option like this: vim +"set cryptmethod=blowfish" to trigger the setlocal nobackup noundofile ... section of the autocommand from the comment?

Why does Carpetsmoker say that the crytpmethod way is superior to the separate vimrc way?
As I think of it, both

vim -u ~/.vimrc-incognito

and

vim +"set cryptmethod=blowfish" 

are equally easy to forget.

1 Answer 1

4

Note that the original question was asking about how to prevent leakage of sensitive information every time certain filetypes are edited.

The essential point that @Carpetsmoker was trying to make is that this feature should be automatic, because anything manual is easy to forget.

Note that he wrote: "Something like this autocmd" (emphasis mine), so this code isn't necessarily supposed to be a full answer. I think he may have misremembered the encryption options slightly, and meant to check 'key', which is set if and only if encryption is being used, rather than 'cryptmethod', which is set by default to 'zip'*. Seeing as the original question was about filetypes though, the following might have been a simpler illustration of his concept:

au BufRead *.[sensitive filetype] setlocal nobackup noundofile ...

To use your examples, he's not suggesting you should use:

vim +"set cryptmethod=blowfish" 

instead of

vim -u ~/.vimrc-incognito

He's suggesting you should configure Vim is such a way that you can use:

# automatic, impossible to forget
vim filename.[sensitive filetype]

instead of:

# manual, easy to forget
vim -u ~/.vimrc-incognito filename.[sensitive filetype]

...which is an obvious improvement.

None of this is really relevant to what you are trying to do, however, which is specifically to create a feature that is not limited to certain filetypes and which does need to be turned on manually.

* and I suspect even this wouldn't actually work well, as I don't think this autocmd would fire when setting the key with :X — I haven't tested this, though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.