Practical Vim: Edit Text at the Speed of Thought

Practical Vim: Edit Text at the Speed of Thought

by Drew Neil

Paperback

$29.00
View All Available Formats & Editions
Members save with free shipping everyday! 
See details

Overview

Vim is a fast and efficient text editor that will make you a faster and more efficient developer. It's available on almost every OS, and if you master the techniques in this book, you'll never need another text editor. In more than 120 Vim tips, you'll quickly learn the editor's core functionality and tackle your trickiest editing and writing tasks. This beloved bestseller has been revised and updated to Vim 8 and includes three brand-new tips and five fully revised tips.

A highly configurable, cross-platform text editor, Vim is a serious tool for programmers, web developers, and sysadmins who want to raise their game. No other text editor comes close to Vim for speed and efficiency; it runs on almost every system imaginable and supports most coding and markup languages.

Learn how to edit text the "Vim way": complete a series of repetitive changes with The Dot Formula using one keystroke to strike the target, followed by one keystroke to execute the change. Automate complex tasks by recording your keystrokes as a macro. Discover the "very magic" switch that makes Vim's regular expression syntax more like Perl's. Build complex patterns by iterating on your search history. Search inside multiple files, then run Vim's substitute command on the result set for a project-wide search and replace. All without installing a single plugin! Three new tips explain how to run multiple ex commands as a batch, autocomplete sequences of words, and operate on a complete search match.

Practical Vim, Second Edition will show you new ways to work with Vim 8 more efficiently, whether you're a beginner or an intermediate Vim user. All this, without having to touch the mouse.

What You Need:

Vim version 8

Product Details

ISBN-13: 9781680501278
Publisher: The Pragmatic Programmers, LLC
Publication date: 11/07/2015
Pages: 356
Sales rank: 294,923
Product dimensions: 7.50(w) x 9.20(h) x 0.90(d)

About the Author

Drew Neil is a programmer, trainer, and entrepreneur. He runs Studio Nelstrom, which specializes in making educational screencasts. At peertopeer.io he publishes live coding videos; at vimcasts.org he publishes articles and video tutorials about Vim.

Table of Contents

Acknowledgments xi

Foreword xiii

Read Me xv

Read the Forgotten Manual xvii

1 The Vim Way 1

Tip 1 Meet the Dot Command 1

Tip 2 Don't Repeat Yourself 4

Tip 3 Take One Step Back, Then Three Forward 6

Tip 4 Act, Repeat, Reverse 8

Tip 5 Find and Replace by Hand 9

Tip 6 Meet the Dot Formula 11

Part I Modes

2 Normal Mode 15

Tip 7 Pause with Your Brush Off the Page 15

Tip 8 Chunk Your Undos 16

Tip 9 Compose Repeatable Changes 17

Tip 10 Use Counts to Do Simple Arithmetic 20

Tip 11 Don't Count If You Can Repeat 22

Tip 12 Combine and Conquer 24

3 Insert Mode 27

Tip 13 Make Corrections Instantly from Insert Mode 27

Tip 14 Get Back to Normal Mode 28

Tip 15 Paste from a Register Without Leaving Insert Mode 29

Tip 16 Do Back-of-the-Envelope Calculations in Place 31

Tip 17 Insert Unusual Characters by Character Code 32

Tip 18 Insert Unusual Characters by Digraph 33

Tip 19 Overwrite Existing Text with Replace Mode 34

4 Visual Mode 37

Tip 20 Grok Visual Mode 37

Tip 21 Define a Visual Selection 39

Tip 22 Repeat Line-Wise Visual Commands 41

Tip 23 Prefer Operators to Visual Commands Where Possible 43

Tip 24 Edit Tabular Data with Visual-Block Mode 45

Tip 25 Change Columns of Text 47

Tip 26 Append After a Ragged Visual Block 48

5 Command-Line Mode 51

Tip 27 Meet Vim's Command Line 51

Tip 28 Execute a Command on One or More Consecutive Lines 54

Tip 29 Duplicate or Move Lines Using ':t' and ':m' Commands 59

Tip 30 Run Normal Mode Commands Across a Range 61

Tip 31 Repeat the Last Ex Command 63

Tip 32 Tab-Complete Your Ex Commands 65

Tip 33 Insert the Current Word at the Command Prompt 66

Tip 34 Recall Commands from History 68

Tip 35 Run Commands in the Shell 71

Part II Files

6 Manage Multiple Files 77

Tip 36 Track Open Files with the Buffer List 77

Tip 37 Group Buffers into a Collection with the Argument List 80

Tip 38 Manage Hidden Files 83

Tip 39 Divide Your Workspace into Split Windows 85

Tip 40 Organize Your Window Layouts with Tab: Pages 89

7 Open Files and Save Them to Disk 93

Tip 41 Open a File by Its Filepath Using': edit' 93

Tip 42 Open a File by Its Filename Using ':find' 96

Tip 43 Explore the File System with netrw 98

Tip 44 Save Files to Nonexistent Directories 101

Tip 45 Save a File as the Super User 102

Part III Getting Around Faster

8 Navigate Inside Files with Motions 107

