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

Book Description

Ready-to-use hacks with solutions for common situations encountered by users of the Vim editor

  • Create, install, and use Vim scripts to extend Vim's functionality

  • Personalize your work-area to fit your workflow

  • Optimize your Vim editor to be faster and more responsive

  • Packed with tips and tricks based on the author's practical experience

  • In Detail

    Vim is one of the most powerful open-source editors used by programmers and system administrators around the world. While Vim itself is inherently a powerful editor, personalizing it to suit your needs can be a daunting task. However, it is possible to do so with the help of this book.

    This book contains examples that cover everything from personalizing Vim according to the your work cycle to optimizations that will boost the your productivity. The main focus of this book is to make your life, as a Vim user, easier.

    Each chapter 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.

    This book is written for Vim 7.2, the latest stable version. This latest version of Vim includes many new features like spell-checking, code completion, document tabs, current line and column highlighting, undo branches, and much more.

    Getting the most out of the Vim editor

    Table of Contents

    1. Hacking Vim 7.2
      1. Table of Contents
      2. Hacking Vim 7.2
      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. Who this book is for
        4. New to Vim?
        5. Conventions
        6. Reader feedback
        7. Customer support
          1. Errata
          2. Piracy
          3. Questions
      7. 1. Getting Started with Vim
        1. Getting Vim
        2. vi, Vim, and friends
          1. vi
          2. STEVIE
          3. Elvis
          4. nvi
          5. Vim
          6. Vile
          7. Compatibility
        3. Vim is charityware
        4. Common terminology
        5. Summary
      8. 2. Personalizing Vim
        1. Where are the configuration files?
        2. Changing the fonts
        3. Changing color scheme
          1. Personal highlighting
            1. Example 1: Mark color characters after a certain column
            2. Example 2: Mark tabs not used for indentation in code
            3. Example 3: Preventing errors caused by IP addresses
        4. A more informative status line
        5. Toggle menu and toolbar
        6. Adding your own menu and toolbar buttons
          1. Adding a menu
          2. Adding toolbar icons
        7. Modifying tabs
        8. 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
            1. Example 1: Using abbreviations for quick address insertion
          6. Modifying key bindings
        9. Summary
      9. 3. Better Navigation
        1. Faster navigation in a file
          1. Context-aware navigation
            1. Moving around within a code file
            2. Moving in a code file
          2. Navigating long lines
        2. Faster navigation in Vim help
          1. Faster navigation in multiple buffers
          2. Open referenced files faster
        3. Search and you will find
          1. Search the current file
            1. Example 1: Find the next occurrence of a word
            2. Example 2: Search for a word under the cursor
          2. Search in multiple files
          3. Search the help system
        4. X marks the spot
          1. Visible markers—using signs
          2. Hidden markers—using marks
        5. Summary
      10. 4. Production Boosters
        1. Using templates
          1. Using template files
          2. Abbreviations as templates
          3. Snippets with the snipMate script
        2. Using tag lists
          1. Easier taglist navigation
          2. Other usages of taglists
        3. Using autocompletion
          1. Autocompletion with known words
          2. Autocompletion using dictionary lookup
          3. Omnicompletion
          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
        7. Using undo branching
        8. Folding
          1. Simple text file outlining
          2. Using vimdiff to track the changes
          3. Navigation in vimdiff
          4. Using diff to track changes
        9. Open files anywhere
          1. Faster remote file editing
        10. 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. Basic Vim Scripting
        1. Syntax-color schemes
          1. Your first syntax-color file
        2. Syntax regions
          1. Color scheme and syntax coloring
        3. Using scripts
          1. Script types
          2. Installing scripts
            1. Uninstalling scripts
        4. Script development
          1. Script writing basics
            1. Types
            2. Variables
            3. Conditions
            4. Working with lists and dictionaries
            5. Loops
              1. For loops
              2. While loops
            6. Creating functions
              1. Variable argument list
        5. Summary
      13. 7. Extended Vim Scripting
        1. Script structure
          1. Script header
          2. Script-loaded check
          3. Script configuration
          4. Key mappings
          5. Functions
          6. Putting it all together
        2. Scripting tips
          1. Gvim or Vim?
          2. Which operating system?
          3. Which version of Vim?
          4. Printing longer lines
        3. Debugging Vim scripts
        4. Distributing Vim scripts
          1. Making Vimballs
        5. Remember the documentation
        6. Using external interpreters
          1. Vim scripting in Perl
          2. Vim scripting in Python
          3. Vim scripting in Ruby
        7. Summary
      14. 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
        5. Using Vim as a Twitter client
      15. B. Vim Configuration Alternatives
        1. Tips for keeping your vimrc file clean
        2. A vimrc setup system
        3. Storing vimrc online
      16. Index