Using Vim as a C# editor, facing a few issues - c#

I have a few questions and a few issues using vim as a C# editing environment. Firstly I am new to vim, so it all is a bit of a learning process for me, I would appreciate any advice and guidance you may have to offer. Secondly I am having some issues getting any cs file to compile.
I am using this as my cs.vim compiler:
if exists("current_compiler")
finish
endif
let current_compiler = "cs"
if exists(":CompilerSet") != 2 " older Vim always used :setlocal
command -nargs=* CompilerSet setlocal <args>
endif
CompilerSet errorformat&
CompilerSet errorformat+=%f(%l\\,%v):\ %t%*[^:]:\ %m,
\%trror%*[^:]:\ %m,
\%tarning%*[^:]:\ %m
execute 'CompilerSet makeprg=' . cs#get_net_compiler("csc.exe") . "\\ %
Not sure exactly where I found this. But if I am in a directory with spaces in the dir name I get an error that the file cannot be found to compile. I think I need to tell it to escape the spaces, but how do I do this?
even if I switch back to the original cs.vim compiler file, i get weird issues and it does not appear to compile:
above and beyond that is it possible to work with C# projects in vim and when you compile have it recognize references etc?
EDIT: for clarification, I have and use Visual Studios as my main IDE. I would like to learn to use vim better, so thus I ask these questions.
Thanks!

Personally, I use a combination of Vim and Visual Studio (with VsVim installed) for my day to day C# coding. I do the longer spurts of editing with pure Vim because VsVim, as nice as it is, just isn't the same as the full Vim environment with its ecosystem. Nothing beats Visual Studio for interactive debugging.
To get the compiler, I use the following settings in my vimrc, stolen and transmogrified from some section of the internet:
set errorformat=\ %#%f(%l\\\,%c):\ %m
set makeprg=C:\\windows\\microsoft.net\\framework\\v4.0.30319\\msbuild.exe\ /nologo\ /v:q\ /property:GenerateFullPaths=true
Please note that this integrates MSBuild and so works with the full .sln file--the whole build just works, no need to muck around with individual files. All you have to do to perform a full build is run :make.
While not strictly required, I also like this flag:
set shellcmdflag=\/C
because it ensures that the cmd window closes on its own.

Related

Visual Studio testc, how to get rid of it?

I could have asked this question years ago, but I think it has finally annoyed me enough to ask this question. Many times while I am coding, Visual Studio tries to Intellisense my deal with testc. I know that testc is a snippet for a test class, but it is something I will never use in anything except maybe a test project, and likely not even then. So, how do I prevent this annoyance from ever appearing in my Intellisense options again? Yeah I know... stupid thing to worry about...
On the Tools menu, click Code Snippets Manager.
Select the directory Test.
Click Remove.
Press CTRL + K, CTRL + B. This will bring up the code snippets manager. In the Visual C# directory, you can remove the snippets (testc in your case) that you don't want to include. Note that system generated snippets cannot be removed by this method, although per mojits answer you could remove the entire directory of snippets.
One way around this is to delete the snippet file manually, by finding / deleting its actual file. I am using Visual C# express 2010 right now, and this is the directory they are in for me (you may have to modify slightly, and restart VS for changes to take effect).
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC#\Snippets\1033\Visual C#

Visual Studio Code invisible buttons