Tip 46 Keep Your Fingers on the Home Row 108

Tip 47 Distinguish Between Real Lines and Display Lines 110

Tip 48 Move Word-Wise 112

Tip 49 Find by Character 114

Tip 50 Search to Navigate 118

Tip 51 Trace Your Selection with Precision Text Objects 120

Tip 52 Delete Around, or Change Inside 124

Tip 53 Mark Your Place and Snap Back to It 126

Tip 54 Jump Between Matching Parentheses 127

9 Navigate Between Files with Jumps 131

Tip 55 Traverse the Jump List 131

Tip 56 Traverse the Change List 133

Tip 57 Jump to the Filename Under the Cursor 134

Tip 58 Snap Between Files Using Global Marks 137

Part IV Registers

10 Copy and Paste 141

Tip 59 Delete, Yank, and Put with Vim's Unnamed Register 141

Tip 60 Grok Vim's Registers 144

Tip 61 Replace a Visual Selection with a Register 149

Tip 62 Paste from a Register 151

Tip 63 Interact with the System Clipboard 154

11 Macros 157

Tip 64 Record and Execute a Macro 158

Tip 65 Normalize, Strike, Abort 161

Tip 66 Play Back with a Count 163

Tip 67 Repeat a Change on Contiguous Lines 164

Tip 68 Append Commands to a Macro 168

Tip 69 Act Upon a Collection of Files 169

Tip 70 Evaluate an Iterator to Number Items in a List 174

Tip 71 Edit the Contents of a Macro 176

Part V Patterns

12 Matching Patterns and Literals 183

Tip 72 Tune the Case Sensitivity of Search Patterns 183

Tip 73 Use the \v Pattern Switch for Regex Searches 184

Tip 74 Use the \V Literal Switch for Verbatim Searches 187

Tip 75 Use Parentheses to Capture Submatches 189

Tip 76 Stake the Boundaries of a Word 190

Tip 77 Stake the Boundaries of a Match 192

Tip 78 Escape Problem Characters 193

13 Search 199

Tip 79 Meet the Search Command 199

Tip 80 Highlight Search Matches 201

Tip 81 Preview the First Match Before Execution 202

Tip 82 Count the Matches for the Current Pattern 204

Tip 83 Offset the Cursor to the End of a Search Match 204

Tip 84 Operate on a Complete Search Match 206

Tip 85 Create Complex Patterns by Iterating upon Search History 209

Tip 86 Search for the Current Visual Selection 212

14 Substitution 215

Tip 87 Meet the Substitute Command 216

Tip 88 Find and Replace Every Match in a File 217

Tip 89 Eyeball Each Substitution 216

Tip 90 Reuse the Last Search Pattern 220

Tip 91 Replace with the Contents of a Register 222

Tip 92 Repeat the Previous Substitute Command 224

Tip 93 Rearrange CSV Fields Using Submatches 228

Tip 94 Perform Arithmetic on the Replacement 229

Tip 95 Swap Two or More Words 230

Tip 96 Find and Replace Across Multiple Files 233

15 Global Commands 237

Tip 97 Meet the Global Command 237

Tip 98 Delete Lines Containing a Pattern 238

Tip 99 Collect TODO Items in a Register 240

Tip 100 Alphabetize the Properties of Each Rule in a CSS File 242

16 Index and Navigate Source Code with ctags 249

Tip 101 Meet ctags 249

Tip 102 Configure Vim to Work with ctags 252

Tip 103 Navigate Keyword Definitions with Vim's Tag Navigation Commands 254

17 Compile Code and Navigate Errors with the Quickfix List 259

Tip 104 Compile Code Without Leaving Vim 260

Tip 105 Browse the Quickfix List 262

Tip 106 Recall Results from a Previous Quickfix List 265

Tip 107 Customize the External Compiler 265

18 Search Project-Wide with grep, vimgrep, and Others 269

Tip 108 Call grep Without Leaving Vim 269

Tip 109 Customize the grep Program 271

Tip 110 Grep with Vim's Internal Search Engine 273

19 Dial X for Autocompletion 275

Tip 111 Meet Vim's Keyword Autocompletion 275

Tip 112 Work with the Autocomplete Pop-Up Menu 277

Tip 113 Understand the Source of Keywords 279

Tip 114 Autocomplete Words from the Dictionary 281

Tip 115 Autocomplete Entire Lines 282

Tip 116 Autocomplete Filenames 283

Tip 117 Autocomplete with Context Awareness 285

20 Find and Fix Typos with Vim's Spell Checker 287

Tip 118 Spell Check Your Work 287

Tip 119 Use Alternate Spelling Dictionaries 289

Tip 120 Add Words to the Spell File 290

Tip 121 Fix Spelling Errors from Insert Mode 291

21 Now What? 293

21.1 Keep Practicing! 293

21.2 Make Vim Your Own 293

21.3 Know the Saw, Then Sharpen It 294

A1 Customize Vim to Suit Your Preferences 295

A1.1 Change Vim's Settings on the Fly 295

A1.2 Save Your Configuration in a vimrc File 296

Al 3 Apply Customizations to Certain Types of Files 298

Index 299

Customer Reviews