After a long days installation of a new VoIP phone system at the office I am going to make today’s post a brief, but hopefully helpful one. I often use Vim to edit text files, but I also on occasion need to open said text files on a windows machine where nothing but WordPad is available. I have attempted to use Notepad for this task but often times it strips hard returns and tabs from the file making it impossible to read. After editing the file with WordPad you would inevitably save it and then open it again with Vim to make sure that no extra formatting was added. Usually, everything seems to be fine, but looking closely you will discover two things:

1) The file has become tagged as ‘executable’ in the Linux system.


2) The file now shows ‘dos’ as the file format type in Vim.


The solution to the first problem (well, it’s really is more of an annoyance) can be achieved by issuing the following command:

chmod -x

The fact that the file format has now been changed to ‘dos’ can lead to problems down the road (e.g. when writing scripts). You are definitely going to want to ensure that the file format gets changed back to ‘unix’ format before you attempt to run your code on a Unix-like OS, but how?

Here is how you would change the file format from within the Vim editor back to ‘unix’:

:set fileformat=unix

If you  have ever wondered exactly why editing a file with anything other than Notepad in Windows was frowned upon to such a degree by the programming community, now you have the answer (and the solution).

Leave a Reply

Your email address will not be published. Required fields are marked *