我怎样才能保持在内存中的文件编辑过程中? [英] How can I keep a file in memory during editing?

查看:306
本文介绍了我怎样才能保持在内存中的文件编辑过程中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

短版:回声测试| VIM - | grep的好

Short version : echo "testing" | vim - | grep "good"

这不能作为VIM工作不会输出到管道。它说:Vim:警告:输出不是到终端。没有办法做到这一点?跨编辑器支持将是很好了。

This doesn't work as vim won't output to a pipe. It says : "Vim: Warning: Output is not to a terminal". Any way to do this? Cross-editor support would be nice too.

我试过命名管道,但是Vim不会打开。

I've tried named pipes, but vim won't open them.

长版:回声$ PASSW | GPG -q -d --passphrase-FD 0 $文件名| VIM - | 不知何故GPG使用$ PASSW加密并将其存回$文件名。

Long version : echo $passw | gpg -q -d --passphrase-fd 0 $filename | vim - | "somehow gpg encrypt it using $passw and store it back in $filename".

我想编辑GPG加密的文件,但希望不会对磁盘​​解密文件在任何时间。

I'm trying to edit a gpg encrypted file but would like to not have the decrypted file on disk at any time.

完整的脚本是在这里: http://github.com/ptarjan/gpg-加密/树/主

The full script is here : http://github.com/ptarjan/gpg-encrypt/tree/master

推荐答案

您可以只是VIM加密它。

You could just have vim encrypt it for you.

在您保存在vim文件,通过你的GPG加密器过滤的内容:

Before you save the file in vim, filter the content through your gpg encrypter:


    :{range}![!]{filter} [!][arg]   			*:range!*
          Filter {range} lines through the external program
          {filter}.  Vim replaces the optional bangs with the
          latest given command and appends the optional [arg].
          Vim saves the output of the filter command in a
          temporary file and then reads the file into the
          buffer.  Vim uses the 'shellredir' option to redirect
          the filter output to the temporary file.
          However, if the 'shelltemp' option is off then pipes
          are used when possible (on Unix).
          When the 'R' flag is included in 'cpoptions' marks in
          the filtered lines are deleted, unless the
          |:keepmarks| command is used.  Example: >
            :keepmarks '<,'>!sort
    <    		
          When the number of lines after filtering is less than
          before, marks in the missing lines are deleted anyway.
        w 

所以,如果你想通过GPG筛选它(我的猜测标志在这里):

So, if you want to filter it through gpg (I'm guessing at the flags here):

:%!gpg -q -d -p $password
:w $filename

您将需要导出 $密码 $文件名环境变量,以便
如果你想VIM中使用它们VIM可以访问它们。

You'll need to export the $password and $filename environment variables so vim has access to them if you want to use them within vim.

这篇关于我怎样才能保持在内存中的文件编辑过程中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