Size: 669
Comment:
|
Size: 4303
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 18: | Line 18: |
== Vim == * 先看 [http://chinaunix.net/jh/28/194152.html 进行有效编辑的七种习惯] by Bram Moolenaar, the author of vim. * 再看 [http://www-128.ibm.com/developerworks/cn/linux/l-tip-vim1/ Vim 实用技术] at DeveloperWorks. === Edit a file === ==== Move around quickly ==== * If you set the '''incsearch''' option, Vim will show the first match for the pattern, while you are still typing it. This quickly shows a typo in the pattern. * If you set '''hlsearch''' option, Vim will highlight all matches for the pattern with a yellow background. * If you see a specific word and want to search for other occurrences of the same word, use the '''*''' command to grab the word from under the cursor and search for the next one, while '''#''' search for the previous one. * In structured text(C/C++) * '''%''' can jump to many different matching items. It is very useful to check if() and {} constructs are balanced properly. * Use '''[{''' to jump back to the "{" at the start of the current code block, and ''']}''' for '}'. * Use '''gd''' to jump from the use of variable to its local declaration. ==== Don't type it twice ==== * If you want to change one word into another in the whole file, you can use the ''':s'''(substitute) command. * If you want to change one word into another only a few locations, a quick method is to use the '''*''' command to find the next occurrence of the word and use '''cw''' to change the word. Then type '''n''' to find the next word and '''.'''(dot) to repeat the '''cw''' command. * '''CTRL-N''' can auto complete function and variable names. Vim looks up words in the file you are editing, and also in #include'd files. * Vim has a mechanism to record a macro. You type '''qa''' to start recording into register 'a'. Then you type your commands as usual and finally hit '''q''' again to stop recording. When you want to repeat the recorded commands you type '''@a'''. ==== Fix it when it's wrong ==== * It's normal to make errors while typing, this can be corrected with abbreviations: ''':abbr Lunix Linux'''. * The same mechanism can be used to type a long word with just a few characters: ''':abbr pn pinguin'''. * To find errors in your text Vim has a clever hightlighting mechanism. This was actually meant to be used to do syntax hightlighting of programs, but it can catch and highlight errors as well. * A more complex example: English text. === Edit more files === ==== A file seldom comes alone ==== * Tag mechanism works for jumping between files. * Another powerful mechanism is to find all occurrences of a name in a group of files, using the ''':grep''' command. Vim makes a list of all matches, and jumps to the first one. The ''':cn''' command takes you to each next match. * Positions the cursor on the name of the function in your file and type '''[i''': Vim will show a list of all matches for the function name in the included files. * In vim you can split the text erea in several parts to edit different files. * There are more uses of multiple window. The preview-tag mechanism is a very good example. ==== Let's work together ==== * Select some structured text in a list and sort it: '''!sort'''. ==== Text is structured ==== * One of the simpler things is to speed up the edit-compile-fix cycle. Vim has the ''':make''' command, which starts your compilations, catches the errors it produces and lets you jump to the error locations to fix the problems. === Sharpen the saw === ==== Make it a habit ==== * You need to learn new commands and turn them into a habit. |
1. 关于我
个人信息
Jick Nan |
|
邮件 |
|
主页 |
|
Blog |
2. C
2.1. malloc, calloc, free
- 一个严重的错误:释放不是通过调用 malloc, calloc 得到的指针所指向的存储空间。
- 使用已释放空间同样是错误的。
3. Gnu Tools
3.1. Vim
先看 [http://chinaunix.net/jh/28/194152.html 进行有效编辑的七种习惯] by Bram Moolenaar, the author of vim.
再看 [http://www-128.ibm.com/developerworks/cn/linux/l-tip-vim1/ Vim 实用技术] at DeveloperWorks.
3.1.1. Edit a file
3.1.1.1. Move around quickly
If you set the incsearch option, Vim will show the first match for the pattern, while you are still typing it. This quickly shows a typo in the pattern.
If you set hlsearch option, Vim will highlight all matches for the pattern with a yellow background.
If you see a specific word and want to search for other occurrences of the same word, use the * command to grab the word from under the cursor and search for the next one, while # search for the previous one.
- In structured text(C/C++)
% can jump to many different matching items. It is very useful to check if() and {} constructs are balanced properly.
Use [{ to jump back to the "{" at the start of the current code block, and ]} for '}'.
Use gd to jump from the use of variable to its local declaration.
3.1.1.2. Don't type it twice
If you want to change one word into another in the whole file, you can use the :s(substitute) command.
If you want to change one word into another only a few locations, a quick method is to use the * command to find the next occurrence of the word and use cw to change the word. Then type n to find the next word and .(dot) to repeat the cw command.
CTRL-N can auto complete function and variable names. Vim looks up words in the file you are editing, and also in #include'd files.
Vim has a mechanism to record a macro. You type qa to start recording into register 'a'. Then you type your commands as usual and finally hit q again to stop recording. When you want to repeat the recorded commands you type @a.
3.1.1.3. Fix it when it's wrong
It's normal to make errors while typing, this can be corrected with abbreviations: :abbr Lunix Linux.
The same mechanism can be used to type a long word with just a few characters: :abbr pn pinguin.
- To find errors in your text Vim has a clever hightlighting mechanism. This was actually meant to be used to do syntax hightlighting of programs, but it can catch and highlight errors as well.
- A more complex example: English text.
3.1.2. Edit more files
3.1.2.1. A file seldom comes alone
- Tag mechanism works for jumping between files.
Another powerful mechanism is to find all occurrences of a name in a group of files, using the :grep command. Vim makes a list of all matches, and jumps to the first one. The :cn command takes you to each next match.
Positions the cursor on the name of the function in your file and type [i: Vim will show a list of all matches for the function name in the included files.
- In vim you can split the text erea in several parts to edit different files.
- There are more uses of multiple window. The preview-tag mechanism is a very good example.
3.1.2.2. Let's work together
Select some structured text in a list and sort it: !sort.
3.1.2.3. Text is structured
One of the simpler things is to speed up the edit-compile-fix cycle. Vim has the :make command, which starts your compilations, catches the errors it produces and lets you jump to the error locations to fix the problems.
3.1.3. Sharpen the saw
3.1.3.1. Make it a habit
- You need to learn new commands and turn them into a habit.
3.2. CVS
先看 [http://www.chedong.com/tech/cvs_card.html CVS使用手册] by Chedong.
4. 反馈
欢迎大家对我说三道四哪