Menu
blog.headdesk.me
blog.headdesk.me

Edit gpg encrypted file with vim

Posted on 2022/12/162022/12/16

Working with encrypted files can be troublesome at times. Thanks to James McCoy, there is a plugin for vim that makes the task so much easier.

Vim supports encryption with the -x switch. At time of writing, blowfish2 symmetric encryption is only encryption available. That means a password needs to be set for every file. I use gpg to encrypt files with asymmetric keys. With the vim-gnupg plugin, I can seamlessly edit encrypted files. Here is how.

Download the plugin from https://www.vim.org/scripts/script.php?script_id=3645. Unzip the file in ~/.vim/pack/vendor/start

wget -O /tmp/vim-gnupg.zip https://www.vim.org/scripts/download_script.php?src_id=27359
unzip -d ~/.vim/pack/vendor/start/ /tmp/vim-gnupg.zip
rm -f /tmp/vim-gnupg.zip

The plugin will be started by vim automatically. To edit an encrypted file, make sure it has an extension of .gpg, .pgp, or .asc. You will be asked to unlock your gpg key if it’s not already loaded in gpg-agent. Then you will be able to edit the file directly. When it’s saved, it will be re-encrypted.

I think that’s awesome.

Loading

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Full text search

Recent Posts

  • Generate secure password
  • AWS Compute Savings Plans
  • AWS Zonal Shift
  • Coffee break…
  • Prevent private key from being committed to git
  • aws (14)
  • coffee (2)
  • headfi (1)
  • linux (9)
  • others (61)
  • security (2)
  • tech (41)
  • terraform (3)
  • wordpress (2)

Loading

apache aws awscli azure backup boot cloud coffee docker ec2 EL8 ElasticBeanstalk espresso featured git kernel lelit linux lvm meltdown MFA nat gateway php power proliant python rdp Redhat RHEL rpm Ryzen scp security smartarray smart switch snapshot spectre tech terraform ubuntu ubuntu upgrade vpn windows wordpress workspace

©2026 blog.headdesk.me | Powered by SuperbThemes