Month: October 2008

  • How to convert to/from DOS format in VIM…

    It’s very easy, but also easy to forget how to convert to or from a DOS format file in Unix using “vim” (Vi iMproved), the Open Source “vi”. If the file is in DOS format and you want to convert to Unix, use the command:

    :set ff=unix

    note that “ff” is an abreviation for “fileformat” which you can also use.

    If the file is Unix and you want to write DOS format, use the following command:

    :set ff=dos

    In both examples it is assuming you are ESCaped out of edit mode and the leading “:” is required.

    Note that the difference between the two formats is that:

    • DOS format ends each line with a CRLF (carriage-return line-feed) pair.
    • Unix format ends each line with a simple LF (line feed).

    Neither of these forms should be confused with the C language string delimiter ‘NUL’ which is an ASCII “zero”. That however is an entirely different subject.


  • Where to find the Windows XP “hosts” file

    Just like Unix you can add a static host to the Windows system. On Windows XP the file is usually found in the “intuitive” location here (may change depending on where you loaded Windows):

    C:\Windows\System32\drivers\etc

    This is also where the “lmhosts” file is found.

    The format is in standard ARPANET format. For more information see this Wiki page.

    Be warned though, putting entries in here essentially makes them static and thus if the target IP is changed in the real owner’s DNS, your local host entry may be pointing to the wrong place. That is why this is best avoided unless really necessary.