move to gpg ftplugin

Sat, 16 Mar 2019 04:16:50 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Sat, 16 Mar 2019 04:16:50 -0500
changeset 746
63fedee268a7
parent 745
dd23da749523
child 747
a3c2fbf5a623

move to gpg ftplugin

.vim/ftdetect/gpg.vim file | annotate | diff | comparison | revisions
.vim/ftplugin/gpg.vim file | annotate | diff | comparison | revisions
.vimrc file | annotate | diff | comparison | revisions
new file mode 100644
--- /dev/null
+++ b/.vim/ftdetect/gpg.vim
@@ -0,0 +1,1 @@
+autocmd BufRead,BufNewFile *.gpg,*.gpg.wiki  setfiletype gpg
new file mode 100644
--- /dev/null
+++ b/.vim/ftplugin/gpg.vim
@@ -0,0 +1,14 @@
+" based on
+" https://mjj.io/2015/01/27/encrypting-files-with-gpg-and-vim/
+" hacked to work with vimwiki
+" moved to ftplugin
+
+setl noswapfile noundofile nobackup viminfo=
+
+sil %!GPG_TTY=/dev/tty gpg2 --decrypt 2>/dev/null
+
+augroup GPGWriteEncrypted
+  autocmd!
+  autocmd BufWritePre *.gpg,*.gpg.wiki :sil %!GPG_TTY=/dev/tty gpg2 -se -a --default-recipient-self 2>/dev/null
+  autocmd BufWritePost *.gpg,*.gpg.wiki :sil undo
+augroup END
--- a/.vimrc
+++ b/.vimrc
@@ -294,17 +294,6 @@ augroup vimrc
   autocmd BufNewFile,BufRead neomutt-*-\w\+ setf mail
 augroup END
 
-" https://mjj.io/2015/01/27/encrypting-files-with-gpg-and-vim/
-" hacked to work with vimwiki
-augroup encrypted
-  autocmd!
-  autocmd BufReadPre,FileReadPre *.gpg,*.gpg.wiki setl noswapfile noundofile nobackup viminfo=
-  autocmd BufReadPost *.gpg,*.gpg.wiki :sil %!GPG_TTY=/dev/tty gpg2 --decrypt 2> /dev/null
-  autocmd BufWritePre *.gpg,*.gpg.wiki :sil %!GPG_TTY=/dev/tty gpg2 -se -a --default-recipient-self
-  autocmd BufWritePost *.gpg,*.gpg.wiki :sil undo
-augroup END
-"}}}
-
 " Perl type-specific settings  {{{
 let perl_include_pod     = 1
 let perl_sub_signatures  = 1

mercurial