Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get gvim to play nicely with Visual Studio 2010?

On my last job, they used Visual Studio 2005 (and occasionally Visual Studio 97), and for command line convenience I used vim for editing things like Mercurial version control configuration files like hgrc and .hgignore

However my coworkers soon began to complain that vim would change the encoding of the files, and would cause a message to popup in Visual Studio telling them about the encoding difference.

After that I stopped using vim and just ended up editing the files in Visual Studio.

Are there any changes to vim's configuration I can make so that this does not occur?

I'd use notepad to edit my files but it always puts that pesky .txt extension on the ends of my files.

I'm also aware of solutions like Notepad++, but I just wondered if there was a solution for this in vim.

like image 243
leeand00 Avatar asked Mar 22 '11 18:03

leeand00


3 Answers

If it is because their VS files are being saved as UTF-8 by default and your vim is doing ISO-8859-1 or ASCII, try changing your file encoding:

" Encoding displayed
:set encoding=utf-8

" Encoding written to file.
:set fileencoding=utf-8
like image 91
Michael Berkowski Avatar answered Nov 15 '22 07:11

Michael Berkowski


For new files

:set ff=dos

In the standard setup, vim will preserve the line-ending style of an already existing file.

like image 36
bobbogo Avatar answered Nov 15 '22 07:11

bobbogo


Another option might be to use ViEmu, which is a plugin that provides vi emulation within Visual Studio. Please note that it is not a free plugin, but to me it's worth paying for.

like image 45
Ross Fuhrman Avatar answered Nov 15 '22 08:11

Ross Fuhrman