Reputation: 57
I'm using Vim to encrypt a file.
In my .vimrc I have:
set viminfo='0,\"0,\/0,:0,f0
setlocal cryptmethod=blowfish
AFAIK The first line tells Vim not to save information on .viminfo so the nothing from the file to encrypt is saved.
The problem is that this removes all the viminfo nice features for all the files
I'm searching for something like:
autocmd «ThisExactFileNameKeyword» thefileiwanttoencrypt set viminfo='0,\"0,\/0,:0,f0
Does Vim provides any command to place on «ThisExactFileNameKeyword»?
EDIT Ingo Karkat's solution works like charm
autocmd VimEnter * if ! empty(&l:key) | set viminfo='0,\"0,\/0,:0,f0 | echomsg "Adapted for encrypted editing" | endif
I just had to change the encryption method from blowfish to blowfish2 to get rid of a warning on weak method.
Upvotes: 0
Views: 605
Reputation: 172768
When you read :help 'viminfo'
, you'll notice that this is a global option. So, its contents alway apply to the entire Vim session.
In order to differentiate the settings between normal editing and editing of an encrypted file, you have to use a separate Vim session for editing the encrypted file.
You can check for this in your ~/.vimrc
, and adapt the 'viminfo'
setting (and others) accordingly. For example:
if argc() == 1 && argv(0) ==# 'thefileiwanttoencrypt'
set viminfo=...
endif
or for any encrypted file:
autocmd VimEnter * if ! empty(&l:key) | set viminfo=... | echomsg "Adapted for encrypted editing" | endif
Upvotes: 4