Write an unencrypted range of lines while editing an encrypted file

0

I maintain a daily journal in a Vim-encrypted text file. While editing this journal, I occasionally have need to write sections of this journal to an unencrypted file (such as a script that I then execute externally in another shell).

But when I attempt to execute this script, it is also in Vim-encrypted format, rendering it useless as a script. Is it possible to write a range of lines to an unencrypted file from an encrypted Vim session?

Firstrock

Posted 2012-02-27T18:47:47.900

Reputation: 145

Answers

1

You will probably have to script this in some manner using writefile(). For example, yank the range of lines into register a, then do:

:call writefile(split(@a, "\n"), 'foo')

This will create or overwrite the file named "foo", so you may want to use something like filewritable() first.

See:

:help filewritable()
:help writefile()

Heptite

Posted 2012-02-27T18:47:47.900

Reputation: 16 267