Quick jump between Ctags-vim code

Source: Internet
Author: User

Ctags-vim code Quick Jump 1, description

When using Vim for driver writing and maintenance in a Linux environment, it is often necessary to call a function or macro definition of the Linux kernel, and frequent jumps between the driver and the kernel code are cumbersome, and the Ctags package makes it easy to jump through functions or macro definitions.

2. Configuration method

Suppose: Ctags is already installed in the system.
Example:
In the Linux kernel code linux-3.5 create tags as an example, it is recommended to first compile linux-3.5 kernel code through, because after the Ctags package, then compile or modify the CTAGS environment will be destroyed, need to re-hit ctags; kernel code does not compile and can normally implement the jump between the code.
In the Program Project home directory (the directory where you want to jump between code), such as/home/kernel/linux-3.5/:

# cd /home/kernel/linux-3.5# ctags -R

After running, a tags file is generated in the/HOME/KERNEL/LINUX-3.5/directory.
To set the tags package to global:
Under the Redhat system:

# vim /etc/vimrc

Under the Ubuntu system:

# vim /etc/vim/vimrc

At the end of the VIMRC file, add:

set tags+=/home/kernel/linux-3.5/tags

Note :
You must use "+ =" and cannot have spaces on either side.
No need to restart the computer, just need to turn vim has opened the file and re-open, you can implement the program code with kernel code between the jump.

If you want to implement the multiple program files you write, or a single file in different places within the function of the jump, you can also use Ctags implementation, the same way, for example, as follows:
Suppose: The driver code being written is/home/helloworld/.

# cd /home/helloworld# ctags -R

A tags file is generated under the/home/helloworld/directory.
To set the tags package to global:
Under the Redhat system:

# vim /etc/vimrc

Under the Ubuntu system:

# vim /etc/vim/vimrc

At the end of the VIMRC file, add:

set tags+=/home/helloworld/tags

Also do not need to restart the computer, just need to turn vim has opened the file and re-open, you can implement the program code with kernel code between the jump.

3. How to use

Ctrl +]
Ctrl + O
In the Linux environment under any directory of the program file functions, to achieve jump to the kernel code to view, just to move the VIM cursor to the function name or macro definition name, using the shortcut key "Ctrl +", you can jump to the function in kernel or macro definition of the place to view, There are a number of paths to jump will appear in the vim below a few lines of options, directly enter the number plus return can be used for the corresponding function or macro definition selection; To return to the previous function or macro definition, just use the shortcut key "Ctrl+o" to jump to the last viewed function.

Quick jump between Ctags-vim code

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.