1. 让宏宇开心
2. 项目的报告和解释
3. DynaMIT-R 代码深解读
4. 去“张家界的信息”
5. PADS 2012 Report
Wednesday, 11 July 2012
Wednesday, 4 July 2012
Search VIM
1
2.
3.
dd or :d Delete the current line. Again, you don't need to highlight it first.
4.
| Vim command | Action |
| /pattern | Search the file for pattern. |
| n | Scan for next search match in the same direction. |
| N | Scan for next search match but opposite direction. |
2.
| Replace | |
| Vim command | Action |
| :rs/foo/bar/a | Substitute foo with bar. r determines the range and a determines the arguments. |
| The range (r) can be | |
| nothing | Work on current line only. |
| number | Work on the line whose number you give. |
| % | The whole file. |
| Arguments (a) can be | |
| g | Replace all occurrences in the line. Without this, Vim replaces only the first occurrences in each line. |
| i | Ignore case for the search pattern. |
| I | Don't ignore case. |
| c | Confirm each substitution. You can type y to substitute this match, n to skip this match, a to substitute this and all the remaining matches ("Yes to all"), and q to quit substitution. |
| Examples | |
| :452s/foo/bar/ | Replace the first occurrence of the word foo with bar on line number 452. |
| :s/foo/bar/g | Replace every occurrence of the word foo with bar on current line. |
| :%s/foo/bar/g | Replace every occurrence of the word foo with bar in the whole file. |
| :%s/foo/bar/gi | The same as above, but ignore the case of the pattern you want to substitute. This replaces foo, FOO, Foo, and so on. |
| :%s/foo/bar/gc | Confirm every substitution. |
| :%s/foo/bar/c | For each line on the file, replace the first occurrence of foo with bar and confirm every substitution. |
3.
dd or :d Delete the current line. Again, you don't need to highlight it first.
4.
VIM
| :w filename | Save changes to a file. If you don't specify a file name, Vim saves as the file name you were editing. For saving the file under a different name, specify the file name. |
| :q | Quit Vim. If you have unsaved changes, Vim refuses to exit. |
| :q! | Exit Vim without saving changes. |
| :wq | Write the file and exit. |
Sunday, 1 July 2012
Subscribe to:
Comments (Atom)