Friday, September 24, 2010

How to write lines from script with both CR/LF

I have the following function that writes a line to a file every time a document is opened taht shows the date, time, and document name. It uses redir and echo to write the lines, which works just fine. However, the lines are terminated with linefeed only. How can I get it to terminate lines with carriage return and linefeed? As it stands, the lines are all run together when the file is opened in notepad. TIA.
 
function! RecordFileOpen()
let record = " (".strftime("%Y/%m/%d %H:%M").") ".expand("%:p")
redir >> C:/vimlog.txt
echo record
redir END
endfunction

autocmd! BufReadPre * exe RecordFileOpen()
 

No comments:

Post a Comment