Monday, October 1, 2012

Re: vim in an edit pipeline

Currently, my template script creates a temporary .vimrc invoked with -u that sets viminfo= to nothing so viminfo doesn't get saved/used.  I was doing the same with the swap file so no swap is created in this instance.  The BufWriteCmd very well may fit the bill.

The goal is to make this user friendly so people can use it who have only the most rudimentary of 'vi' knowledge and I think BufWriteCmd will fit the bill in this particular case, assuming that 'gpg' can handle being passed the data as it does in a standard pipe as in from the CLI.

As far as :w !cmd  not encrypting the text, this isn't too big of a deal so long as it's not written to disk.  Nothing will withstand someone who has access to read directly from memory and if it gets to that point, I have much bigger issues on hand.

On Mon, Oct 1, 2012 at 1:26 PM, Ben Fritz <fritzophrenic@gmail.com> wrote:
On Monday, October 1, 2012 11:52:26 AM UTC-5, Art Scheel wrote:
> vim can read stdin with 'vim -' but there's currently no way to submit all edited changes to stdout (so far as I can find.)  There are plenty of scripts and plugins that allow this kind of functionality, but they all require a file to be written to disk (even if it's a RAMDISK).
>
> Would it be worth pursuing a patch that would allow a saved file (:wq) to send the newly edited text to 'stdout'?
>
> My particular end goal is to handle the editing of encrypted text files, hence the necessity for the inbound and outbound files to never be written to disk except for the encrypted versions of this file.

I don't think you need a patch for this.

First, Vim allows you to use the :w command to invoke any shell command with stdin taken from the current Vim buffer. So, :%w !encrypt would pass all text in the current buffer to the "encrypt" program on stdin.

Second, Vim allows you to define a BufWriteCmd autocmd, which specifies what Vim should actually do to write a file. So you could use the above method inside an autocmd to make it transparent, if desired.

Finally, Vim has strong "Blowfish" encryption built in. If you want a specific encryption scheme which you already use, this doesn't matter, but if you're only interested in general in being able to use Vim to edit encrypted files, this may be a better solution.

Do these methods meet your needs?

Be aware that Vim's swapfile, viminfo file, backup file, and possibly undo file may all contain unencrypted text. Make sure to turn these off for your encrypted edit. When using Vim's built-in encryption, the swap file and undo file are encrypted with the file so those two can still be used.

:help encryption says that filtering with :!cmd or :w !cmd do not encrypt the text which "may reveal it to others". I'm not sure under what circumstances this can happen.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php



--
Molon Labe
"Come and take them"

"By divine design, fathers are to preside over their families in love and righteousness and are responsible to provide the necessities of life and protection for their families."

"The Marines I have seen around the world have the cleanest bodies, the filthiest minds, the highest morale, and the lowest morals of any group of animals I have ever seen. Thank God for the United States Marine Corps!" -Eleanor Roosevelt

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: