Hi cryptoz,

2016-6-9(Thu) 15:53:05 UTC+9 cryptoz:
> I have followed instructions on the Internet to edit gpg encrypted text file 
> transparently. It almost works, but the file format is messed up for gpg 
> files. 
> 
> OS: Windows 10.
> vim version: 7.4.1023 and 7.4.1721 (tried both)
> 
> Problems: 
> 
> Suppose I have a file a.txt. It has only one character in it (say, 'a'). The 
> file has three bytes:
> 
> 00000000: 61 0d 0a
> 
> If I encrypted the file with gpg without armor, the output file has hundreds 
> of binary data. When I opened the gpg file with vim, there is an ^M at the 
> end of the line. 
> 
> The fileformats is set to dos,unix and fileformat (detected) is dos.
> 
> If I use armored file (.asc), there is no issue.
> 
> The script I put in _vimrc to open *.gpg,*.asc files is similar to what I
> got from http://vim.wikia.com/wiki/Encryption
> 
> I understand correctly, the steps are:
> 
> 1. set bin option before read the file.
> 2. read the file into buffer.
> 3. call gpg to decrypt the buffer. 
> 4. set nobin option.
> 
> I am not sure when fileformat is detected during this process. I tried to set 
> fileformat to dos in each step, it did not work. 
> 
> The problem could be the fileformat detection is done in 2. Since it is a 
> binary file, fileformat is set to unix. In step 3, when decrypted text is 
> placed back in buffer, there is ^M at the end of each line because fileformat
> is already set to unix. 
> 
> I would think a better way to handle similar situations is add a user 
> configurable filter to convert the stream read from the file into another 
> format (e.g., decryption, encoding) and another filter one for writing.

Probably, You need to turn off the 'fixeol' option.
:set nofixeol

Please see a document.  (:help 'fixeol')
--
Best regards,
Hirohito Higashi (a.k.a. h_east)

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui