Hacking Vim 7.2

Hacking Vim 7.2
eBook: $23.99
Formats: PDF, PacktLib, ePub and Mobi formats
save 15%!
Print + free eBook + free PacktLib access to the book: $63.98    Print cover: $39.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Table of Contents
Sample Chapters
  • 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

Book Details

Language : English
Paperback : 244 pages [ 235mm x 191mm ]
Release Date : April 2010
ISBN : 1849510504
ISBN 13 : 9781849510509
Author(s) : Kim Schulz
Topics and Technologies : All Books, Application Development, Linux Servers, Open Source

Table of Contents

Chapter 1: Getting Started with Vim
Chapter 2: Personalizing Vim
Chapter 3: Better Navigation
Chapter 4: Production Boosters
Chapter 5: Advanced Formatting
Chapter 6: Basic Vim Scripting
Chapter 7: Extended Vim Scripting
Appendix A: Vim Can Do Everything
Appendix B: Vim Configuration Alternatives
  • Chapter 2: Personalizing Vim
    • Where are the configuration files?
    • Changing the fonts
    • Changing color scheme
      • Personal highlighting
        • Example 1: Mark color characters after a certain column
        • Example 2: Mark tabs not used for indentation in code
        • Example 3: Preventing errors caused by IP addresses
    • A more informative status line
    • Toggle menu and toolbar
    • Adding your own menu and toolbar buttons
      • Adding a menu
      • Adding toolbar icons
    • Modifying tabs
    • Work area personalization
      • Adding a more visual cursor
      • Adding line numbers
      • Spell checking your language
      • Adding helpful tool tips
      • Using abbreviations
        • Example 1: Using abbreviations for quick address insertion
      • Modifying key bindings
    • Summary
  • Chapter 3: Better Navigation
    • Faster navigation in a file
      • Context-aware navigation
        • Moving around within a code file
        • Moving in a code file
      • Navigating long lines
    • Faster navigation in Vim help
      • Faster navigation in multiple buffers
      • Open referenced files faster
    • Search and you will find
      • Search the current file
        • Example 1: Find the next occurrence of a word
        • Example 2: Search for a word under the cursor
      • Search in multiple files
      • Search the help system
    • X marks the spot
      • Visible markers—using signs
      • Hidden markers—using marks
    • Summary
  • Chapter 4: Production Boosters
    • Using templates
      • Using template files
      • Abbreviations as templates
      • Snippets with the snipMate script
    • Using tag lists
      • Easier taglist navigation
      • Other usages of taglists
    • Using autocompletion
      • Autocompletion with known words
      • Autocompletion using dictionary lookup
      • Omnicompletion
      • All-in-one completion
    • Using macro recording
    • Using sessions
      • Simple session usage
        • Satisfy your own session needs
      • Sessions as a project manager
    • Registers and undo branching
      • Using registers
        • The unnamed register
        • The small delete register
        • The numbered registers
        • The named registers
        • The read-only registers
        • The selection and drop registers
        • The black hole register
        • Search pattern register
        • The expression register
    • Using undo branching
    • Folding
      • Simple text file outlining
      • Using vimdiff to track the changes
      • Navigation in vimdiff
      • Using diff to track changes
    • Open files anywhere
      • Faster remote file editing
    • Summary
  • Chapter 5: Advanced Formatting
    • Formatting text
      • Putting text into paragraphs
      • Aligning text
      • Marking headlines
      • Creating lists
    • Formatting code
      • Autoindent
      • Smartindent
      • Cindent
      • Indentexpr
      • Fast code-block formatting
      • Auto format pasted code
    • Using external formatting tools
      • Indent
      • Berkeley Par
      • Tidy
    • Summary
  • Chapter 6: Basic Vim Scripting
    • Syntax-color schemes
      • Your first syntax-color file
    • Syntax regions
      • Color scheme and syntax coloring
    • Using scripts
      • Script types
      • Installing scripts
        • Uninstalling scripts
    • Script development
      • Script writing basics
        • Types
        • Variables
        • Conditions
        • Working with lists and dictionaries
        • Loops
        • Creating functions
    • Summary
  • Chapter 7: Extended Vim Scripting
    • Script structure
      • Script header
      • Script-loaded check
      • Script configuration
      • Key mappings
      • Functions
      • Putting it all together
    • Scripting tips
      • Gvim or Vim?
      • Which operating system?
      • Which version of Vim?
      • Printing longer lines
    • Debugging Vim scripts
    • Distributing Vim scripts
      • Making Vimballs
    • Remember the documentation
    • Using external interpreters
      • Vim scripting in Perl
      • Vim scripting in Python
      • Vim scripting in Ruby
    • Summary
  • Appendix A: Vim Can Do Everything
    • Vim games
      • Game of Life
      • Nibbles
      • Rubik's cube
      • Tic-Tac-Toe
      • Mines
      • Sokoban
      • Tetris
    • Programmers IDE
    • Mail program
    • Chat with Vim
    • Using Vim as a Twitter client

