Tips for using source insightRelease date: 17:15:16
1 appetizer-basic application 1.1 select beautiful interface to enjoy work
Although it is not possible to get people by appearance, it seems that no one has ever blamed the software for appearance. Si's gorgeous interface is absolutely modern
The aesthetic taste of people in the world. In Si, we can easily define various types of keywords, variables, tokens, functions, macros, comments, and so on as different colors and display methods (positive or italic, bold, or positive
Often, underline, zoom in, etc.), there is always a way for us to identify at a glance what this logo is.
1.1.1 font selection
In Si, styles can be inherited. to fundamentally change the font, you can directly modify the font in the root style,
Because other styles are inherited from this. Select Screen in font options on the options/document Options page
Fonts font to change the font in the root style. The default configuration in Si is verdana font, which is a non-width font. To make the written code look good in various editors
Qi effect. We strongly recommend that you use an equal width font. Courier, new courier, and are all good choices.
1.1.2 color definition
After all, this is a matter of benevolence and wisdom, so there has never been a unified standard. Many people do not like the default settings provided by Si, so we
Change it. On the options/style properties page, you can modify all styles. Select equal sign (=) to inherit the parent
Style, you can also select pick (or on/OFF) to configure a new value. This depends on your personal preferences.
1.1.3 identifier style selection
InColor DefinitionThis configuration can be completed in the same interface.
1.1.4 select background color
Right-click the window in which you want to change the background color (assuming the right-hand mouse is used) and select XXX from the context menu.
Window properties, and then click back in the pop-up window
Color button to modify the background color of the window. For the main source code window of Si, you only need to select the special window color in the context menu to modify the background color.
1.2Properly configured default values work efficiently
1.2.1 use reasonable indentation
I always think that the configuration of this option is the most likely to be recognized. Select
On the options/document Options page, click the auto indent button.
In The indenting window, set auto indent type to smart by default, and select smart indent.
In options, the default indent effect is <PRE> while (1)
{
I
}
</PRE> adjust the indentation manually each time. In fact, you only need to remove the two check options to get <PRE> while (1)
{
I
}
</PRE> Why Not?
1.2.2 show coordinates
Generally, in the lower left corner of the window status bar, the information about the row and column where the current cursor is located is displayed, but I don't think it is obvious. Therefore, we usually configure the following:
On the options/document Options page, select Show line numbers. When show right margin is selected, a right boundary is displayed, reminding us whether the code is too long.
1.3 create convenient shortcuts to work happily
1.3.1 several frequently used shortcut keys
By default, SI has defined many useful shortcut keys:
- F5
Specify a row number to redirect rows. When a compilation error occurs, you can easily locate the error row.
- Shift + F8
Highlight the specified ID to quickly view the usage of the ID.
- CTRL + Click the icon
Jump directly to the ID definition.
- CTRL + F
Search in this file.
- F3
The last query result in this file.
- F4
Next to the search result in this file.
- F7
Open the Browse project symbols window to quickly browse the identity definitions in the project.
- CTRL + m
Create or search for bookmarks so that you can retrieve the bookmarks next time.
1.3.2 custom shortcut
Select Options/key assignments. In the pop-up key assignments window, you can freely add your favorite shortcut keys. We recommend the following shortcut key definitions:
- Edit: Drag line down
Move the cursor down the current row.
- Edit: Drag line up
Move the cursor down the current row.
- Edit: Join lines
The current row and the next row are connected to one row.
1.3.3 more shortcut keys
If you have research on Si's Marco language (which will be introduced below), you can also define more useful shortcuts, for example, add a file header, function header, and comment (The following describes how to implement the Marco language ).
2 tips-search and replace intermediate application 2.1
SI supports multiple search and replacement methods. In addition to the file search mentioned above, it also supports searching within the project scope, searching for directories, and specifying multiple file searches.
2.1.1 search
- Loopup references
One of the most common search methods is to select search/lookup references, press Ctrl +/, or click the r button to search in the pop-up loopup references window.
There are four search methods available in the search method: simple string, regular expression,
Keyword expression and look up reference. Simple
String is the most common search method. You can find any character or character in a file, or even search for it._ Upap | uHowever, when the project is large, the search process is slow.
The regular expression lookup method will be introduced later when we talk about regular expression. Here, we will temporarily press this button.
Keyword expression and look up
The results of the reference query are basically the same, but the display method is slightly different. Both methods use the database pre-created by Si, and the search speed is quite fast. However, this speed is usually only applicable
The identifier has obvious effect. You are strongly advised to search for functions such as function names and variable names.
- Search files
Select search/search files or press Ctrl + Shift + F to search in the pop-up search files window.
Enter the file name or folder in the file name box. Note: When the folder to be queried contains subfolders, you can select include subdirectiories in options to implement recursive search for each layer of files.
- Search Project
Select search/search project and search in the displayed search project window. The operation is almost identical to the loopup references operation. They respectively Save the configuration of the last search.
2.1.2 replacement
- Single file replacement
Select search/replace or press Ctrl + H to search in the displayed Replace window. Check in the Search Project
Select selection to replace only the selected documents. If the confirm check box is selected
Replacements are replaced one by one. Otherwise, all content meeting the replacement conditions will be replaced.
- Multi-file replacement
Select search/replace files or press Ctrl + Shift + H to search in the displayed replace files window. In addition to the new box (the content after replacement), the rest are the same as the search files window. You can refer to the instructions in the search section for operations.
2.2 Column Operations
Although it was said at the beginning that the column operation function of Si is relatively weak, it is not equal to none. Press the Alt key first, then you can use the mouse to select a column, and then you can delete the specified column.
2.3 Anonymous skills
Here are some tips that we can ignore in most cases. But if we know this, sometimes it will improve our work efficiency.
- Smart rename
Select smart rename or press Ctrl + 'in the context menu to bring up the smart rename window. It has powerful functions, but the most convenient way to use it is to change the name of the local variable in the function. The operation only acts inside the function, and the speed is very fast.
- Renumber
CTRL + R will pop up the Renumber window, which is used to handle the order of numbers, such as array subscript. For example, the existing Code <PRE> array [0] = 1;
Array [1] = 2;
Array [2] = 3;</PRE> change to <PRE> array [0] = 0;
Array [1] = 1;
Array [2] = 2;
Array [3] = 3;
</PRE> of course, it can be modified one by one, but the fastest way is inArray [0] = 1;Previously addedArray [0] = 0;Then, select the array subscript, and use the Renumber function to refill the value with 0 as the starting value.
- Edit Condition
Many codes, especially driver codes, have a large number of pre-compiled definitions to support different hardware configurations. When reading such code, the most painful thing is that you cannot simply judge the code branches actually executed by the program. A large number of branches exist at the same time, often confusing our audio and video. For example, for the following code: <PRE> # ifdef dev1
/* Dev1 code */
# Else
/* Execute code from other devices */
# Endif</PRE> if we confirm that we are analyzing the execution status of dev1
5. You can select the edit condition option in the context menu and set the value of dev1 to true in the displayed conditional parsing window.# Ifdef dev1It is equivalent# If 1It is quite commented out.# ElseCode of the branch. If set to flase, comment out# Ifdef dev1Code of the branch.
3. Learn to be lazy-advanced application 4. Regular Expression in Appendix 1-si
Regular Expression 6 is often used in search and replacement. Here we will briefly introduce the Regular Expression of Si.
4.1 wildcard characters
Regular Expression wildcard summary table:
<Table border = "1">
<Tbody>
<Tr>
<TD>Character
</TD> <TD>Matches
</TD> </tr> <tr>
<TD>^(At the beginning of the expression)
</TD> <TD> start part of the row
</TD> </tr> <tr>
<TD>.
</TD> <TD> any single character
</TD> </tr> <tr>
<TD>[ABC]
</TD> <TD> Any individual character that belongs to the set ABC
</TD> </tr> <tr>
<TD>[^ ABC]
</TD> <TD> Any individual character that does not belong to the ABC set
</TD> </tr> <tr>
<TD>*
</TD> <TD> the first character is zero or multiple duplicates.
</TD> </tr> <tr>
<TD>+
</TD> <TD> one or more of the preceding characters are repeated.
</TD> </tr> <tr>
<TD>\ T
</TD> <TD> one Tab character
</TD> </tr> <tr>
<TD>\ S
</TD> <TD> A space character
</TD> </tr> <tr>
<TD>\ W
</TD> <TD> a blank space character (including a Tab character and a space character)
</TD> </tr> <tr>
<TD>$
</TD> <TD> end part of the row </TD> </tr> </tbody> </table>
4.2 group in Expression
When performing the replacement operation, the group will be useful. Each part of the regular expression can be used\(And\)And each item is a group. During replacement, you can extract a specific string from the Matching content by using a group. In a regular expression, each group has a number, from left to right, starting from 1.
For example:ABC \ (xyx \)Match abcxyz. In this case, group 1 contains the XYZ string. When performing the replacement operation, you can enter\ 1To retrieve this string. By extension, you can use\ <Number>To obtain the group<Number>String.
For example\ (ABC \) \ (XYZ \)Replace\ 2 \ 1For abcxyz replacement strings, group 1 contains ABC, group 2 contains xyz, And the content after replacement is defined as group 2 content followed by group 1 content (\ 2 \ 1), So xyzabc is obtained.
For example, we believe that this will increase your interest. For ease of debugging, various forms of mytrace calls are everywhere in the Code <PRE> mytrace ("create parameter list ...");
</PRE> sometimes you want to comment them all out, and sometimes you want to restore them all back. This is a simple example. You can use <PRE> ^ \(. *\)\(/\*\)\(. * mytrace. * \) \ (\ */\) ___ fckpd ___ 6 nbsp ;=>\ 1 \ 3
</PRE> restore them back and use <PRE> ^ \(. * \) \ (mytrace \)\(. * \) ___ fckpd ___ 7 nbsp ;=> \ 1/* \ 2 \ 3 */
</PRE> all of them are commented out.
5 macro language in Appendix 2-si
I always think this is the most interesting part of Si. It is a powerful programming language that can almost implement various functions that may be used in the programming process.
I am not going to introduce how to program the macro language (refer to Si help documentation .), This section only describes how to use compiled programs. For ease of use, I have concentrated these programs in the utils. Em file, which will be discussed below.
This macro file implements some functions that may be used in the encoding process, such as adding a file header, function description (automatically adding a file name, function name, and current date when used), and macro definition, code completion.
Instructions for use:
- Project/open project...
Open the base project (this project is generally in "My Documents/source Insight/projects/base );
- Project/add and remove project files...
Add a macro file (utils. Em );
- Options/menu assignments
Open the menu assignments window, input macro in command, select the macro to be used, and add it to the appropriate menu.
Recommended macros: insfileheader, insfunheader, insheaderdef, insifdef, and autoexpand ).
For autoexpand example, if you enter a switch and the optical mark is behind the switch, run this macro and you will get <PRE> switch (###)
{
Case
Break;
Default:
}
</PRE>
For insfunheader macros, if the following function bodies <PRE> int nopenconfigfile (char * pchmemconfig, char * pchflashconfig,
Int nsize, int nmode)
{
I
}
</PRE> the cursor runs the macro in the function body, <PRE>/********************************* above the function body /**************************** **************************************** **********
* Nopenconfigfile-
* Description :-
*
* Input: N/
* Output: N/
* Returns: N/
*
* Modification history
*--------------------
* 1.00, APR 19,200 7, t357 written.
*--------------------
**************************************** **************************************/
</PRE> the function name and writing date are automatically filled according to the actual situation. You can modify the utils. Em file for the t357 string to the name you need.
6. Appendix 3-recommended formats
People have their own aspirations.