Practical Vim, 2nd Edition [2nd edition]
9781680501278
Vim is a fast and efficient text editor that will make you a faster and more efficient developer. It's available on
557
52
5MB
English
Pages 356
[335]
Year 2015
Report DMCA / Copyright
DOWNLOAD PDF FILE
Table of contents :
Cover......Page 1
Table of Contents......Page 7
Acknowledgments......Page 13
Foreword to the First Edition......Page 16
How This Book Is Structured......Page 17
Learn to Touch Type, Then Learn Vim......Page 18
Get to Know Vim's Built-in Documentation......Page 19
Notation for Simulating Vim on the Page......Page 20
Use Vim's Factory Settings......Page 24
On the Role of Vim Script......Page 25
On Vim Versions......Page 26
Tip 1. Meet the Dot Command......Page 28
Tip 2. Don't Repeat Yourself......Page 31
Tip 3. Take One Step Back, Then Three Forward......Page 33
Tip 4. Act, Repeat, Reverse......Page 35
Tip 5. Find and Replace by Hand......Page 36
Tip 6. Meet the Dot Formula......Page 38
Part I—Modes......Page 40
2. Normal Mode......Page 41
Tip 8. Chunk Your Undos......Page 42
Tip 9. Compose Repeatable Changes......Page 44
Tip 10. Use Counts to Do Simple Arithmetic......Page 46
Tip 11. Don't Count If You Can Repeat......Page 48
Tip 12. Combine and Conquer......Page 50
Tip 13. Make Corrections Instantly from Insert Mode......Page 54
Tip 14. Get Back to Normal Mode......Page 55
Tip 15. Paste from a Register Without Leaving Insert Mode......Page 56
Tip 16. Do Back-of-the-Envelope Calculations in Place......Page 58
Tip 17. Insert Unusual Characters by Character Code......Page 59
Tip 18. Insert Unusual Characters by Digraph......Page 60
Tip 19. Overwrite Existing Text with Replace Mode......Page 61
Tip 20. Grok Visual Mode......Page 63
Tip 21. Define a Visual Selection......Page 65
Tip 22. Repeat Line-Wise Visual Commands......Page 67
Tip 23. Prefer Operators to Visual Commands Where Possible......Page 69
Tip 24. Edit Tabular Data with Visual-Block Mode......Page 71
Tip 25. Change Columns of Text......Page 73
Tip 26. Append After a Ragged Visual Block......Page 74
Tip 27. Meet Vim's Command Line......Page 76
Tip 28. Execute a Command on One or More Consecutive Lines......Page 79
Tip 29. Duplicate or Move Lines Using ‘:t’ and ‘:m’ Commands......Page 84
Tip 30. Run Normal Mode Commands Across a Range......Page 86
Tip 31. Repeat the Last Ex Command......Page 88
Tip 32. Tab-Complete Your Ex Commands......Page 90
Tip 33. Insert the Current Word at the Command Prompt......Page 91
Tip 34. Recall Commands from History......Page 93
Tip 35. Run Commands in the Shell......Page 95
Tip 36. Run Multiple Ex Commands as a Batch......Page 99
Part II—Files......Page 103
Tip 37. Track Open Files with the Buffer List......Page 104
Tip 38. Group Buffers into a Collection with the Argument List......Page 107
Tip 39. Manage Hidden Files......Page 110
Tip 40. Divide Your Workspace into Split Windows......Page 113
Tip 41. Organize Your Window Layouts with Tab Pages......Page 116
Tip 42. Open a File by Its Filepath Using ‘:edit’......Page 119
Tip 43. Open a File by Its Filename Using ‘:find’......Page 122
Tip 44. Explore the File System with netrw......Page 124
Tip 45. Save Files to Nonexistent Directories......Page 127
Tip 46. Save a File as the Super User......Page 128
Part III—Getting Around Faster......Page 130
8. Navigate Inside Files with Motions......Page 131
Tip 47. Keep Your Fingers on the Home Row......Page 132
Tip 48. Distinguish Between Real Lines and Display Lines......Page 134
Tip 49. Move Word-Wise......Page 136
Tip 50. Find by Character......Page 138
Tip 51. Search to Navigate......Page 142
Tip 52. Trace Your Selection with Precision Text Objects......Page 144
Tip 53. Delete Around, or Change Inside......Page 147
Tip 54. Mark Your Place and Snap Back to It......Page 149
Tip 55. Jump Between Matching Parentheses......Page 150
Tip 56. Traverse the Jump List......Page 153
Tip 57. Traverse the Change List......Page 155
Tip 58. Jump to the Filename Under the Cursor......Page 156
Tip 59. Snap Between Files Using Global Marks......Page 159
Part IV—Registers......Page 161
Tip 60. Delete, Yank, and Put with Vim's Unnamed Register......Page 162
Tip 61. Grok Vim's Registers......Page 165
Tip 62. Replace a Visual Selection with a Register......Page 170
Tip 63. Paste from a Register......Page 172
Tip 64. Interact with the System Clipboard......Page 175
11. Macros......Page 178
Tip 65. Record and Execute a Macro......Page 179
Tip 66. Normalize, Strike, Abort......Page 182
Tip 67. Play Back with a Count......Page 183
Tip 68. Repeat a Change on Contiguous Lines......Page 185
Tip 69. Append Commands to a Macro......Page 189
Tip 70. Act Upon a Collection of Files......Page 190
Tip 71. Evaluate an Iterator to Number Items in a List......Page 194
Tip 72. Edit the Contents of a Macro......Page 197
Part V—Patterns......Page 200
12. Matching Patterns and Literals......Page 201
Tip 73. Tune the Case Sensitivity of Search Patterns......Page 202
Tip 74. Use the \v Pattern Switch for Regex Searches......Page 203
Tip 75. Use the \V Literal Switch for Verbatim Searches......Page 205
Tip 76. Use Parentheses to Capture Submatches......Page 207
Tip 77. Stake the Boundaries of a Word......Page 209
Tip 78. Stake the Boundaries of a Match......Page 210
Tip 79. Escape Problem Characters......Page 211
Tip 80. Meet the Search Command......Page 216
Tip 81. Highlight Search Matches......Page 219
Tip 82. Preview the First Match Before Execution......Page 220
Tip 83. Offset the Cursor to the End of a Search Match......Page 221
Tip 84. Operate on a Complete Search Match......Page 223
Tip 85. Create Complex Patterns by Iterating upon Search History......Page 226
Tip 86. Count the Matches for the Current Pattern......Page 229
Tip 87. Search for the Current Visual Selection......Page 231
14. Substitution......Page 233
Tip 88. Meet the Substitute Command......Page 234
Tip 89. Find and Replace Every Match in a File......Page 236
Tip 90. Eyeball Each Substitution......Page 237
Tip 91. Reuse the Last Search Pattern......Page 239
Tip 92. Replace with the Contents of a Register......Page 240
Tip 93. Repeat the Previous Substitute Command......Page 243
Tip 94. Rearrange CSV Fields Using Submatches......Page 246
Tip 95. Perform Arithmetic on the Replacement......Page 247
Tip 96. Swap Two or More Words......Page 248
Tip 97. Find and Replace Across Multiple Files......Page 250
Tip 98. Meet the Global Command......Page 254
Tip 99. Delete Lines Containing a Pattern......Page 255
Tip 100. Collect TODO Items in a Register......Page 257
Tip 101. Alphabetize the Properties of Each Rule in a CSS File......Page 259
Part VI—Tools......Page 263
Tip 102. Meet ctags......Page 264
Tip 103. Configure Vim to Work with ctags......Page 267
Tip 104. Navigate Keyword Definitions with Vim's Tag Navigation Commands......Page 269
17. Compile Code and Navigate Errors with the Quickfix List......Page 273
Tip 105. Compile Code Without Leaving Vim......Page 274
Tip 106. Browse the Quickfix List......Page 276
Tip 108. Customize the External Compiler......Page 279
Tip 109. Call grep Without Leaving Vim......Page 283
Tip 110. Customize the grep Program......Page 285
Tip 111. Grep with Vim's Internal Search Engine......Page 287
Tip 112. Meet Vim's Keyword Autocompletion......Page 291
Tip 113. Work with the Autocomplete Pop-Up Menu......Page 293
Tip 114. Understand the Source of Keywords......Page 295
Tip 115. Autocomplete Words from the Dictionary......Page 297
Tip 116. Autocomplete Entire Lines......Page 298
Tip 117. Autocomplete Sequences of Words......Page 299
Tip 118. Autocomplete Filenames......Page 301
Tip 119. Autocomplete with Context Awareness......Page 303
Tip 120. Spell Check Your Work......Page 304
Tip 121. Use Alternate Spelling Dictionaries......Page 306
Tip 122. Add Words to the Spell File......Page 307
Tip 123. Fix Spelling Errors from Insert Mode......Page 308
Make Vim Your Own......Page 310
Know the Saw, Then Sharpen It......Page 311
Change Vim's Settings on the Fly......Page 312
Save Your Configuration in a vimrc File......Page 313
Apply Customizations to Certain Types of Files......Page 315
– SYMBOLS –......Page 316
– B –......Page 317
– C –......Page 318
– D –......Page 319
– F –......Page 320
– H –......Page 321
– L –......Page 322
– M –......Page 323
– P –......Page 324
– S –......Page 325
– V –......Page 327
– W –......Page 328
– Z –......Page 329