Hi Peter!

On So, 15 Aug 2010, Peter Hodge wrote:

> I certainly don't want to be making sure ^M is at the end of each
> line, so I have written a command-line script to erase the last
> linebreak and an autocmd to call it when the 'eol' option is off. I
> understand the importance of having a newline at the end of the file,
> but in this circumstance it is more important to not change anything
> unless absolutely necessary.

How about something like this:
fun! WriteFilewithoutEOF(filename)
    let a=getline(1,line('$')-1)
    let b=map(a, 'v:val . nr2char(13)') 
    call extend(b, getline('$', '$'))
    call writefile(b,a:filename, 'b')
endfun

com! -complete=file -nargs=1 WriteFile :call WriteFilewithoutEOF(<q-args>)

You could call this via a BufWriteCmd autocommand.
(I think, this should write DOS like files without an EOF, but please 
verify.)

regards,
Christian
-- 
Letzte Worte eines Informatikers:
  "Ich bleibe hier, bis das Problem gelöst ist."

-- 
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

Reply via email to