Command line option to open a formatted Mac file in Vim

I have a mac file, I know I can use :e! ++ff=mac :e! ++ff=mac to modify the correct file. I would like to know if there is a command line option that I can pass when I open the file to open it directly with the correct file format.

+7
source share
2 answers

You can do this using the command line, try:

 $ vim -c "set fileformat=mac" 

-c <command> is executed before loading the first file. As jammessan noted, this will only affect the first downloaded file, for subsequent files you will need to change the fileformat for each buffer.

If this does not work, you can also try:

 $ vim -c "e ++ff=mac" 

But it is better to configure this in your .vimrc on this machine:

 set fileformats=mac,unix,dos 

indicates which formats should be used when starting a new buffer. It may also affect the choice of fileformat for existing files.

See help file-formats :help 'fileformat' and :help 'fileformats' .

+8
source

The best solution would be to force Vim to automatically recognize files in this format. You can do this by updating the 'fileformats' option in ~/.vimrc

 set fileformats=unix,dos,mac 

This will force Vim to check all three formats when determining the format in which the file is located.

0
source

All Articles