0. Written in front of the nonsense
The development environment is migrated to Ubuntu, and all the tools that are handy with windows are looking for a replacement.
Windows has been using the souce Insight to read the source code, need to find a replacement under Ubuntu.
Look at the Internet, seemingly vim + Ctags + cscope good, install to try O (∩∩) o
1. Installation
In my Ubuntu, these three software are not self-contained, need to manually install, very simple to use the apt-geT command installation is good
$ sudo apt-get install vim
$ sudo apt-get install ctags
$ sudo apt-get install cscope
The following figure:
2. Use
2.1 Index Creation
Before you can search freely, you need to index the root directory where you want to see the source code, which is to execute two commands:
$ ctags-r
$ cscope-indexer-r
2.2 using Ctag in Vim
1 jump to the specified function into Vim, with ": Tag Func_name" Jump to the function Func_name place. Using the tag
command, you can use the TAB key to match the lookup and continue pressing the TAB key to toggle down.
When a function has more than one definition
: Tag
Jumps to the first definition and jumps to the current file precedence
: Tnext
Jump to the first
: TFirst
Skip to Previous Count
: [count]tprevious
Skip to count one after
: [Count]tnext
Skip to the last one
: Tlast
You can also choose from all tagname:
: Tselect tagname
If you want to jump to an identifier that contains a block: "Tag/block" and then use the TAB key to select it. Here '/' is to tell vim
' Block ' is a statement chunk label.
2 Use the CTRL +] shortcut key to jump to the definition of the function identifier where the cursor is located.
3 Use "CTRL + T" to return to the top. If you want to choose from an identifier that starts with Write_: Tselect/^
Write_ here, ' ^ ' denotes the beginning, and, similarly, ' $ ' indicates the end. Multiple identifiers with the same name
2.3 Using Csope in Vim
Well, it looks like it should be called Vim in Csope, the prerequisite is to establish the index (cscope-indexer-r), and then execute the csope command in the source root directory
$ csope , effect as shown below
Several kinds of search methods, random input points to find content, such as I2C, press ENTER, the effect is as follows:
Select the file you want to open, enter the front number to open it in vim, and then use Ctags to jump between functions quickly in Vim ^_^
Above the cscope Two panel toggle: Tab
cscope exit: Ctrl + D
//====================================================
Add the following actions,
Global variables or functions
1 to rest the cursor on a function or variable, "CTRL +]", will jump directly to the place where the function is defined.
2) local variable jump
Press GD to jump to define
Ctrl+o return to position before jump
3 Sometimes use vim to edit the file, accidentally pressed the ctrl+z, that is, debugging to the background work, this time to switch back to this operation: direct input FG. You can switch back.
4 Vim Display line number:
The first is manual display: in vim command line mode, enter: Set Nu
Suppress display: in vim command line mode, enter: Set Nonu
The second is permanent automatic display: We modify a configuration file.
Find the. vimrc file and add the set Nu at the end
5 The Vim interface executes the shell command method
There are several forms of executing shell commands in vim:
1):!command
Do not quit Vim and execute the shell command commands to display the command output in the VIM command area without changing the contents of the currently edited file
For example
:!ls-l
Special to run:!bash to start a bash shell and execute commands without quitting vim
2): R!command
Inserts the result of the shell Command command into the next line of the current row
For example
: R!date to read the system time and insert the next line in the current line.
3): Start line number, end line number!command
Enter the contents of the range specified in the Start and end line numbers into the shell Command command, and replace the result with the contents in the range specified by the start line number and ending line number
For example
: 62,72!sort, sort 62 rows to 72 rows
You can specify only the starting line, for example:!tr [A-z] [a-z], converting 62-line lowercase letters to uppercase letters
The row with the current cursor, in addition to specifying the line extra, can also be used. Means, for example:. !tr [A-z] [a-z], converting the lowercase of the current line to uppercase
4): Starting line number, ending line number W!command
Enter the contents of the range specified by the start and end line numbers as command commands. Does not change the contents of the currently edited file
For example
: 62,72 w!sort to sort 62 rows to 72 rows, but the results of the sorting are not directly exported to the currently edited file, but are displayed in the area where vim knocks the command
Special can be used below.
: The W!bash will execute the contents of line 62nd as Bash command and display the results without changing the contents of the currently edited file
The same:. W!bash to execute the contents of the current line as a bash command
For example, 52 lines of content are ls-l
So input: W!bash is the same effect as executing!ls-l, if you use a shell that is a bash shell
If the input is:!bash, then the 52nd row of the content is ls-l as a command, and the output of the command will replace the contents of the 52nd line, notice the difference.
6 Vim Chinese garbled problem
Need to modify VIM configuration, you can modify/ETC/VIM/VIMRC, you can also modify ~/.VIMRC, add the following: Set Fencs=utf-8,gb18030,ucs-bom,default,latin1 Note that the VIMRC file modification , when modifying the/ETC/VIM/VIMRC file is valid for all users, modifying ~/.VIMRC is only valid for the current user
7)
In the vi editing mode through CTRL+N,CTRL+P, you can realize the word (to check the word part of the characters) of the automatic completion and input hint function.
8) VI History command
Q: Go to command history editor.
Similarly, q/can enter the search history editor.
Note that if you follow the other letters after Q, you enter the command record.
You can edit a command like an edit buffer, and then enter the execution. You
can also exit history editing with Ctrl-c, but the history edit window does not close, and you can enter it yourself by referring to previous commands.
use: X to close the history edit and discard the editing results, or you can return to the empty command on the equivalent of exiting.
8 Vim in the general mode of input shift+# can achieve fast search