Kim Schulz

Kim Schulz has an M.Sc. in Software Engineering from Aalborg University in Denmark. He has been an active developer in the Linux and Open Source communities since 1997 and has worked with everything from translation and bug fixing to producing full-blown software systems. This entire time, Vim has been Kim's editor of choice and it has been the first thing he installs whenever he sits by a new computer. Today Kim works as a full-time software engineer at CSR Plc. developing software for the next generation wireless technologies. A lot of Kim's spare time has been spent on developing the open-source CMS Fundanemt. This has lead to him now owning the web-hosting company Devteam Denmark that specializes in hosting and development of Fundanemt-based websites.

Code Downloads

Download the code and support files for this book.

Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


- 9 submitted: last submission 03 Jan 2013

Errata type: Typo| Page number:54

The title "Moving around within a code file" should be "Moving around within a text file"


Errata type:Code | Page number: 79

for (i = 0; I < count; i++) { /* code */ } It should be: for (i = 0; i < count; i++) { /* code */ }


Errata type:Typo | Page number:91

qa: Record from now on into register a. Any register can be used, but q is often used for simplicity. It should be: qa: Record from now on into register a. Any register can be used, but a is often used for simplicity


Errata type:Others | Page number:83

link to taglist.vim was wrong.The correct link is http://www.vim.org/scripts/script.php?script_id=273


Errata type: code| Page number: 109

There is a missing endfunction. The correct code is: function! MyFoldFunction() let line = getline(v:foldstart) " cleanup unwanted things in first line let sub = substitute(line, '/\*\|\*/\|^\s+', '', 'g') " calculate lines in folded text let lines = v:foldend - v:foldstart + 1 return v:folddashes.sub.'...'.lines.' Lines...'.getline(v:foldend) endfunction


Errata type: Typo | Page number: 56

In the note : "If you want ... For example, 5g to go to the place you changed something five changes ago."

There is a ";" missing, you need to type 5g; not 5g

Errata type: Typo | Page number: 57

In the last paragraph, the instructions about pressing [ key and pressing ]] are inverted, it must be as follows:

"So if you have two or more functions in the file and the cursor is currently at the beginning of the first function, pressing ] key twice will take you to the beginning of the next function, and so on. If you want to go back to the previous function, you just have to press [[ and Vim will take you right back to the beginning of the previous function."

Errata type: Typo | Page number: 97

In the Last sentence:
"just remember to save the the session again ..."

It should be as follows:
"just remember to save the session again ..."

Errata type : Technical | Page number : 99

In the Last paragraph the commands are inverted :
"You can simply use the P (after cursor) and p (before cursor) commands to paste ..."

It should be :

"You can simply use the P (before cursor) and p (after cursor) commands to paste ..."

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

Hacking Vim 7.2 +    Nmap 6: Network Exploration and Security Auditing Cookbook =
50% Off
the second eBook
Price for both: €27.35

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Gain a deep understanding of Vim to master the editor
  • Personalize Vim to suit your needs
  • Navigate through files faster while editing multiple files
  • Boost your productivity by using templates, auto-completion, folding, sessions, and registers
  • Improve the formatting of your text and code by mastering simple tricks
  • Extend Vim with scripts
  • Retain your Vim configuration across computers by storing an online copy

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


This book is a tutorial packed with ready-to-use hacks that give solutions for common problems faced by Vim users in their everyday life. Every chapter covers a set of recipes, each of which follows a systematic approach with a self-contained description of the task it covers, how to use it, and what you gain by using it. The minimum version of Vim required for each hack is clearly indicated.

Who this book is for

If you are a Vim user who wants to get more out of this legendary text editor, this book is for you. It focuses on making life easier for intermediate to experienced Vim users.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software