So I recently have had an interest in learning C# and so I downloaded Visual Studio Code, assuming that it would be the best place to start. The biggest problem at the moment is that everything looks so empty because buttons are invisible. I can still program and things just fine, it's just hard to know what I'm looking at when half of the UI is missing.
Here is a pic of what I'm explaining:
https://i.gyazo.com/a3f8b0ae48c8fcdc15d92c6ce81e34eb.png
As you can see, the UI buttons on the right aren't visible.. If anyone has experienced this bug and has found a fix for it, that would be great! Thanks guys!
I would suggest trying Visual Studio Community Edition instead of Code. It's also free and includes a lot more functionality.
Martins answer is not targeting the original question, so I suggest to remove it. You are seeing invisible icons because of an issue in VS Code that we noticed on some Windows installations. We use SVG icons and sometimes the Windows registry is not having a correct entry for their file type. The fix is documented on our FAQ page (https://code.visualstudio.com/Docs/FAQ):
Open an Administrator Command Prompt.
Type REG ADD HKCR\.svg /f /v "Content Type" /t REG_SZ /d image/svg+xml
Then restart VS Code and things should be good.

Microsoft Visual C# 2010 Express intellisense not working

I tried googling, but I couldn't find a fix.
Before, when writing:
console.writeline();, C# would automatically uppercase it to Console.WriteLine();.
Now, by mistake, I somehow deactivated that function. If I write console.writeline(), it doesn't turn it into Console.WriteLine();. Any ideas?
What your looking for is called: Intellisense
The sole goal of this feature is to allow coding to be more productive, smarter, and easier.
You can renable Intellisense by hitting CTRL + J. That will manually reactivate it. Otherwise you'll need to go to:
Tools
Options
Text Editor
Auto List Member
But one of those should address your issue. Otherwise I might suggest running a repair on Visual Studio or Restoring it back to defaults. Cause by default it is enabled and configured correctly.
A known issue can also come from third-party Add Ons that actually handle such data can cause issues with Intellisense so uninstalling such Add Ons, then defaulting Visual Studio should fix it as well.
Example:
Resharp
Visual Assist X
Just Code
Etc.
Basically the ones that handle code completion, quick coding features.
Here is an article from Microsoft Developer Network.
Hopefully that helps.

How do I get started using Cygwin for C# development?

I'm coming from Linux, and I want to try to learn some C# development.
But I'm partial to the command line and using Vim. Is it easy to set up Cygwin to run the csc compiler from the command line and to edit C# files directly in the console with Vim?
I downloaded SharpDevelop, but I would really like to give console-style C# development a try.
Specifically, how do I set up the PATH (is there an equivalent to .bash_profile?) so that I can run csc and vim from the Windows Console?
I'm running Windows 7.
You should give VsVim a try. With C#, you'll thank yourself for sticking with Visual Studio.
Specifically, how do I set up the PATH (is there an equivalent to .bash_profile?) so that I can run csc and vim from the Windows Console?
Exactly like in linux. The only difference, IIRC, is that you use .bashrc instead of .bash_profile. Edit (or create) the file in your cygwin user's home directory (~/) and write the usual export PATH=$PATH:/path/to/other/bin lines.
http://www.cygwin.com/cygwin-ug-net/setup-env.html
I love VsVim, as suggested by Joel. But you said you want to try without Visual Studio, so here:
vim integrates well with gnu make, and writing makefiles for C# programs is quite simple.
Just be careful about tabs vs spaces, same as on Linux (and like I'm not doing on SO, since getting tabs in HTML code blocks is hard). You'll just need a rule along the lines of:
myapp.exe : mymain.cs myhelpers.cs mydialog.cs
csc.exe /o /out:$# $^
Then from inside vim, you can just use the :make command.
ProcessStartInfo pInfo = new ProcessStartInfo("C:\\Cygwin\\bin\\mintty.exe");
pInfo.Arguments = "-i /Cygwin-Terminal.ico -";
if cygwin is installed on C:\

Long load time in Visual Studio for Large Project

Is there a way to turn off intellisense in Visual Studio 2008? I know about deleting a DLL to turn off intellisense in C++, but that doesn't work for C#. I also know about the preferences but that just turns off the visual display. I want to turn off ALL of intellisense so it does not scan my code at all.
Update 10/14/09: Eric was kind enough to take a look so I sent him some log info. I'll post the resolution here when we get one.
Update: updated title to reflect the changed direction of the thread
Related Question
Turning off Intellisense for a single project in Visual Studio 2008
The guys on the VS team looked at this for me and found a problem with intellisense. Here's their description:
"It looks like both of the files you gave me contain a part of static partial class EntityPropertyDescriptors, and I would guess that all the rest of the 500 files do too. What’s happening is that as we build up our IntelliSense cache, each time we parse one of these files, we see that it has a static class in it, and we decide to see if that static class has any extension methods. In order to look for the extension methods, we look through each method in each part to see if it’s an extension method. This causes us to reparse every file in order to see if the type has any extension methods."
They found a similar problem with VS2010 but are fixing it now. Unfortunately, they are not going to fix it in VS2008, so we are left with the workaround of putting all the partial classes into a single file. They can still be partials, but they must be in the same physical file to get around the problem.
After combining all partial classes into a single file, load time for this problem project when from 30 minutes to about 10 seconds.
Big thanks to Eric Lippert and Kevin Pilch-Bisson for helping me with this.
You need to switch off background compilation.
Here is a HowTo:
http://ira.me.uk/2008/09/01/switch-offon-visual-studio-2008-background-compilation/
Tools -> Options -> Text Editor -> C# -> Advanced -> Show live semantic errors
You will still get error underlining, but you must hit the Build button before they show up.
In tools > options > Text Editor > C# there is a Intellisense section which looks like it does what you want.
Have you tried cleaning your solution from all temporary files created by Visual Studio? Sometimes these files could get corrupted, the chances might especially be high if you migrated from VS 2005.
Close your solution, look for all *.suo and *.ncb files and remove/rename them, and then re-open the solution.
Just another thing to make sure: Are there any third-party add-ins installed? Try to start VS in SafeMode using the /SafeMode command-line option.

Categories