1

I've opened the files I want to diff using the following command:

C:\temp\robocopyTasks>vim -c "edit ++enc=ucs-2le" -d C:\temp\robocopyTasks\acl\tasks_temp.txt C:\temp\robocopyTasks\acl\tasks_win.txt

But the file encoding is only set on the first file that is opened, and not on the second one; is there any way to do this from the command line?

4

The edit ++enc=ucs-2le [filename] only applies to the current file; when multiple are passed on the command-line, that's the last opened one. You could open the other with :diffsplit ++enc=ucs-2le file2, but in this case, it's shorter to augment the 'fileencodings' option:

vim --cmd "set fileencodings^=ucs-2le" -d icacls.txt icacls2.txt

This allows you to keep the -d argument for diff mode, and avoids duplication of the encoding name.

0

You can apply a command to all buffers by using bufdo

vim -c "bufdo edit ++enc=ucs-2le" -d a.txt b.txt
  • That just causes unnecessary buffer reloads; better open the files with the right encoding from the start. – Ingo Karkat Apr 17 '15 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.