1

I am using vim to view Spyder's Python comman history. I set to :e +=ff=dos to get rid of ^M at the end of each line. When I switch to another file, then switch back, the fileformat is unix again. Is there anyway to have vim remember the fileformat for the buffer?

  • 1
    try :set hidden – Christian Brabandt Aug 20 at 6:42
  • Thanks, Christian. That works. Care to post it as the answer? – user2153235 Aug 20 at 11:30
  • Pity that this isn't a local setting... – user2153235 Aug 20 at 11:41
  • 1
    this isn't a local setting Use set bufhidden=hide then. – Matt Aug 20 at 12:34
  • Thanks, Matt. Care to post this as the answer? – user2153235 Aug 21 at 19:25
1

Add dos to your fileformats option. If fileformats contains dos and all lines of a file end with <CR><NL> the fileformat option of that file is automatically set to dos.

Addendum: @ChristianBrabandt's comment to try :set hidden might be better if the file in question has mixed end-of-line styles. set fileformats+=dos only works if all lines end with <CR><NL>, while :e ++ff=dos prints a hint [CR missing], but loads the file without showing the ^Ms anyway.

  • Thanks, Jurgen. My fileformats already contains dos. But :set hidden works fine. – user2153235 Aug 20 at 11:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.