A more comprehensive introduction of vim (for example)
Http://www.cnblogs.com/dubing/archive/2011/12/16/2290421.html
Http://blog.csdn.net/sabalol/article/details/3426635
Http://hi.baidu.com/howard1980/blog/item/3399e42668751b0a908f9d5f.html
Previous review
The previous section describes the basic environment configuration of C Programming in linux and the selection of related tools.
But we can use vim for 10 Daniel and 9 Daniel. In linux, do not rely on the graphic interface to play c. Okay, say goodbye to Ide. The command line is the king of c.
In this article, I would like to thank Sun He for his technical support and the loving c-bull.
Vim plug-ins (provided by Sun He) are mostly used in this article at http://www.vim.org.
Pointer string
Since I have never played c since graduation, I have said that pointers are the focus of c. But as an address variable, why not directly operate on the variable itself. At the end of this article, we will announce
Vim configuration file
~ /. Default configuration file of vimrc
~ /. Vim/plugin/directory of users' default script files
~ /. Vim/ftplugin/directory for storing script files of the user's default file type
Programming support provided by vim
Text Information (line number, file name, etc)
Code indent
Syntax highlighting
Quick Positioning
Mark location
Full-text search
Completion
Multi-file editing
Multi-Window editing
Function list
File List
Function jump
Syntax Error
Character Set Encoding
Binary viewing
And so on...
Test vim
Run the vim command as root on the terminal to display the vim homepage.
: R filename reads the content of a file and writes it to the current editor.
Press I to enter the insert mode
After editing: w save
After editing, Press esc to exit insert mode and enter normal mode.
Enter sh to go to shell.
Compile and run
Text Information Configuration
Set nu (written to the configuration file. vimrc) displays the row number.
Ctrl-g (use commands in normal mode) to display the file information and the current line.
Statusline. vim (plug-in) adds the bottom status bar.
Code indent Configuration
Filetype on (written to the configuration file. vimrc) makes vim sensitive to the file type.
Autocmd FileType c, cpp, h: setlocal cindent cinoptions =: 0, g0, t0 (written to the configuration file. vimrc) to set the c indent style. For details, see h cinoptions-values.
Autocmd FileType c, cpp, h: setlocal et sta sw = 4 sts = 4 tabstop = 4 (written to configuration file. vimrc) sets the indentation distance to four spaces.
= (Use commands in normal or visual mode) typographical code according to the indent style.
<(Use commands in visual mode) indent to the left.
> (Use commands in visual mode) indent to the right.
Syntax highlighting
Filetype plugin on (written to the configuration file. vimrc) the syntax highlighting plug-in for various languages has been added to the installed vim. You only need to open the plug-in related file types.
Quick Positioning
Gd (use commands in normal mode) jumps to the local variable definition.
GD (use commands in normal mode) jumps to the global scalar definition.
* (Use commands in normal mode) search for and jump to the word where the cursor is located.
G * (use commands in normal mode) is similar to *, but the search target does not contain the \ <and \> word boundary symbols.
# (Use commands in normal mode) search for and jump to the word where the cursor is located.
G # (use commands in normal mode) function is close to #, but the search target does not contain the \ <and \> word boundary symbols.
Mark location
M {a-zA-Z0-9} (using commands in normal mode) makes a tag at the current position, marking a name that can use any character between a-z or A-Z, such as entering ma, is to mark the current position as. Note that a-z is a single file tag and cannot be used across files, while a A-Z0-9 is a global tag and can be used across files.
'{A-zA-Z0-9} (use command in normal mode) jumps to the tag of this file.
: Marks [{a-zA-z0-9}] (use command in normal mode) to view the content of the specified tag, view all without writing a tag number.
: Delm {a-zA-z0-9} (use command in normal mode) to delete a tag.
Full-text search
: Vimgrep (use commands in normal mode) full-text search. The function is the same as the grep command, but supports multi-file jump location in vim.
Usage: vimgrep Regular Expression file. Files support wildcards. For example, *. c Represents all. c files. If you want to perform recursive search, you can use **/* to search all files.
: Cl list results
: Cc (use command in normal mode) Current result
: Cn (use commands in normal mode) next result
: Cp (use command in normal mode) previous result
: Cw (use commands in normal mode) to re-open the search result window
Multi-file editing
Vim f1 f2 ...... Fn (use commands in shell) to open multiple files.
: E file name (use commands in normal mode) to open a new file in vim.
: Ls (use commands in normal mode) list of all open files.
: Bn (use commands in normal mode) to the next file.
: Bp (using commands in normal mode) to the previous file.
: B # Or ctrl-6 (using commands in normal mode) to the nearest previous file.
Set autowriteall (written to the configuration file. vimrc) If you hate opening a new file every time, vim will require you to save it, you can set Automatic saving.
Multi-Window editing
: Sp file name (command in normal mode) Horizontal Split Window (multi-line window ).
: Vsp file name (command in normal mode) Vertical Split Window (Multi-column window ).
Ctrl-w h (use commands in normal mode) move the cursor to the Left window.
Ctrl-w j (use the command in normal mode) to move the cursor to the next window.
Ctrl-w k (use commands in normal mode) move the cursor to the previous window.
Ctrl-w l (use commands in normal mode) move the cursor to the right window.
Ctrl-w + (use commands in normal mode) the current window size increases.
Ctrl-w-(use the command in normal mode) the current window size becomes smaller.
Ctrl-w o (use commands in normal mode) only displays the current window.
Function list
Taglist. vim () List ins.
Let Tlist_Use_Right_Window = 1 (written to the configuration file. vimrc). If you want to display the list on the right, add this configuration. The default value is left.
: Tlist (use commands in normal mode) to display the function list.
D (used in the taglist window) deletes files from the list.
+ (Used in the taglist window) Expand the file.
-(Used in the taglist window) collapse the file.
= (Used in the taglist window) collapse all files.
X (used in the taglist window) shows or hides the normal window.
File List
NERD_tree.vim (plug-in) Horizontal Split Window (multi-row window ).
Let NERDTreeWinPos = 'right' (written to the configuration file. vimrc). If you want to display the file tree on the right, add this configuration. The default value is left.
: NERDTree (use commands in normal mode) to display the file list.
Function jump
Ctags (software, which must be installed separately) software that generates multilingual tag files.
Ctags-R *. c (use the command in shell) to generate the tag of all. c files in the current path.-R indicates recursion.
: Ta tag or [g] ctrl-] list tags (multiple tags) or jump to tags (single tag ).
Ctrl-t returns the upper level.
: Tags: list tag stacks.
Syntax Error
: Make (use commands in normal mode) executes the external make command, displays all compilation warnings and errors, and can be located in vim.
: Cl list results
: Cc (use command in normal mode) Current result
: Cn (use commands in normal mode) next result
: Cp (use command in normal mode) previous result
: Cw (use commands in normal mode) to re-open the search result window
View binary files (Update Binary files to binary files in view of differences)
: Range! Xxd (use commands in normal mode) converts part of the specified range to the binary file reading mode.
: Range! Xxd-r (use commands in normal mode) converts part of the specified range back to the character reading mode.
Character Set Encoding
Let & termencoding = & encoding
Set fileencodings = UTF-8, gbk, cp936 (written to configuration file. vimrc)
Supports multiple character encoding.
: Set fileencoding (use commands in normal mode) to set the file character encoding.
Supplement
CTRL-P (use the command in insert mode) to jump out of the completion menu.
CTRL-N (after the completion menu is displayed) The next result.
CTRL-P (after the completion menu is displayed) the previous result.
CTRL-y (after the completion menu is displayed) Select the current result.
CTRL-x Ctrl-F (use command in insert mode) file name completion.
The header file contained in ctrl-x Ctrl-I (use the command in insert mode.
CTRL-x Ctrl-] (use the command in insert mode) ctags (described below) symbol completion.
CTRL-x Ctrl-O (use the command in insert mode) omni completion, you need to set the omnifunc variable.
Other Vim commands (refer to VI (Vim) Tutorial)
Open, save, and close a file:
VI filename // open the filename File
: W // save the file
: W vpser.net // save it to the vpser.net File
: Q // exit the editor. If the file has been modified, run the following command:
: Q! // Exit the editor and do not save
: Wq // exit the editor and save the file
Insert text or line:
A // Add text to the right of the current cursor position
I // Add text to the left of the current cursor position
A // Add text at the end of the current row
I // Add text at the beginning of the current line (the beginning of a non-null character)
O // create a new row above the current row
O // create a new row under the current row
R // Replace (overwrite) The current cursor position and subsequent text
J // merge the row where the cursor is located and the next row as one line (still in command mode)
Move the cursor:
Use up, down, left, and right direction keys
Command mode: h to left, j down, k up, l to the right.
Space key to the right, Backspace to the left, Enter to the next line first,-to move to the previous line first.
Delete:
X // Delete the current character
Nx // Delete n characters starting from the cursor
Dd // Delete the current row
Ndd // Delete n rows including the current row down
U // undo the previous operation
U // undo all operations on the current row
Search:
/Vpser // search for a vpser string under the cursor
? Vpser // search for a vpser string from the cursor
N // search down the previous search action
N // search for the previous search action
Jump:
N + // jump n rows down
N-// jump n rows up
NG // jump to the row whose row number is n
G // jump to the bottom of the file
Set row number:
: Set nu // display the row number
: Set nonu // undisplay the row number
Copy:
Yy // copy the current row to the cache, or use "ayy copy," a as the buffer, and a can be replaced with any letter from a to z, you can complete multiple replication tasks.
Nyy // copy the N rows of the current row to the buffer. You can also use "anyy replication," A is the buffer, and a can also be replaced with any letter from A to Z, you can complete multiple replication tasks.
YW // copy the characters starting from the cursor to the end of the word.
Nyw // copy the N words starting from the cursor.
Y ^ // copy the content from the cursor to the beginning of the line.
Y $ // copy the content from the cursor to the end of the row.
P // paste the content in the clipboard after the cursor. If the preceding custom buffer is used, we recommend that you use "AP" for pasting.
P // paste the content in the clipboard before the cursor. If you use the custom buffer above, we recommend that you use "AP for pasting.
Replace:
: S/old/new // replace the old
: S/old/new/g // replace all the old in the row with new
: N, m s/old/new/g // replace all the old values from N to m with new
: % S/old/new/g // replace all old files in the current file with new
Edit Other resources:
: E otherfilename // edit the file named otherfilename.
Modify the file format:
: Set fileformat = UNIX // modify the file to Unix format. For example, ^ m will appear in the text file under Windows in Linux.
Objective answer
C parameters are passed by value. One function of a pointer is to achieve similar reference effects. In addition, you can use a pointer to directly operate the memory!
Sun he explained:
Each thread has a fixed stack size. Generally, the stack of the main thread is usually 8 MB by default, and the memory is referenced by pointers. The stack memory is usually used and the stack is limited, it is also affected by the lifetime. Therefore, there are more scenarios where the heap is used than the stack. Some things have a long lifetime. If more than one function is called, The heap memory is used.
This article is intended to help you.
: Http://www.vim.org/scripts/script.php? Script_id = 1, 273
The "tag list" plug-in is a source code browser plug-in compiled for VIM. It must be supported by ctags. You can list functions, global parameter lists, and macros on the left. (Sorted)
1. Download The taglist.zip file and decompress it to $ home /. in the vim directory, or in the $ home/vimfiles or $ Vim/vimfiles directory, after this step, you should have these two files (the directory structure should be retained)
Plugin/taglist. vim-taglist plug-in file
DOC/taglist.txt-document (HELP) File
2. Go to $ HOME/. vim/doc, $ HOME/vimfiles/doc, or $ VIM/vimfiles/doc.
Directory, run Vim, and run in command line mode ":Helptags. "Command to process the taglist help file. If you do not have this step, you will not be able to get the taglist help prompt
3. If the ctags tool is not in your PATH search PATH, you need to set the Tlist_Ctags_Cmd variable in $ HOME/. vimrc to indicate the ctags PATH.
4. If you are running VIM of the terminal/console version and terminal does not support changing the window width, you need to change the window width at $/HOME /. vimrc sets the variable 'tlist _ inc_winwidth' to 0,
5. Restart vim
6. You can use ":Tlisttoggle"To open/close the taglist window, you can use ":Help taglist"Command to get more information about using the taglist plug-in
Installation and Use of NERDTree
Nerdtree from: Http://www.vim.org/scripts/script.php? Script_id = 1, 1658A. install. 1. After decompression, copy the plugin/nerd_tree.vim file ~ /. Vim/plugin. Copy the DOC/nerd_tree.txt file ~ /. Vim/doc 2. Open vim and load the document. : Helptags ~ /. Vim/doc/nerd_tree.txt For more information, see h nerd_tree.txt. B. It is commonly used. 1. label. 1-1. Open a directory. : Nerdtree ~ /Share/ABC 1-2, mark it. : Bookmark your_mark_name_of_abc 1-3. Open this label. : Nerdtree your_mark_name_of_abc has the same effect as 1-1. 2. Quick help When the cursor is in the directory Workspace of the NERDTree, press? Key. |
Remove highlight
Method 1: nohlsearch
Method 2:/awertgvcxz (find a string that certainly does not exist)
After the highlighted search (: set hlsearch) is set, you can disable the highlighted search permanently through: set nohlsearch.
Display. You can also temporarily disable the highlighted feature by using nohlsearch. The highlighted feature is automatically restored during the next search. From: http://9esuluciano.javaeye.com/blog/137333