The Vim Tutorial and Reference the Vim Tutorial and Reference by Steve Oualline
Total Page:16
File Type:pdf, Size:1020Kb
The Vim Tutorial and Reference The Vim Tutorial and Reference By Steve Oualline vim-1.0.odt (28. Sep. 2007) The Vim Book Page 1 The Vim Tutorial and Reference Table of Contents Introduction..............................................................................................26 Chapter 1:Basic Editing............................................................................28 Chapter 2:Editing a Little Faster..............................................................42 Chapter 3:Searching.................................................................................59 Chapter 4:Text Blocks and Multiple Files.................................................69 Chapter 5:Windows and Tabs....................................................................83 Chapter 6:Basic Visual Mode....................................................................99 Chapter 7:Commands for Programmers.................................................111 Chapter 8:Basic Abbreviations, Keyboard Mapping, and Initialization Files.........................................................................................................148 Chapter 9:Basic Command-Mode Commands.........................................159 Chapter 10:Basic GUI Usage...................................................................168 Chapter 11:Dealing with Text Files.........................................................175 Chapter 12:Automatic Completion.........................................................192 Chapter 13:Autocommands.....................................................................202 Chapter 14:File Recovery and Command-Line Arguments.....................211 Chapter 15:Miscellaneous Commands....................................................226 Chapter 16:Cookbook..............................................................................232 Chapter 17:Topics Not Covered..............................................................247 Chapter 18:Complete Basic Editing........................................................260 Chapter 19:Advanced Searching Using Regular Expressions.................290 Chapter 20:Advanced Text Blocks and Multiple Files.............................309 Chapter 21:All About Windows, Tabs, and Sessions...............................335 Chapter 22:Advanced Visual Mode.........................................................351 Chapter 23:Advanced Commands for Programmers...............................363 Chapter 24:All About Abbreviations and Keyboard Mapping.................418 Chapter 25:Complete Command-Mode (:) Commands...........................427 Chapter 26:Advanced GUI Commands....................................................453 Chapter 27:Expressions and Functions...................................................487 Chapter 28:Customizing the Editor........................................................533 Chapter 29:Language-Dependent Syntax Options..................................563 Chapter 30:How to Write a Syntax File...................................................586 Appendix A: Installing Vim.....................................................................598 Appendix B: The <> Key Names.............................................................605 Appendix C: Normal-Mode Commands...................................................608 Appendix D: Command-Mode Commands...............................................633 Appendix E: Visual-Mode Commands.....................................................734 Appendix F: Insert Mode Commands......................................................738 Appendix G: Option List..........................................................................742 vim-1.0.odt (28. Sep. 2007) The Vim Book Page 2 The Vim Tutorial and Reference Appendix H: Vim License Agreement......................................................770 Appendix I: Basic Vim Quick Reference.................................................772 Appendix J: Vim Quick Reference...........................................................773 vim-1.0.odt (28. Sep. 2007) The Vim Book Page 3 The Vim Tutorial and Reference Detail Table of Contents Introduction.......................................................................................................26 Copyright and License Information...............................................................26 Part I Tutorial...........................................................................................27 Chapter 1:Basic Editing.....................................................................................28 Before You Start.............................................................................................28 Running Vim for the First Time.....................................................................29 The vim Command.....................................................................................29 Modes.........................................................................................................30 Editing for the First Time..............................................................................30 Inserting Text.............................................................................................30 Getting Out of Trouble...............................................................................31 Moving Around...........................................................................................31 Aliases........................................................................................................32 Deleting Characters.......................................................................................33 Undo and Redo...............................................................................................34 Getting Out.................................................................................................35 Discarding Changes...................................................................................35 Other editing Commands...............................................................................36 Inserting Characters at the End of a Line.................................................36 Deleting a Line...........................................................................................36 Opening Up New Lines..............................................................................37 Help................................................................................................................37 Help Language...........................................................................................40 Other Ways to Get Help.............................................................................40 Using a Count to Edit Faster.........................................................................41 The Vim Tutorial............................................................................................41 Summary........................................................................................................41 Chapter 2:Editing a Little Faster.......................................................................42 Word Movement.............................................................................................42 Moving to the Start or End of a Line.............................................................43 Searching Along a Single Line.......................................................................44 Moving to a Specific Line..............................................................................45 Telling Where You Are in a File.....................................................................46 Where Am I?...............................................................................................47 vim-1.0.odt (28. Sep. 2007) The Vim Book Page 4 The Vim Tutorial and Reference Scrolling Up and Down..................................................................................48 Deleting Text..................................................................................................49 Deleting Text Without Visual Mode............................................................49 Where to Put the Count (3dw or d3w).......................................................50 Visual vs. Normal Mode Delete..................................................................51 Changing Text................................................................................................51 The . Command..............................................................................................53 Joining Lines..................................................................................................53 Replacing Characters....................................................................................54 Changing Case...............................................................................................55 Keyboard Macros...........................................................................................55 Digraphs.........................................................................................................57 Chapter 3:Searching..........................................................................................59 Simple Searches............................................................................................59 Search History...............................................................................................60 History Window..........................................................................................61