Skip to content

Code editor

tomdam edited this page Jun 17, 2020 · 1 revision

SPCoder’s code editor uses the Fast Colored TextBox control.

Code editor windows are by default opened in central dock position. You can create new code editor window by clicking the New button on toolstrip menu or File->New button in main menu.

Code editor 1

Languages

Code editor supports formating for several different file types:

  • CSharp
  • HTML
  • Javascript
  • JSON
  • VB
  • XML
  • PHP
  • SQL

Code editor 2

Code execution

You can execute the code in the active code editor by pressing F5 on keybord or by clicking the Execute (F5) button on toolstrip menu.

Important tips:

  • You can execute only part of the code by selecting it. If nothing is selected then all the code from the active code editor will be executed.
  • If an error occurs during the execution of the code, log entry with error details will be made. If the error is related to some specific part of the code (like compilation error), that line will be marked with red color in code editor.
  • Code is executed either on a separate thread (asynchronously) or on the application thread.
    • By default the asynchronous execution is enabled, and the setting for changing that behaviour is located in main menu, Code -> Asynchronous code execution. That means that you can continue working in SPCoder while your code is executing. You can also start executing another part of the code while the first execution is running, but you need to be careful if next execution depends on a value from previous one. It is best to avoid paralel executions if they are not absolutely needed.
    • If you run code synchronously, then, in cases of long running operations, the application would freeze and you wouldn't be able to do anything with it, until the execution finishes.

Code editor 22

Autocomplete

One of the features of code editor is autocomplete. It helps you while typing by suggesting properties and methods of the variable.

Code editor 3

It is important to know that SPCoder recognizes only the variables that are already in Roslyn context.

Useful tip for writing code is that you can execute just the line of code where you declare your variable to be able to use autocomplete on next line:

//if you write the line
var dt = new DataTable();
//and start typing dt. in the next line, SPCoder won't know the type of dt and won't be able to display autocomplete.
//But if you select the previous line with declaration and execute it (var dt = new DataTable();)
//then on the next line it will offer you all the properties and methods of DataTable object and you will be able
//to choose Columns from the list
dt.Columns.Add("col1");

By default SPCoder won't offer the extension methods of a type when showing autocomplete members. If you want to see the extension methods too, you can activate that feature by checking the Code -> Autocomplete - show extension methods checkbox in the main menu.

Code editor 21

File handling controls

SPCoder supports standard file handling features, like New, Open, Save, Save as, Print. It also saves the list of the opened files in settings config file, so the next time you start SPCoder it will try to open the same files that were opened last time before the app was closed.

SPCoder also keeps track of the files you had closed and you can reopen some of them from Recent list (File -> Recent in main menu).

Code editor 6

Code editing controls

SPCoder supports standard code editing features, like Copy, Paste, Cut, Select all, Undo, Redo, Find, Replace, Comment, Uncomment, Clone line.

Example that shows code editing controls: Code editor 7

Example that shows Find/Replace control: Code editor 8

You can also use Paragraph feature to show white characters in your code, and use Word wrap feature to wrap the text (Notice that Paragraph and Word wrap buttons on toolstrip menu are checked in next example).

Code editor 5