Wiki: Vim Gpg


Note: You are viewing an old revision of this page. View the current version.


Here's an example of some .vimrc commands to add to enable editing of GPG encrypted files.

" Transparent editing of gpg encrypted files.
" By Wouter Hanegraaff <wouter@blub.net>
augroup encrypted
    au!

    " First make sure nothing is written to ~/.viminfo while editing
    " an encrypted file.
    autocmd BufReadPre,FileReadPre      *.gpg set viminfo=
    " We don't want a swap file, as it writes unencrypted data to disk
    autocmd BufReadPre,FileReadPre      *.gpg set noswapfile
    " Switch to binary mode to read the encrypted file
    autocmd BufReadPre,FileReadPre      *.gpg set bin
    autocmd BufReadPre,FileReadPre      *.gpg let ch_save = &ch|set ch=2
    autocmd BufReadPost,FileReadPost    *.gpg '[,']!gpg --decrypt 2> /dev/null
    " Switch to normal mode for editing
    autocmd BufReadPost,FileReadPost    *.gpg set nobin
    autocmd BufReadPost,FileReadPost    *.gpg let &ch = ch_save|unlet ch_save
    autocmd BufReadPost,FileReadPost    *.gpg execute ":doautocmd BufReadPost " . expand("%:r")

    " Convert all text to encrypted text before writing
    autocmd BufWritePre,FileWritePre    *.gpg   '[,']!gpg --default-recipient-self -ae 2>/dev/null
    " Undo the encryption so we are back in the normal text, directly
    " after the file has been written.
    autocmd BufWritePost,FileWritePost    *.gpg   u
augroup END

http://siweiyuan15.51.net/ http://zuche021.51.net/ http://zuche8.51.net/ http://siweiyuan14.51.net/ http://fadianjizu.51.net/ http://sunflow.51.net/ http://siweiyuan13.51.net/ http://zhibanji.51.net/ http://amwaypower.51.net/ http://siweiyuan12.51.net/ http://tiezhixiangji.51.net/ http://diandu123.51.net/ http://www.playseo.com/zuche/ http://siweiyuan11.51.net/ http://www.playseo.com/zuche021/ http://www.paiwei.cn/ http://www.paiwei.cn/add/ http://siweiyuan10.51.net/ http://www.paiwei.cn/fadianji/ http://www.txhf8.com/ http://siweiyuan09.51.net/ http://www.txhf8.com/add/ http://www.txhf8.com/shaibanji/ http://siweiyuan08.51.net/ http://www.txhf8.com/zhibanji/ http://www.sunflow.com.cn/ http://siweiyuan07.51.net/ http://www.sunflow.com.cn/sunflow/ http://www.sunflow.com.cn/gongzuoliu/ http://www.amwaypower.com/addwords.asp http://siweiyuan06.51.net/ http://www.amwaypower.com/amwaypower/ http://www.amwaypower.com/amway/ http://www.amwaypower.com/amway_chanpin/ http://siweiyuan05.51.net/ http://www.amwaypower.com/amway_china/ http://www.amwaypower.com/amway_gongsi/ http://siweiyuan04.51.net/ http://www.amwaypower.com/amway_niucuilai/ http://www.amwaypower.com/amway_zhixiao/ http://siweiyuan03.51.net/ http://www.songshangroup.com/MoSi2_SiC_heating_elements.htm http://usauniversity.51.net/ http://siweiyuan02.51.net/ http://pagerank.51.net/ http://siweiyuan.51.net/ http://bjlvyou.51.net/ http://siweiyuan01.51.net/

http://www.amwaypower.com/keywords/free1.htm http://www.boshilw.com/keywords/free1.htm http://www.dfhb.com/keywords/free1.htm http://www.dxslw.com/keywords/free1.htm http://www.emicn.com/keywords/free1.htm http://www.gfqy.com/keywords/free1.htm http://www.google123.net/keywords/free1.htm http://www.google123.org/keywords/free1.htm http://www.lnhbsb.com/keywords/free1.htm http://www.ly-yufeng.com/keywords/free1.htm http://www.lyzhuguang.com/keywords/free1.htm http://www.lxep.com/keywords/free1.htm http://www.newstyle-w.com/keywords/free1.htm http://www.paiwei.cn/keywords/free1.htm http://www.playseo.com/keywords/free1.htm http://www.saishuo.com/keywords/free1.htm http://www.sh-xinping.com/keywords/free1.htm http://www.shhcy.com/keywords/free1.htm http://www.songshangroup.com/free1.htm http://www.souwho.com/keywords/free1.htm http://www.sunflow.com.cn/keywords/free1.htm http://www.suntront.com.cn/keywords/free1.htm http://www.think-t.com/keywords/free1.htm http://www.txhf8.com/keywords/free1.htm http://www.vita-biotech.com/keywords/free1.htm http://www.writerlw.com/keywords/free1.htm http://www.xinpushihua.com/keywords/free1.htm http://www.xtzn.com/keywords/free1.htm http://www.ycc-zipper.com.cn/keywords/free1.htm http://pagerank.51.net/free1.htm


Sponsored by: Labrat Technology -- Need Consulting Services? Programming, Maintenance, Security, Database Analysis & Design, Hosting -- we do it all!
Copyright 2005 Robert Melton
Send questions and comments to
Last updated March 10th, 2005