Share E-Book
Scan to open this page

Scan with your phone to open this page

AuthorArnold Robbins, Elbert Hannah, Linda Lamb

There's nothing that hard-core Unix and Linux users are more fanatical about than their text editor. Editors are the subject of adoration and worship, or of scorn and ridicule, depending upon whether the topic of discussion is your editor or someone else's. vi has been the standard editor for close to 30 years. Popular on Unix and Linux, it has a growing following on Windows systems, too. Most experienced system administrators cite vi as their tool of choice. And since 1986, this book has been the guide for vi. However, Unix systems are not what they were 30 years ago, and neither is this book. While retaining all the valuable features of previous editions, the 7th edition of Learning the vi and vim Editors has been expanded to include detailed information on vim, the leading vi clone. vim is the default version of vi on most Linux systems and on Mac OS X, and is available for many other operating systems too.

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 If you spend any time in a terminal, this is the definitive guide to mastering vi and Vim—the editors that power Unix, Linux, and macOS. From your first keystroke to advanced scripting, it turns a frustrating tool into your fastest path from thought to text. 【Book Arc】 - **Opening (~0%–9%)**: Introduces vi's philosophy and history, explains why it's not a WYSIWYG word processor, and covers opening/closing files, quitting, and the basic command structure. This stage solves the "where do I start?" problem with a clear mental model. - **Early (~9%–25%)**: Dives into simple editing—cursor movement, insert/delete/change commands, undo/redo, and screen navigation (H/M/L, scrolling). It also introduces the general command pattern (command + number + text object), which is the key to vi's power. This stage builds muscle memory for everyday editing. - **Early–Middle (~25%–38%)**: Explores global replacement with :g and :s, including regular expressions, special replacement characters (&, ~, \u, \l), and the :set command for customizing options. This stage solves the "I need to change this everywhere" problem efficiently. - **Middle (~38%–47%)**: Covers advanced editing—abbreviations, key mapping with :map, named buffers, and autoindent for source code. It also introduces shift commands (>>, <<) and tabstop/shiftwidth settings. This stage is about personalizing your workflow. - **Late (~47%–end)**: Moves into Vim-specific features and power tools: interval expressions in regex, enhanced tags with Exuberant ctags, and tag stacks for navigating code. This stage is for users ready to go beyond basic vi into clone-specific optimizations. 【Key Takeaways】 - **The command pattern is everything** (Early): Most vi commands follow `(command)(number)(text object)`—like `d2w` to delete two words. Understanding this unlocks the editor's composability; you can mix and match commands (c, d, y) with movements to do complex edits in a few keystrokes. - **Undo is more powerful than you think** (Early): `u` undoes the last command, `U` undoes all edits on a line, and you can toggle between versions by undoing the undo. Vim adds `CTRL-R` for redo and infinite undo history, letting you move forward and backward through your edit history. - **Global replacement is a lifesaver** (Early): The `:s/old/new/g` command changes every occurrence on a line, while `:%s/old/new/g` does it file-wide. Special characters like `&` (replay the match) and `\u`/`\l` (change case) make it a precision tool, not just a find-and-replace. - **Customize with :set and .exrc** (Middle): Toggle options like `:set ic` (ignore case) or value options like `:set window=20` change how vi behaves. Startup files (.exrc in home and local directories, plus EXINIT) let you define different environments for different tasks—English text vs. source code. - **Abbreviations and mappings save keystrokes** (Middle): `:ab` expands short phrases into long ones (watch out for infinite loops), while `:map` assigns complex command sequences to unused keys. These turn repetitive tasks into single keystrokes, dramatically speeding up your workflow. - **Autoindent is a coder's best friend** (Middle): The `autoindent` option, combined with `>>`/`<<` shift commands and `shiftwidth` settings, keeps source code properly indented. Special `CTRL-D` variants handle C preprocessor lines and reset indentation levels, helping you avoid bugs from mismatched braces. - **Vim's regex and tags go deeper** (Late): Interval expressions like `{n,m}` give precise control over repetitions, and Exuberant ctags (supported by most clones) enables powerful tag stacks—saving multiple locations as you jump through code. This is where vi stops being an editor and becomes a navigation system. 【Reading Tips】 - **Skim the problem checklists** (Early): Each major section includes troubleshooting lists for common mistakes. Don't read them upfront—just know they're there and return when you hit a snag. - **Deep-read the command pattern chapter** (Early): The `(command)(number)(text object)` structure is the foundation. Spend extra time here; it's the difference between memorizing commands and truly understanding vi. - **Practice the global replacement examples** (Early–Middle): The `:s` and `:g` commands have many subtle options. Work through the examples with a test file—especially the `&`, `~`, and case-conversion characters—to see the results firsthand. - **Skip the clone-specific sections initially** (Late): The book covers vi, nvi, elvis, Vim, and vile. If you're on Linux or macOS, focus on Vim sections first; come back to the others only if you need them. - **Take away the .exrc setup** (Middle): Even if you skim the rest, learn how to create a .exrc file with your preferred :set options. It's a small investment that pays off every time you open the editor. 【Coverage Limits】 This guide synthesizes the first ~47% of the book in depth; the later portions on Vim-specific features, multi-window editing, and scripting are covered only at a high level. Excerpts do not cover the book's appendices or advanced Vim scripting.
Page 9
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Movement by Screens 35 Movement by Text Blocks 38 Movement by Searches 39 Movement by Line Number...
View in text
Excerpt 2
edraw part of (or all of) the screen, so you can always get rid of unwanted messages by scrolling them off the screen and then returning to your previous pos...
View in text
Excerpt 3
character in the replacement text to mean “the replacement text of the last substitute command.” Pattern-Matching Rules | 79 www.it-ebooks.info As the first ...
View in text
Excerpt 4
hen doing indenting. Usually, when you see text indented by eight spaces at a time, vi will actually insert tab characters into the file, since tabs usually
View in text
Excerpt 5
g directory `/home/ehannah/Desktop/vim/vim71/src' gcc -c -I. -Iproto -DHAVE_CONFIG_H -g -O2 -o objects/ charset.o charset.c gcc -c -I. -Iproto...
View in text
Excerpt 6
88 | Chapter 11: Multiple Windows in Vim www.it-ebooks.info Choosing an alternate color scheme depending on the time of day may seem trite, but maybe not as ...
View in text
Excerpt 7
n commands, or other methods, and then reenter insert mode. Superficially, this seems like a great idea, but in practice it will appeal to only a subset of u...
View in text
Excerpt 8
o retrieve getchar getcwd getdirentries getenv getgrent ... The first two lines are typical English-language synonyms (matching “fun” and “fun- ny,” respecti...
View in text
Tags
AI categories
LinuxProgramming LanguageProgramming
ISBN: 059652983X
Publisher: O'Reilly Media
Publish Year: 2008
Language: English
Pages: 496
File Format: PDF
File Size: 7.5 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…