First, use basic Vim directly on Google.
Second, for installation and configuration of VIM, refer to this classic Tutorial:
Http://blog.csdn.net/wooin/archive/2008/08/28/2844868.aspx
Thanks again to Wu Yin.
Here are my vim configurations and tips for using them. paste them to take notes :)
Configuration from the beginning is troublesome every time, as Wu Yin said. I saved my vimrc and plug-ins,
Put it in the home. Vim folder, compress and store it :). if the system is reinstalled, decompress and run the following
Install script command.
Install Vim in hongmy525 (refer to the install script ):
Note: It is assumed that you are not a root user like me.
1. Create the. Vim folder in the $ home directory;
2. Copy the prepared plug-ins and configuration files (home. Vim/*) to the $ home/. Vim/directory.
3. Connect $ home/. vimrc to $ home/vimrc.
4. Let the root user make two connections./root/. Vim points to $ home/. Vim,
/Root/. vimrc points to $ home/. Vim/vimrc
The Vim version is 7.2 source code compilation and installation. The following is an advanced teaching function supported by VIM.
You need to add the-enable-cscope option when compiling Vim with source code.
Generally, the following plug-ins are installed:
$ Sudo apt-Get install ctags cs.pdf
I used to create index files like this:
$ Ctags-r -- fields = + LS & cscope-rbq
Write this command as a shell script and put it under/usr/bin.
1. Use VIM + ctags
A first, we must create one or more tags files for the original code to be read,
Use the ctags command in shell to create a tags for a single file as follows:
$ Ctags filename. c
To create a tags for all files in the same directory:
$ Ctags-R
In this case, open the source file in the directory where the tags file is located, and VIM will automatically call the tags file.
If the tags file is not in the current directory, use the following command in command mode to set the Tag file.
: Set tag = tag_file_path
However, for me, tags are all under the current directory, so I am used ~ /. Add the following to vimrc:
: Set tags = $ PWD/tags
B. to jump to the definition of a function under vim, use the following command in command mode:
: Tag fuction_name
This command will take you to the definition of the fuction_name function.
This function is very useful and has never been noticed before.
C. In addition, the CTRL +] command uses the words under the current cursor as the Tag Name and jumps directly.
Press Ctrl + T to return to the previous tag. You can add a number before Ctrl + T to jump back.
Number of layers.
D. use Ctrl + GTO display the file name being edited and the row number.
If the source file layout is messy, you can use the command Gg = g to format the entire source file.
2. cscope
Before using cssag, You need to form a database.
A generates the index file:
Cssag options for generating index files:
-R: Search for the code in the subdirectory tree when generating the index file
-B: Only the index file is generated, and the cssag interface is not displayed.
-Q: generate the cssag. In. Out and cssag. Po. out files to speed up the cssag index.
-K: when the index file is generated, the/usr/include directory is not searched.
-I: If the file name for saving the file list is not cs.pdf. Files, add this option
Where to find the source file list. "-" Indicates that the file list is obtained by the standard input.
-I dir: Find the header file in the directory specified by the-I option.
-U: scan all files and regenerate the cross-index file.
-C: Case Insensitive during search
-P path: the path added before the file in the relative path. In this way, you do not need to convert it to your database.
The directory where the file is located can also be used.
If your source code only contains. C and. H files, you can directly use
$ Cs1_rbq
Before using cssag, you need to create a database. You can use cssag-indexer (if multiple
Directory, you can use the-r option). It will generate a file for csprogram. Files in the current directory.
The file contains all the files for generating the index for cssag, because cssag-indexer does not automatically find. cpp,. s
Therefore, use find to generate the cssag. Files file:
$ Find./-name "*. c"-or-name "*. H"-or-name "*. cpp"> cs.pdf. Files
The preceding command lists all. C,. H,. cpp files in the current directory and writes them to the cs.pdf. Files file.
Then use cs1_rbq to generate index reference.
$ Cs1_rbq
General Usage:
$ Find. /-name "*. C "-or-name "*. H "-or-name "*. CPP "-or-name "*. s "| cs1_rbq
B. Then you can use Vim to open a file to browse and edit the code.
The best way to view csflood usage is to input the following in VIM:
: CS Help
Here is a brief explanation:
S: Find the C language symbol, that is, find the place where the function name, Macro, enumerated value, and so on appear
G: Find the locations defined by functions, macros, and enumeration, similar to the functions provided by ctags.
D: Find the function called by this function.
C: Find the function that calls this function.
T: Find the specified string
E: Find the egrep mode, which is equivalent to the egrep function, but the search speed is much faster.
F: Find and open the file, similar to the find function of vim.
I: Find the text that contains this file
For example, the most common query function calls the function func ():
: Cs f c func
Or
: CS find C func
The last two images:
This is automatic completion:
Below is the function parameter prompt:
Some friends discussed case-insensitive:
Case sensitivity is ignored here:
By configuring this, it is basically enough to use Vim for programming or to read the source code. Thank you again ~
My configuration file and installation script are placed on a kernel-compatible Forum. Because files cannot be uploaded here, please download them from the Forum. However, you may need to register a forum account.
Post address:
Http://www.unifiedkernel.com/forum/viewtopic.php? F = 5 & t = 48 & P = 102 # p102