vim手册

2,969 views

Published on

简单的vim工具的手册

Published in: Automotive, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,969
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
15
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

vim手册

  1. 1. 1 __ ___ ___ ____ ____ | | / / / / / | / | | || / / / /__/ / / || / || | || / / / __/ / /| || / /| || | || / / / ___ / / | || / / | || | || / / / / / / / /| || / / /| || | || / / / / / / / / / | ||/ / / | || | || / / / / / / / / / | |/ / / | || | || / / / / / / / / / | / / | || | || / / / / / / / / / | / / | || | ||/ / / / / / / / / | / / | || | |/ / / / / / / / / |__/ / | || | / / / / / / / / __/ | || | / / / / / / / / | || | / / / / / / / / | || |__/ / /__/ / /__/ / |__|| __/ __/ __/ __| Bram Moolenaar ZhaoRuFei<slimzhao@hotmail.com> 7.2 1
  2. 2. 2 Vim Vim Vim Vim Vim Vim Vim 1 Vim notepad, word, edit Vim BUG Vim( vi) Vim Vim 1 Emacs 2
  3. 3. 3 Vim notepad, edit UNIX :help xxx Mission Impossible Vim 1 i18n internationalization Vim the teh Vim script Vim Vim Vim SHELL Vim Vim Vim Vim LTEX A LTEX A email <slimzhao@hotmail.com> 1 " " " " 3
  4. 4. 4 The Vim user manual and reference manual are Copyright (c) 1988-2002 by Bram Moolenaar. This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later. The latest version is presently available at: http://www.opencontent.org/openpub/ People who contribute to the manuals must agree with the above copyright notice. Vim <slimzhao@hotmail.com> 2004/06/08 4
  5. 5. 5 Acrobat Reader 5
  6. 6. 6 0.2 0.20.2 0.1 2 ( ). Acrobat AcrobatReader 5 6 3 4============================== % (<qzhen@flotu.org>) gbk2uni.exe CTex 6
  7. 7. 7 6.3.0 6.3.01. 6.3.0 VIM 6.3, 6.12. 6.3.0 0.2(A) 0.1 0.2 usr 21.txt, usr 22.txt, usr 29.txt, usr 45.txt 4 4(B) shell ex command :au BufRead *.tip setf tip 7 Vim ex command 6 normal mode command Vim normal normal mode command gg=G shell command unix shell windows OS DOS BOX shell command env LANG=de_DE.ISO_8859-1 vim Display 7
  8. 8. 8 6.3.0 Display :!make | &tee /tmp/vim215953.err gcc -g -Wall -o prog main.c sub.c main.c: In function main: main.c:6: too many arguments to function do_sub main.c: At top level: main.c:10: parse error before } make: *** [prog] Error 1 2 returned "main.c" 11L, 111C (3 of 6): too many arguments to function do_sub Hit ENTER or type command to continue List List r Insert o Normal "o" "O" c textwidth code code while i < b { if a { b = c; } } url URL http://www.cl.cam.ac.uk/~mgk25/download/ucs-fonts.tar.gz (C) cmtt computer modern typewriter cmr(computer modern roman) Latex L TEX A cmr cmtt LTEX A A 1 1 <unicell@gmail.com> " " " " " ; " 8
  9. 9. 9 6.3.0(D) URL email mail(E) ‘‘...’’(LTEX A ), ... "..." ’ /hello hi hi(F) CTRL-N, <Esc>(G) BUG 1 / ...(H) PDF HTML HTML bgcolor PDF PDF Tex 2 PL (Public License Piao Liang) windows3. TODO: upquote LTEX package A ’ fancyvrb " " " " . 1 " " " " . 2 PDF 9
  10. 10. 10 6.3.0 --- LTEX A TMD 10
  11. 11. 11 7.0 7.00. 7.0 " " Bram Beta 7.0fBeta 7.0 " " 7.0 release 7.01. List- 50- :Omni--- Vim ( Python )- Vim- Unicode--- grep- zip/tar---- http://groups.yahoo.com/group/vimannounce/message/1592. , , VIM :colorscheme default, |41.1| | , . | .3. , , , . 11
  12. 12. 12 7.1 7.1 7.1 7.0 bugfix bugfix shell command cd $VIM/vim71/doc for i in usr*; do diff ../../vim70/doc/$i $i; done > tmp.txt wc tmp.txt 366 Display1c1< *usr_01.txt* For Vim version 7.1. Last change: 2006 Oct 08---> *usr_01.txt* For Vim version 7.0. Last change: 2006 Apr 24 132 (A) |02.8| ( ) (B) |10.2| ":substitute" p p (C) |12.1| "fourty" "fourteen" fourty (D) |24.3| Omni (E) |41.10| Comments Unix Vim Vim shell 12
  13. 13. 13 7.1 1. 1.5 2. LTEX A LTEX A LTEX A 3. Mail " ... " " ... " 11,300,000 23,600,000 google :-) " " " " 1986 " " " " " ... " " ... " <step by step@263.net> Mail 13
  14. 14. 14 7.1 :-) LTEX A 14
  15. 15. 15 7.2 7.27.2 7.2 7.1 7.1 7.0 bugfix 7.2 | 7.1 | 15
  16. 16. 16 LTEX A LTEX A0. LTEX A <slimzhao@hotmail.com> LTEX A *1*. fancyvrb Verbatim a ba 7.1b 7.12*. fancyvrb Verbatim Verbatim xleftmargin xrightmargin 16
  17. 17. 17 LTEX A3*. CJK " " "s:count" "other.vim" 1 COPY sloppy LTEX A / "s:count" "other.vim"4*. : EMAIL slimzhao@21cn.com " a" CopyRight c LTEX A marvosym MVAt @ MAIL : L TEX Anewcommand{VimMailURL}[1] {textcolor{VimURLColor}{href{mailto:#1}{#1}} email VimMailURL #1 @ MVAt. 1 Vim C/C++/Java "[a-zA-Z ][a-zA-Z0-9 ]*" 17
  18. 18. 18 LTEX A L TEX Anewcommand{VimMailURL}[2]{ texttt{<}textcolor{VimURLColor}{href{mailto:#1@#2} {#1{footnotesizeMVAt}#2}}texttt{>}} Vim VimMailURL{xxx}{yyy.zzz}5. LTEX A 6.3 18
  19. 19. 19 LaTeX LTEX A LTEX A <rice maxwell@163.com> <chunmin.yang@gmail.com> LTEX A TEX/LTEX A PDF LTEX A LTEX A PDF TEX LTEX A LTEX A .zip CTeX 19
  20. 20. 200. <002424@fudan.edu.cn> PDF AcrobatReader Acrobat 7 -> ( CTRL-K) check box RGB (255,255,242).1. <laneast@hotmail.com> HTML Txt HTML LTEX A docbook2. <chunmin.yang@gmail.com> Vim3. <chenbo.liu@gmail.com> PDF j k Acrobat Reader4. (<taker2001@gmail.com>,<chunlinyao@gmail.com>, <chunmin.yang@gmail.com> ) Vim Vim 90% 90% bash : 20
  21. 21. 21 shell commandfor i in usr*; do diff ../../vim70c/doc/$i $i; done > tmp.txtgvim tmp.txt & 7.05. MAIL :<002424@fudan.edu.cn><ankyhe@gmail.com><baikaishiuc@hotmail.com><chenbo.liu@gmail.com><chunlinyao@gmail.com><chunmin.yang@gmail.com><huanlf@gmail.com><KDV367@motorola.com><laneast@hotmail.com><livahu@gmail.com><lsl635@sina.com><maintainer@vim.org><rice maxwell@163.com><ringken@gmail.com><step by step@263.net><taker2001@gmail.com><unicell@gmail.com><xyzguy@126.com><yangxcmail-linux@yahoo.com.cn><zhasm64@gmail.com> sort -f| uniq -i mail6. MAIL 21
  22. 22. 22 00*usr toc.txt* Vim 7.0 . 2006 04 24 VIM --- Bram Moolenaar <slimzhao@hotmail.com> *user-manual*|usr 01.txt||usr 02.txt| Vim|usr 03.txt||usr 04.txt||usr 05.txt| Vim|usr 06.txt||usr 07.txt||usr 08.txt||usr 09.txt| GUI|usr 10.txt||usr 11.txt||usr 12.txt||usr 20.txt||usr 21.txt||usr 22.txt| 22
  23. 23. 23 00|usr 23.txt||usr 24.txt||usr 25.txt||usr 26.txt||usr 27.txt||usr 28.txt||usr 29.txt||usr 30.txt||usr 31.txt| GUI|usr 32.txt| Vim|usr 40.txt||usr 41.txt| Vim|usr 42.txt||usr 43.txt||usr 44.txt||usr 45.txt| Vim|usr 90.txt| Vim|ref-manual.txt| HTML PDF http://vimdoc.sf.net 23
  24. 24. 24 00 Vim|usr 01.txt| |01.1| |01.2| |01.3| Vim |01.4||usr 02.txt| Vim |02.1| Vim |02.2| |02.3| |02.4| |02.5| |02.6| |02.7| |02.8||usr 03.txt| |03.1| Word |03.2| |03.3| |03.4| |03.5| |03.6| |03.7| |03.8| |03.9| |03.10| 24
  25. 25. 25 00|usr 04.txt| |04.1| |04.2| |04.3| |04.4| Visual |04.5| |04.6| |04.7| |04.8| |04.9| |04.10||usr 05.txt| Vim |05.1| vimrc |05.2| vimrc |05.3| |05.4| plugin |05.5| |05.6| |05.7||usr 06.txt| |06.1| |06.2| ? |06.3| |06.4| |06.5| |06.6||usr 07.txt| |07.1| |07.2| 25
  26. 26. 26 00 |07.3| |07.4| |07.5| |07.6| |07.7||usr 08.txt| |08.1| |08.2| |08.3| |08.4| |08.5| |08.6| |08.7| vimdiff |08.8||usr 09.txt| GUI |09.1| GUI |09.2| |09.3| |09.4||usr 10.txt| |10.1| |10.2| |10.3| |10.4| |10.5| |10.6| |10.7| |10.8| |10.9| 26
  27. 27. 27 00|usr 11.txt| |11.1| |11.2| ? |11.3| ? |11.4||usr 12.txt| |12.1| word |12.2| "Last, First" "First Last" |12.3| |12.4| |12.5| 1 |12.6| |12.7| |12.8| word|usr 20.txt| |20.1| |20.2| |20.3| |20.4| |20.5||usr 21.txt| 1 Unix 27
  28. 28. 28 00 |21.1| |21.2| shell |21.3| viminfo |21.4| |21.5| |21.6||usr 22.txt| |22.1| |22.2| |22.3| |22.4||usr 23.txt| |23.1| DOS, Mac Unix |23.2| |23.3| |23.4| |23.5||usr 24.txt| |24.1| |24.2| |24.3| |24.4| |24.5| |24.6| |24.7| |24.8| |24.9| |24.10| Normal 28
  29. 29. 29 00|usr 25.txt| 1 |25.1| |25.2| |25.3| |25.4| |25.5||usr 26.txt| |26.1| Visual |26.2| |26.3| |26.4| shell Vim|usr 27.txt| |27.1| |27.2| |27.3| |27.4| |27.5| |27.6| |27.7| |27.8| |27.9||usr 28.txt| |28.1| ? |28.2| |28.3| |28.4| 1 <unicell@gmail.com> ! 29
  30. 30. 30 00 |28.5| |28.6| |28.7| |28.8| |28.9| |28.10| ?|usr 29.txt| |29.1| tags |29.2| |29.3| |29.4| |29.5||usr 30.txt| |30.1| |30.2| C |30.3| |30.4| |30.5| |30.6||usr 31.txt| GUI |31.1| |31.2| |31.3| |31.4| Vim |31.5||usr 32.txt| 30
  31. 31. 31 00 |32.1| |32.2| |32.3| Vim Vim|usr 40.txt| |40.1| |40.2| |40.3||usr 41.txt| Vim |41.1| |41.2| |41.3| |41.4| |41.5| |41.6| |41.7| |41.8| |41.9| |41.10| |41.11| plugin |41.12| plugin |41.13| plugin |41.14| plugin |41.15| |41.16| Vim|usr 42.txt| 31
  32. 32. 32 00 |42.1| |42.2| |42.3| |42.4||usr 43.txt| |43.1| |43.2||usr 44.txt| |44.1| |44.2| |44.3| |44.4| |44.5| |44.6| |44.7| |44.8| |44.9| |44.10| |44.11| |44.12||usr 45.txt| |45.1| |45.2| |45.3| |45.4| |45.5| 32
  33. 33. 33 00 Vim Vimming|usr 90.txt| Vim |90.1| Unix |90.2| MS-Windows |90.3| |90.4| |90.5| Vim |manual-copyright| vim:tw=78:ts=8:ft=help:norl: 33
  34. 34. 34 01*usr 01.txt* Vim 7.0 . 2008 05 07 VIM --- Bram Moolenaar Vim Vim|01.1||01.2||01.3| Vim|01.4| |usr 02.txt| |usr toc.txt|*01.1* Vim 1. 2. Vim |notation| 1 : 1 Vim HTML <ahref=#somewhere>click here</a> click here "click here" Vim CTRL-] CTRL-] 34
  35. 35. 35 01 ListCTRL-]CTRL-O |bars| number, ":write" CTRL-] CTRL-] ":help" |help.txt|.*01.2* Vim ( GUI ) |usr 90.txt| *not-compatible* Vi Vim Vi vimrc VIM Unix: ex command:!cp -i $VIMRUNTIME/vimrc_example.vim ~/.vimrcMS-DOS, MS-Windows, OS/2: ex command:!copy $VIMRUNTIME/vimrc_example.vim $VIM/_vimrcAmiga: ex command:!copy $VIMRUNTIME/vimrc_example.vim $VIM/.vimrc Vim, compatible 35
  36. 36. 36 01 ex command:set compatible? nocompatible "compatible" ex command:scriptnames compatible |vimrc| |compatible-default| : Vim "evim"(easy vim) Vim Notepad Insert |evim-keys|*01.3* Vim ( !) vimtutor Vim 30 Unix Vim shell commandvimtutor MS-Windows " /Vim" $VIMRUNTIME vimtutor.bat. 36
  37. 37. 37 01 shell commandvimtutor fr Unix , Vim, "gvimtutor" "vimtutor -g" "vimtutor". OpenVMS VIM shell command@ VIM:vimtutor 1. VIM ( ): shell commandvim -u NONE -c e $VIMRUNTIME/tutor/tutor -c w! TUTORCOPY -c q "TUTORCOPY" shell commandvim -u NONE -c e $VIMRUNTIME/tutor/tutor.fr -c w! TUTORCOPY -c q2. Vim shell commandvim -u NONE -c "set nocp" TUTORCOPY Vim happy 3. shell commanddel TUTORCOPY*01.4* *manual-copyright* 37
  38. 38. 38 01 Vim c 1988-2003 by BramMoolenaar " "1.0 http://www.opencontent.org/opl.shtml *frombook* Steve Oualline Vi IMproved - Vim ( New Riders ISBN:0735710015). " " ( Vim 6.0 ) |frombook| Steve Oualline New Riders OPL |iccf| |usr 02.txt| |manual-copyright| vim:tw=78:ts=8:ft=help:norl: 38
  39. 39. 39 02 Vim*usr 02.txt* Vim 7.0 . 2007 02 28 VIM --- Bram Moolenaar Vim 1 --- << >> Vim|02.1| Vim|02.2||02.3||02.4||02.5||02.6||02.7||02.8| |usr 03.txt| |usr 01.txt| |usr toc.txt|*02.1* Vim shell commandgvim file.txt 1 39
  40. 40. 40 02 Vim Vim. UNIX Microsoft Windows, MS-DOS Vim file.txt Display+---------------------------------------+|# ||~ ||~ ||~ ||~ ||"file.txt" [New file] |+---------------------------------------+("#" .) (~) Vim file.txtVIM gvim shell commandvim file.txt xterm xterm MicrosoftWindows MS-DOS gvim*02.2* Vim Normal Insert Normal 40
  41. 41. 41 02 Vim Insert Vim Normal Insert "i" (i Insert) DisplayiA very intelligent turtleFound programming UNIX a hurdle"turtle" <Esc> Insert Normal Vim Display+---------------------------------------+|A very intelligent turtle ||Found programming UNIX a hurdle ||~ ||~ || |+---------------------------------------+ ex command:set showmode ( ) ( ). "i" Vim --INSERT-- Insert 41
  42. 42. 42 02 Vim Display+---------------------------------------+|A very intelligent turtle ||Found programming UNIX a hurdle ||~ ||~ ||-- INSERT -- |+---------------------------------------+ <Esc> Normal 1 "--INSERT--" Vim --- <Esc> Normal ( Normal ) <Esc> Vim 2 Normal*02.3* Normal Listhjkl l right ( ) 1 Normal --NORMAL-- 2 google 42
  43. 43. 43 02 Vim : hjkl h l j k h l j "i" Insert hjkl <Esc> Normal |vimtutor| Hiroshi Iwatani Display Komsomolsk ^ | Huan Ho <--- ---> Los Angeles(Yellow river) | v Java (the island, not the programming language)*02.4* "x". ( xxxx ) xxxxxxx(7 x) "A very " 43
  44. 44. 44 02 Vim Display+---------------------------------------+|intelligent turtle ||Found programming UNIX a hurdle ||~ ||~ || |+---------------------------------------+ DisplayiA young <Esc> i( Insert ) "A young" Insert ( <Esc>) Display+---------------------------------------+|A young intelligent turtle ||Found programming UNIX a hurdle ||~ ||~ || |+---------------------------------------+ "dd" Display+---------------------------------------+|Found programming UNIX a hurdle ||~ ||~ ||~ || |+---------------------------------------+ Vim "J" 44
  45. 45. 45 02 Vim DisplayA young intelligentturtle "J": DisplayA young intelligent turtle*02.5* "u" 1 "dd" "u" A DisplayA young intelligent turtle xxxxxxx "A young" Displayintelligent turtle "u" g Displayg intelligent turtle u Displayng intelligent turtle u 1 ... 45
  46. 46. 46 02 Vim Displayung intelligent turtleoung intelligent turtleyoung intelligent turtle young intelligent turtleA young intelligent turtle : "u" Vim Vi |not-compatible| Vim Vim Vi CTRL-R( ) CTRL-R A Displayyoung intelligent turtle "U" "U" DisplayA very intelligent turtle xxxx veryA intelligent turtle xxxxxx turtleA intelligent "U"A very intelligent turtle "u" "U"A intelligent "U" "u" CTRL-R 46
  47. 47. 47 02 Vim "u" CTRL-R |32.1|*02.6* Vim |Q in| "i" "a" "i" Displayand thats not saying much for the turtle. Displayand thats not saying much for the turtle!!! "x" turtle e normal mode commanda!!!<Esc> e Displayand thats not saying much for the turtle!!! "o" Insert DisplayA very intelligent turtleFound programming UNIX a hurdle 47
  48. 48. 48 02 Vim "o" normal mode commandoThat liked using Vim<Esc> DisplayA very intelligent turtleThat liked using VimFound programming UNIX a hurdle"O" ( O) 9 "kkkkkkkkk" "9k" "a!!!<Esc>" "3a!<Esc>" 3 3 3 "3x"*02.7* Vim "ZZ" Vim. : Vim "ZZ", Vim Vim |07.4| Vim ex command:q! 48
  49. 49. 49 02 Vim 3 (:) q 1 2 (.!) Vim ":q" Vim DisplayE37: No write since last change (use ! to override) Vim, " ". ":e!"*02.8* Vim ex command:help <F1> <F1> ":help" Vim ( ) hljk "ZZ" Vim. ( |help|) 1 Vim 2 :! w! 49
  50. 50. 50 02 Vim CTRL-]( ) ( Vim CTRL-] word 1 CTRL-T( ) CTRL-O( ) *help.txt* "*" ( ). |29.1| ex command:help {subject} "x" ex command:help x ex command:help deleting Vim ex command:help index ( CTRL-A) "CTRL-" ex command:help CTRL-A 1 HTML HTML<a href="http://www.w3.org/2001/HTML">HTML</a> Vim tag Vim 50
  51. 51. 51 02 Vim 1Vim Normal Normal CTRL-H ex command:help CTRL-H Insert "i " CTRL-H ex command:help i_CTRL-H Vim - -t ex command:help -tVim number ex command:help number |help-context| Insert ex command:help i_<Up> DisplayE37: No write since last change (use ! to override) ID 1 Insert Normal 51
  52. 52. 52 02 Vim ex command:help E37 ex command :help ( Vim ). ex command :help usr_toc.txt 1 ex command :help :subject "subject" ex command :help :help ex command :help abc normal "abc" ex command :help CTRL-B normal <C-B> ex command :help i_abc :help i_CTRL-B 1 7.1 user-toc.txt 52
  53. 53. 53 02 Vim ex command :help v_abc :help v_CTRL-B Visual ex command :help c_abc :help c_CTRL-B ex command :help ’subject’ subject ex command :help subject() "subject" ex command :help -subject 1 "-subject" ex command :help +subject "+subject" ex command :help EventName "EventName" 1 " " shell vim Vim 53
  54. 54. 54 02 Vim ex command :help digraphs.txt "digraphs.txt" ex command :help pattern<Tab> "pattern" <Tab> ex command :help pattern<Ctrl-D> "pattern" ex command :helpgrep pattern "pattern" ex command :cn ex command :cprev :cN ex command :cfirst :clast / 54
  55. 55. 55 02 Vim ex command :copen :cclose / <Enter> |usr 03.txt| |manual-copyright| vim:tw=78:ts=8:ft=help:norl: 55
  56. 56. 56 03*usr 03.txt* Vim 7.0 . 2006 06 21 VIM --- Bram Moolenaar Vim |Q lr||03.1| Word|03.2||03.3||03.4||03.5||03.6||03.7||03.8||03.9||03.10| |usr 04.txt| |usr 02.txt| |usr toc.txt|*03.1* Word "w" word Vim "w" word "3w" 3 words 56
  57. 57. 57 03 DisplayThis is a line with example text --->-->->-----------------> w w w 3w word "w" word "b"1 word Display This is a line with example text <----<--<-<---------<--- b b b 2b b "e"2 word 3 . "w" "b" "e" "ge" 4 word : DisplayThis is a line with example text <- <--- -----> ----> ge ge e e word "w" word "w" "l" "b" non-word ".", "-" ")" word Vim word iskeyword WORDs WORD word WORD word 1 backward 2 :end of word 3 "w" word "e" word 4 "e" word word 57
  58. 58. 58 03 Display ge b w e <- <- ---> --->This is-a line, with special/separated/words (and some more). <----- <----- --------------------> -----> gE B W E*03.2* "$" <End> 1 "^" . "0" <Home> Display ^ <------------.....This is a line with example text<----------------- ---------------> 0 $("....." ) "$" "1$" "2$" "0" "0" "0" 2 "^"*03.3* 1 2 "^" 58
  59. 59. 59 03 "fx" x "f" "find" human h "fh" DisplayTo err is human. To really foul up you need a computer.---------->---------------> fh fy "fy" really "3fl" "foul" "l" DisplayTo err is human. To really foul up you need a computer. ---------------------> 3fl 1"F" : DisplayTo err is human. To really foul up you need a computer. <--------------------- Fh"tx" "fx" "t" "To" "Tx": DisplayTo err is human. To really foul up you need a computer. <------------ -------------> Th tn 4 ";" "," 2 4 1 : 2 "Fx" "," 59
  60. 60. 60 03 1*03.4* () %2 "(" ")" 3 ")" "(" : Display % <----->if (a == (b * c) / d) <----------------> % [] {} ( 4 matchpairs ) "%" "%" "(", ")": codeif (a == (b * c) / d)---+----------------> %*03.5* C C++ 1 "fx" x "f" Vim Windows 2 (<qzhen@flotu.org>) 3 4 <> HTML, XML 60
  61. 61. 61 03 Displayprog.c:33: j undeclared (first use in this function) 33 33 "9999k"1 "32j" 32 2 "G" "33G" 33 (|usr 30.txt| :make ) 3 , "G" "gg" "1G" Display | first line of a file ^ | text text text text | | text text text text | gg7G | text text text text | | text text text text | text text text text V text text text text | text text text text | G text text text text | last line of a file V 4 "%" . 5 "50%" . "90%" 6 1 9999 C/C++ Vim 2 G Go 3 Vim 4 : N 5 50% 6 Vim :goto 3 61
  62. 62. 62 03 Display +---------------------------+H --> | text sample text | | sample text | | text sample text | | sample text |M --> | text sample text | | sample text | | text sample text | | sample text |L --> | text sample text | +---------------------------+ "H" Home, "M" Middle, "L" Last.*03.6* 1. CTRL-G ( ruler ): Display"usr_03.txt" line 233 of 650 --35%-- col 45-52 - "col 2-9" 8 9. 1 2. number ex command:set number 1 62
  63. 63. 63 03 1 2 : ex command:set nonumber number "no" Vim 3. ruler Vim ex command:set ruler ruler 3*03.7* CTRL-U CTRL-D 1 " " <xyzguy@126.com> 2 :no boolean 3 Vim set number :set nonumber ruler number |gq| 63
  64. 64. 64 03 Display +----------------+ | some text | | some text | | some text |+---------------+ | some text || some text | CTRL-U --> | || | | 123456 || 123456 | +----------------+| 7890 || | +----------------+| example | CTRL-D --> | 7890 |+---------------+ | | | example | | example | | example | | example | +----------------+ CTRL-E( ) CTRL-Y( ) CTRL-E Extra. ( MS-Windows CTRL-Y ). ( ) CTRL-F 1 2 CTRL-B CTRL-F CTRL-B "j" "zz" 1 Forward 2 Backward 64
  65. 65. 65 03 Display+------------------+ +------------------+| some text | | some text || some text | | some text || some text | | some text || some text | zz --> | line with cursor || some text | | some text || some text | | some text || line with cursor | | some text |+------------------+ +------------------+ 1 2"zt" "zb" |Q sc| scrolloff*03.8* "/string" "include" normal mode command/include 3 "/" Vim : .*[]^%/?~$ "n" #include: 1 "zt" t top z zt Zhuan Tie( ) :-) 2 "b" bottom 3 Vim 65
  66. 66. 66 03 normal mode command/#include "n" #include "n" "3n" 3 "/" 1 2 "?" "/" : normal mode command?word"N" "/" "?" "/" "N" "?" "N" ignorecase ex command:set ignorecase "word" "Word" "WORD" ex command:set noignorecase 1 normal / N N / /text n N / N :a 1 ba 2 ba 3 ba 4 ba 5 ba 6 b normal 1 2/d 3 2 n 4 2 Vim 66
  67. 67. 67 03 3 normal mode command/one/two/three "/" Vim "/three" "three" Vim "/two" "/one" "/o<Up>"1 Vim "/one" ":" WORD word "TheLongFunctionName" "/TheLongFunctionName" Vim word "*" Vim word 2 "#" "*" :"3*" word WORD "/the" Vim "there" "the" 1 <Up> 2 : word ? Visual select, yank, :let @ /=@", n 67
  68. 68. 68 03 normal mode command/the>">"1 word "<" 2 word word "the" normal mode command/<the> "there" "soothe". "*" "#" word word( "g*" "g#" word .) "nr" "nr" "*" "n" ex command:set hlsearch "nr", Vim 3 ex command:set nohlsearch 4 : ex command:nohlsearch 1 <qujianning@gmail.com> > 2 word 0 3 |/%<3l| 4 hlsearch 68
  69. 69. 69 03 hlsearch "n" "N" ex command:set incsearch Vim ex command:set nowrapscan wrapscan 1 Vim Vim |not-compatible| ex command:scriptnames ex command:edit ~/.vimrc Vim ex commandGo:set hlsearch<Esc> 1 <qujianning@gmail.com> INTERMEZZO 69
  70. 70. 70 03"G" "o" ":set" <Esc> normal mode commandZZ Vim hlsearch*03.9* Vim |usr 27.txt|. |pattern| ^ 1 6 "include" include "^include" include. $ "was$" was. "x" "the" Displaythe solder holding one of the chips melted and thexxx xxx xxx "/the$" Displaythe solder holding one of the chips melted and the xxx "^the" 1 70
  71. 71. 71 03 Displaythe solder holding one of the chips melted and thexxx "/^the$" "the" "the " . "c.m" 1 c m DisplayWe use a computer that became the cummin winter. xxx xxx xxx "ter." DisplayWe use a computer that became the cummin winter. xxxx xxxx "ter." 2*03.10* "G" Vim Vim normal mode command`` 1 l 71
  72. 72. 72 03 1 ` ` "/" "n" ( ) "fx" "tx" word "w" "e" "j" "k" `` CTRL-O ( O older). CTRL-I ( I O ) 3 normal mode command33G/^TheCTRL-O 2 33 "The" CTRL-O 33 CTRL-O "33G" CTRL-I 33 CTRL-I "/^The" Display | example text ^ | 33G | example text | CTRL-O | CTRL-I | example text | | V line 33 text ^ V | example text | |/^The | example text | CTRL-O | CTRL-I V There you are | V example text 1 ` 1 2 " " 72
  73. 73. 73 03 : CTRL-I <Tab> ":jumps" ">" Vim "ma" "a" a z 26 Vim `{mark}, {mark} normal mode command`a mark( ) mark `mark `mark mark s(start) normal mode commandms e(end) normal mode commandme normal mode commands e e 73
  74. 74. 74 03 1 2 s e ex command:marks List"[] |usr 04.txt| |manual-copyright| vim:tw=78:ts=8:ft=help:norl: 1 start 2 end 74
  75. 75. 75 04*usr 04.txt* Vim 7.0 . 2006 06 21 VIM --- Bram Moolenaar --- 3 Visual|04.1||04.2||04.3||04.4| Visual|04.5||04.6||04.7||04.8||04.9||04.10| 1 |usr 05.txt| Vim |usr 03.txt| |usr toc.txt|*04.1* 2 "x" "4x" 4 "dw" word "w" word "d" 75
  76. 76. 76 04 "4w" 4 word "d4w" 4 word. DisplayTo err is human. To really foul up you need a computer. ------------------> d4wTo err is human. you need a computer. Vim Vim word "e" word 1 Vim : DisplayTo err is human. you need a computer. --------> d2eTo err is human. a computer. " " 2 " " "$" "d$" " " DisplayTo err is human. a computer. ------------> d$To err is human + "d" "4l" "w" 1 2 exclusive inclusive [0, 5) 0≤x<5 [0, 5] 0≤x≤5 . 76
  77. 77. 77 04*04.2* "c" "d" Insert "cw" word word Insert DisplayTo err is human -------> c2wbe<Esc>To be human "c2wbe<Esc>" Listc2w word( Insert )be<Esc> Normal "human" "cw" "c" d :"cw", "ce" word word Vi Vim 1 "dd" "cc" ( ). "d$" "c$" "d$" "a" Insert 1 : 77
  78. 78. 78 04 + Listx dl( )X dh( )D d$( )C c$( )s cl( )S cc( ) "3dw" "d3w" 3 word "3dw" word 3 "d3w" 3 word "3d2w" word 3 6 word. "r" "cl" "s" "r" <Esc> Normal Displaythere is somerhing grong hererT rt rwThere is something wrong here "r" DisplayThere is something wrong here 5rxThere is something xxxxx here 78
  79. 79. 79 04 "r<Enter>" 1 "4r<Enter>" 4*04.3* "." Vim HTML <B> <B> < "df>" </B> < "." "." ( "df>") < "." Display To <B>generate</B> a table of <B>contentsf< < --->df> > -->f< < --------->. df> --->f< < ------------->. df> --> "." "u" CTRL-R ( "." Normal Displayasdf 123asdf 1234 1 "cwxyz" Normal Displayasdf xyz 1 Displayasdf xyz 1 79
  80. 80. 80 04 Displayasdf xyz4 3 xyz.) "four" "five" List/four<Enter> "four"cwfive<Esc> "five"n "four". "five"n.*04.4* Visual + Visual "v" Visual DisplayThis is an examination sample of visual mode ----------> velllldThis is an example of visual mode "l" "d" <Esc> Visual 80
  81. 81. 81 04 "V" Visual "Vjj" 3 Display +------------------------+ | text more text | >> | more text more text | |selected lines >> | text text text | | Vjj >> | text more | V | more text more | +------------------------+ CTRL-V Visual Displayname Q1 Q2 Q3pierre 123 455 234john 0 90 39steve 392 63 334 "Q2" "Q2" "Q" CTRL-V Visual "3j" 3 "w" word "h" "d" Visual "o" ( o other end ) "o" 4 "o" "O" 81
  82. 82. 82 04 1 "o" "O" Visual Normal Normal*04.5* "d" "x" p ( Vim put) "dd" "p" Displaya line a line a lineline 2 dd line 3 p line 3line 3 line 2 "p" ( word), 2"p" DisplaySome more boring try text to out commands. ----> dwSome more boring text to out commands. --------> welpSome more boring text to try out commands. PUTTING "P" "p" 1 4 2 82
  83. 83. 83 04 "dd" "P" 1 "dw" "P" "p" "P" "dd" "3p" 3 ( ) "the" "teh" Vim "teh" e "xp" "x" e "p" e h Displayteh th the x p*04.6* "u" "p" yanking 2 . "y" 3 "p" Yanking Vim "c" 4 , "y" "yank" "y" "y" "yw" word. "y2w" word: 1 2 term:yanking 3 " " (") 4 change copy 83
  84. 84. 84 04 Displaylet sqr = LongVariable * --------------> y2wlet sqr = LongVariable * plet sqr = LongVariable * LongVariable "yw" word "ye" "yy" "dd" "D" "Y" "y$" Displaya text line yy a text line a text lineline 2 line 2 p line 2last line last line a text line last line*04.7* Vim GUI (gvim) "Edit" "Copy" Visual Edit/Copy 1 Vim . Vim Edit/Paste Normal Insert Visual 1 Copy Normal yank Copy Vim *, y Vim " Vim 84
  85. 85. 85 04 "Cut" "Copy","Cut" "Paste" ( ) Vim GUI "y"(yank) "p"(put) "*( ) normal mode command"*yy normal mode command"*p Vim |09.3| |clipboard|*04.8* "dw" "daw"1 Displaythis is some example text. dawthis is some text. "daw" "d" "aw" "aw" "A Word" "daw" "Delete A Word" Word ( ). 1 Vim Perl There is more than one way to do the samething. <huanlf@gmail.com> PERL Perl Perl perl : perl Perl PERL Perl 85
  86. 86. 86 04 Vim + Visual + + "cis" DisplayHello there. Thisis an example. Justsome text. "is an" "cis" DisplayHello there. Justsome text. "Another line.": DisplayHello there. Another line. Justsome text. "cis" "c" "is" "Inner Sentence" "as"(a sentence) "das". "cis" Visual Visual Visual "v" Visual "as" "as" |text-objects|*04.9* 86

×