Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9037317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:13:08+00:00 2026-06-16T09:13:08+00:00

Using vim’s :source command on a vimscript file with dos line endings is giving

  • 0

Using vim’s :source command on a vimscript file with dos line endings is giving me errors that it can’t deal with ^M characters.

The ^M characters are part of dos line endings, but not unix line endings. So it is trying to :source the file using a unix file format.

The thing is, I have :set fileformats=unix,dos setting on. When opening and editing the file (not :source: -ing) there are no line ending problems. Vim sees a file with pure dos line endings and as per fileformats it adjusts itself accordingly.

:help fileformats only gives the barest clue that on dos systems if you have :set fileformats=unix,dos, vim performs an ad-hoc detection of which it should use (and as an irrelevant detail, this :source detection treats mixed line endings differently than than for opening files).

I’m on a modern mac system, how do I get it to :source a dos line ending file?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T09:13:09+00:00Added an answer on June 16, 2026 at 9:13 am

    This is discussed at :h :source_crnl.

    On UNIX systems, which includes Mac OS X, there is no automatic CRLF detection, and an actual CR at the end of a line will may raise an error, e.g. in a mapping. From the help:

    On other systems, Vim expects “:source”ed files to end in a <NL>. These always work. If you are using a file with <CR><NL> <EOL>s (for example, a file made on MS-DOS), all lines will have a trailing <CR>.

    For best compatibility, it is best to have Vim script files always use NL newlines. These will always work everywhere, provided that the first line of the script doesn’t for some reason end in a CR and 'fileformats' is not empty (it isn’t empty by default).

    In short, consider converting your line endings to LF.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that using VIM I can format C++ code just using gg=G Now
Using VIM, it is easy to display line numbers for any given file with:
Using vim with the Rails plugin, can you create a migration file and then
Am using vim and have a large text file that contains some html thrown
I am using vim 7.x I am using alternate file. I have a mapping
When I am editing source files using Vim and other editors, sometimes I get
I am using vim with the fugitive extension . It has a :Gdiff command
Using Vim 6.0. Say I'm editing this file: sdfsdg dfgdfg 34 12 2 4
I'm using Vim to write text that isn't code, just free form writing. To
When I'm using Vim 7.3 to edit a large PHP file (2000 lines), if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.