THE FORMAT
If you use the good old Vi and try to edit an MS-DOS format file, you will
find that each line ends with a ^M character. (^M is <CR>). The automatic
detection avoids this. Suppose you do want to edit the file that way? Then
you need to overrule the format: >
:edit ++ff=unix file.txt
The "++" string is an item that tells Vim that an option name follows, which
overrules the default for this single command. "++ff" is used for
'fileformat'. You could also use "++ff=mac" or "++ff=dos".
This doesn't work for any option, only "++ff" and "++enc" are currently
implemented. The full names "++fileformat" and "++encoding" also work.
CONVERSION
You can use the 'fileformat' option to convert from one file format to
another. Suppose, for example, that you have an MS-DOS file named README.TXT
that you want to convert to Unix format. Start by editing the MS-DOS format
file: >
vim README.TXT
Vim will recognize this as a dos format file. Now change the file format to
Unix: >
:set fileformat=unix
:write
The file is written in Unix format.
==============================================================================
*23.2* Files on the internet
Someone sends you an e-mail message, which refers to a file by its URL. For
example:
You can find the information here: ~
ftp://ftp.vim.org/pub/vim/README ~
You could start a program to download the file, save it on your local disk and
then start Vim to edit it.
There is a much simpler way. Move the cursor to any character of the URL.
Then use this command: >
gf
With a bit of luck, Vim will figure out which program to use for downloading
the file, download it and edit the copy. To open the file in a new window use
CTRL-W f.
If something goes wrong you will get an error message. It's possible that
the URL is wrong, you don't have permission to read it, the network connection
is down, etc. Unfortunately, it's hard to tell the cause of the error. You
might want to try the manual way of downloading the file.
Accessing files over the internet works with the netrw plugin. Currently URLs
with these formats are recognized:
ftp:// uses ftp
rcp:// uses rcp
scp:// uses scp
http:// uses wget (reading only)
Vim doesn't do the communication itself, it relies on the mentioned programs
to be available on your computer. On most Unix systems "ftp" and "rcp" will
be present. "scp" and "wget" might need to be installed.
Vim detects these URLs for each command that starts editing a new file, also
with ":edit" and ":split", for example. Write commands also work, except for
http://.
For more information, also about passwords, see |netrw|.
==============================================================================
*23.3* Binary files
You can edit binary files with Vim. Vim wasn't really made for this, thus
there are a few restrictions. But you can read a file, change a character and
write it back, with the result that only that one character was changed and
the file is identical otherwise.
To make sure that Vim does not