Configuring the C # compilation environment for sublime Text 2 under Linux

Source: Internet
Author: User
Tags sublime text



Everyone crossing don't laugh at me, running on the virtual machine XP XP installed VS2008, and then the computer performance is too poor, so installed sublime used to write code, and then unified by the VS2008 to debug.



Say the right thing.



After installing sublime, you need to install a C # IDE, or you need to get a compile instruction that is similar to Java Javac, which can be compiled at the command line.



Here I installed MonoDevelop, seemingly usable C # compiler is only mono, you crossing if you see a better compiler, you can introduce to me. Project Home



Http://mono-project.com/Main_Page. : http://www.go-mono.com/mono-downloads/download.html



Looks like you can also use Apt-get install MonoDevelop or apt-get install Mono



After installation, enter mono--version on the command line if you can see what is shown, it proves that the installation was successful.


[email protected]:~$ mono --version
Mono JIT compiler version 3.2.8 (Debian 3.2.8+dfsg-4ubuntu1)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:           __thread
    SIGSEGV:       altstack
    Notifications: epoll
    Architecture:  amd64
    Disabled:      none
    Misc:          softdebug 
    LLVM:          supported, not enabled.
    GC:            sgen
[email protected]-pc:~$ 


That's good.



Sublime Text 2 Compiling and running C # has two key commands



"MCS"--the command to compile the *.cs file. Specific instructions for "MCS":: Http://www.mono-project.com/CSharp_Compiler



"Mono"--the command to run the *.exe file generated after compilation.


Configuring the C # Build System for Sublime Text 2


Open Sublime Text 2 and select Tools, build system-> New build System



Then enter the following code


{
    "cmd": ["mcs", "$file"],
    "file_regex": "^(...*?):([0-9]*):?([0-9]*)",
    "selector": "source.cs",
    "encoding": "GBK",
    "variants": 
     [ 
        { 
            "name": "Run", 
            "cmd": ["mono", "${file_path}/${file_base_name}.exe"] 
        } 
     ]  
}


For a description of the parameters of the sublime text 2 Build System, refer to: Http://www.sublimetext.com/docs/build. Click Save, enter the filename c#.sublime-build, and the file will be saved to the Packages/user folder by default. At this point, the work of configuring sublime text 2 is complete.


Test compilation and run environment


wrote a section of code to open the sublime command line



"Ctrl + B" compiled, the hint jumps out. An EXE file with the same name will be generated in the *.cs directory









Ctrl+shift+b "Run, and once again the corresponding prompt.












Here, the environment is ready to be configured.






Code-style plugins are available here by default. Just check it out.






Add comment functionality to C # code



Comment Shortcuts in C # are not valid because the files that define the behavior of comments are missing from the Packages folder . Open packages, add a file named: comments.tmpreferences to the C # folder and enter the following:






Configuring the C # compilation environment for sublime Text 2 under Linux


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.