You are previewing Hacking Vim.
O'Reilly logo
Hacking Vim

Book Description

A cookbook to get the most out of the latest Vim editor

  • Create, install, and use Vim scripts

  • Personalize your work-area

  • Optimize your Vim editor to be faster and more responsive

  • In Detail

    Each chapter of this book deals with a different aspect, and provides recipes for easy-to-use hacks to customize and simplify your Vim experience. After an introduction covering the derivation of Vim and its relatives from the vi editor, the author explains basic changes that you can make to the appearance of the Vim editor. Further chapters cover improved navigation through files and buffers in Vim; speeding up your work with templates, auto-completion, folding, sessions, and registers; and formatting text and code, including using external formatting scripts. The final comprehensive chapter covers everything about using Vim scripts and scripting to extend functionality.

    Vim stands for Vi IMproved and is the editor of choice for programmers looking for a highly configurable, stable, open-source, multi-platform text editor. It is included with almost every Linux distribution as the standard text editor, and can be used to work with source code from any language. A big advantage of using Vim is that it can be extensively customized; you can control the basic interface, define personalized key mappings, implement macros, and call external or user-defined scripts. Vim has its own scripting language that allows for plug-in like extensions to enable IDE behavior, syntax scripts and highlighting, color schemes, themes, and utility scripts that can add a wide range of features and functionality.

    Vim 7.0, for which this book is written, includes spell-checking, code completion, document tabs, current line and column highlighting, undo branches, and more.

    This book contains hacks that cover everything from personalizing Vim according to the user’s work cycle to optimizations that will boost the user’s productivity. It does not cover the basic tasks of using the editor but instead focuses on making life easier for experienced Vim users. It is written for Vim 7.0 , the latest stable version.

    Table of Contents

    1. Hacking Vim
      1. Table of Contents
      2. Hacking Vim
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. Preface
        1. What This Book Covers
        2. What You Need for This Book
        3. Conventions
        4. Reader Feedback
        5. Customer Support
          1. Downloading the Example Code for the Book
          2. Errata
          3. Questions
      7. 1. Introduction
        1. Vi, Vim, and Friends
          1. vi
          2. STEVIE
          3. Elvis
          4. Nvi
          5. Vim
          6. Vile
          7. Compatibility
        2. Vim is Charityware
        3. Summary
      8. 2. Personalizing Vim
        1. Where are the Config Files?
          1. vimrc
          2. gvimrc
          3. exrc
        2. Changing the Fonts
        3. Changing Color Scheme
        4. Personal Highlighting
        5. A More Informative Status Line
        6. Toggle Menu and Toolbar
        7. Adding Your Own Menu and Toolbar Buttons
          1. Adding a Menu
          2. Adding Toolbar Icons
        8. Modifying Tabs
        9. Work Area Personalization
          1. Adding a More Visual Cursor
          2. Adding Line Numbers
          3. Spell Checking Your Language
          4. Adding Helpful Tool Tips
          5. Using Abbreviations
          6. Modifying Key Bindings
        10. Summary
      9. 3. Better Navigation
        1. Faster Navigation in a File
        2. Context-Aware Navigation
        3. Navigating Long Lines
        4. Faster Navigation in Vim Help
          1. Faster Navigation in Multiple Buffers
          2. Open Referenced Files Faster
        5. Search and You Will Find
          1. Search the Current File
          2. Search in Multiple Files
          3. Search the Help System
        6. X Marks the Spot
          1. Visible Markers—Using Signs
          2. Hidden Markers—Using Marks
        7. Summary
      10. 4. Production Boosters
        1. Using Templates
          1. Using Template Files
          2. Abbreviations as Templates
        2. Using Tag Lists
          1. Easier Taglist Navigation
          2. Other Usages of Taglists
        3. Using Auto-Completion
          1. Auto-Completion with Known Words
          2. Auto-Completion using Dictionary Lookup
          3. Omni-Completion
          4. All-in-One Completion
        4. Using Macro Recording
        5. Using Sessions
          1. Simple Session Usage
            1. Satisfy your own Session Needs
          2. Sessions as a Project Manager
        6. Registers and Undo Branching
          1. Using Registers
            1. The Unnamed Register
            2. The Small Delete Register
            3. The Numbered Registers
            4. The Named Registers
            5. The Read-Only Registers
            6. The Selection and Drop Registers
            7. The Black Hole Register
            8. Search Pattern Register
            9. The Expression Register
          2. Using Undo Branching
        7. Folding
          1. Simple Text File Outlining
          2. Using vimdiff to Track the Changes
          3. Navigation in vimdiff
          4. Using Diff to Track Changes
        8. Open Files Anywhere
          1. Faster Remote File Editing
        9. Summary
      11. 5. Advanced Formatting
        1. Formatting Text
          1. Putting Text into Paragraphs
          2. Aligning Text
          3. Marking Headlines
          4. Creating Lists
        2. Formatting Code
          1. Autoindent
          2. Smartindent
          3. Cindent
          4. Indentexpr
          5. Fast Code Block Formatting
          6. Auto Format Pasted Code
        3. Using External Formatting Tools
          1. Indent
          2. Berkeley Par
          3. Tidy
        4. Summary
      12. 6. Vim Scripting
        1. Syntax-Color Schemes
          1. Your First Syntax-Color File
          2. Syntax Regions
          3. Color Scheme and Syntax Coloring
        2. Using Scripts
          1. Script Types
          2. Installing Scripts
          3. Uninstalling Scripts
        3. Script Development
          1. Scripting Basics
            1. Types
            2. Variables
            3. Conditions
            4. Lists and Dictionaries
            5. Loops
            6. Creating Functions
          2. Script Structure
          3. Scripting Tips
            1. Gvim or Vim?
            2. Which Operating System?
            3. Which Version of Vim?
            4. Printing Longer Lines
          4. Debugging Vim Scripts
          5. Distributing Vim Scripts
          6. Making Vimballs
            1. Remember the Documentation
          7. Using External Interpreters
            1. Vim Scripting in Perl
            2. Vim Scripting in Python
            3. Vim Scripting in Ruby
        4. Summary
      13. A. Vim Can Do Everything
        1. Vim Games
          1. Game of Life
          2. Nibbles
          3. Rubik's Cube
          4. Tic-Tac-Toe
          5. Mines
          6. Sokoban
          7. Tetris
        2. Programmers IDE
        3. Mail Program
        4. Chat with Vim
      14. B. Vim Configuration Alternatives
        1. Tips for Keeping your Vimrc Clean
        2. A Vimrc Setup System
        3. Storing Vimrc Online
      15. Index