Edit Page
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 16: | Line 16: | ||
First, be sure you have gnupg setup to the point where you can ascii-armor encrypt a file using your own public key, and decrypt it again. |
First, be sure you have gnupg setup to the point where you can ascii-armor encrypt a file using your own public key, and decrypt it again. |
||
− | Then put this into your |
+ | Then put this into your .vimrc (don't duplicate the 'if has("autocmd")' part if it is already there): |
<pre> |
<pre> |
||
Line 73: | Line 73: | ||
---- |
---- |
||
− | A small addition - If you type your password wrong, you'll get the "incorrect password" message in the buffer. By adding '2 |
+ | A small addition - If you type your password wrong, you'll get the "incorrect password" message in the buffer. By adding '2> /dev/null' to the 'au BufReadPost *.asc :%!gpg -q -d' line, those error messages won't show up. |
---- |
---- |
||
Line 83: | Line 83: | ||
set nocompatible |
set nocompatible |
||
set nopaste |
set nopaste |
||
− | set pastetoggle= |
+ | set pastetoggle=<f11> |
syn on |
syn on |
||
set runtimepath=~/.vim,/etc/vim,/usr/share/vim/vimfiles |
set runtimepath=~/.vim,/etc/vim,/usr/share/vim/vimfiles |
||
Line 101: | Line 101: | ||
" Switch to binary mode to read the encrypted file |
" Switch to binary mode to read the encrypted file |
||
autocmd BufReadPre,FileReadPre *.asc set bin |
autocmd BufReadPre,FileReadPre *.asc set bin |
||
− | autocmd BufReadPre,FileReadPre *.asc let ch_save = &ch|set ch=2 |
+ | autocmd BufReadPre,FileReadPre *.asc let ch_save = &ch|set ch=2 |
− | autocmd BufReadPost,FileReadPost *.asc '[,']!sh -c "gpg --decrypt 2 |
+ | autocmd BufReadPost,FileReadPost *.asc '[,']!sh -c "gpg --decrypt 2> /dev/null" |
" Switch to normal mode for editing |
" Switch to normal mode for editing |
||
autocmd BufReadPost,FileReadPost *.asc set nobin |
autocmd BufReadPost,FileReadPost *.asc set nobin |
||
− | autocmd BufReadPost,FileReadPost *.asc let &ch = ch_save|unlet ch_save |
+ | autocmd BufReadPost,FileReadPost *.asc let &ch = ch_save|unlet ch_save |
autocmd BufReadPost,FileReadPost *.asc execute ":doautocmd BufReadPost " . expand("%:r") |
autocmd BufReadPost,FileReadPost *.asc execute ":doautocmd BufReadPost " . expand("%:r") |
||
" Convert all text to encrypted text before writing |
" Convert all text to encrypted text before writing |
||
− | autocmd BufWritePre,FileWritePre *.asc '[,']!sh -c "gpg --default-recipient-self -ae 2 |
+ | autocmd BufWritePre,FileWritePre *.asc '[,']!sh -c "gpg --default-recipient-self -ae 2>/dev/null" |
" Undo the encryption so we are back in the normal text, directly |
" Undo the encryption so we are back in the normal text, directly |
||
" after the file has been written. |
" after the file has been written. |
||
Line 123: | Line 123: | ||
" Switch to binary mode to read the encrypted file |
" Switch to binary mode to read the encrypted file |
||
autocmd BufReadPre,FileReadPre *.gpg set bin |
autocmd BufReadPre,FileReadPre *.gpg set bin |
||
− | autocmd BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2 |
+ | autocmd BufReadPre,FileReadPre *.gpg let ch_save = &ch|set ch=2 |
− | autocmd BufReadPost,FileReadPost *.gpg '[,']!sh -c "gpg --decrypt 2 |
+ | autocmd BufReadPost,FileReadPost *.gpg '[,']!sh -c "gpg --decrypt 2> /dev/null" |
" Switch to normal mode for editing |
" Switch to normal mode for editing |
||
autocmd BufReadPost,FileReadPost *.gpg set nobin |
autocmd BufReadPost,FileReadPost *.gpg set nobin |
||
− | autocmd BufReadPost,FileReadPost *.gpg let &ch = ch_save|unlet ch_save |
+ | autocmd BufReadPost,FileReadPost *.gpg let &ch = ch_save|unlet ch_save |
autocmd BufReadPost,FileReadPost *.gpg execute ":doautocmd BufReadPost " . expand("%:r") |
autocmd BufReadPost,FileReadPost *.gpg execute ":doautocmd BufReadPost " . expand("%:r") |
||
" Convert all text to encrypted text before writing |
" Convert all text to encrypted text before writing |
||
− | autocmd BufWritePre,FileWritePre *.gpg '[,']!sh -c "gpg --default-recipient-self -e 2 |
+ | autocmd BufWritePre,FileWritePre *.gpg '[,']!sh -c "gpg --default-recipient-self -e 2>/dev/null" |
" Undo the encryption so we are back in the normal text, directly |
" Undo the encryption so we are back in the normal text, directly |
||
" after the file has been written. |
" after the file has been written. |