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

浪尽此生 提交于 2019-12-10 15:05:08

问题


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.


回答1:


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



回答2:


For new files

:set ff=dos

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




回答3:


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.




回答4:


VSVim is a free extension for VS2010 that provides a fair bit of vim functionality built right in the IDE.

ViEmu is a much more complete implementation that's not free but is worth the money.



来源:https://stackoverflow.com/questions/5395947/how-to-get-gvim-to-play-nicely-with-visual-studio-2010

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!