logo资料库

Packtpub.Hacking.Vim.7.2.Apr.2010.pdf

第1页 / 共244页
第2页 / 共244页
第3页 / 共244页
第4页 / 共244页
第5页 / 共244页
第6页 / 共244页
第7页 / 共244页
第8页 / 共244页
资料共244页,剩余部分请下载后查看
Cover
Copyright
Credits
About the Author
About the Reviewers
Table of Contents
Preface
Chapter 1: Getting Started with Vim
Getting Vim
vi, Vim, and friends
vi
STEVIE
Elvis
nvi
Vim
Vile
Compatibility
Vim is charityware
Common terminology
Summary
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
Appendix B: Vim Configuration Alternatives
Tips for keeping your vimrc file clean
A vimrc setup system
Storing vimrc online
Index
Hacking Vim 7.2 Ready-to-use hacks with solutions for common situations encountered by users of the Vim editor Kim Schulz BIRMINGHAM - MUMBAI
Hacking Vim 7.2 Copyright © 2010 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: April 2010 Production Reference: 1230410 Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK. ISBN 978-1-849510-50-9 www.packtpub.com Cover Image by Asher Wishkerman (a.wishkerman@mpic.de)
Credits Editorial Team Leader Mithun Sehgal Project Team Leader Lata Basantani Project Coordinator Shubhanjan Chatterjee Proofreader Lynda Silwoski Production Coordinator Adline Swetha Jesuthas Cover Work Adline Swetha Jesuthas Author Kim Schulz Reviewers Boris Fersing Thomas Moyer Development Editors Darshana D. Shinde Amey Kanse Technical Editors Madhumita Singh Conrad Sardinha Copy Editor Sneha Kulkarni Indexer Hemangini Bari
About the Author 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 a full-blown software system. Throughout this entire time, Vim has been Kim's "weapon" of choice and it is the first program he installs whenever he sits by a new computer. Today Kim works as a Software engineer at CSR Plc, developing software for the next generation mobile and wireless technologies. Kim is also the owner of a web hosting and development company, Devteam Denmark, that specializes in hosting of websites developed using the Fundanemt Content Management System—a CMS that Kim is a co-developer of. I would like to thank my wife, Line, for letting me take the time to write this book. Without her positive attitude and help, I would never have gotten this book ready. I would also like to add a great thank you to Bram Moolenaar for developing the Vim Editor—I appreciate the fruits of your work every day.
About the Reviewers Boris Fersing is an amateur photographer and student in computational linguistics at the University of Saarland, Germany. For his studies, he participated in many projects and used many programming languages (SML, C/C++, Java, Ruby, Prolog) and Vim was always his editor of choice. He also worked as system administrator for a department of the University of Saarland. With this job he learned how to use some Unix tools and improved his knowledge about the Vim editor. I really would like to thank the author for writing such a nice book. It was a pleasure to review it. The information it contains is really interesting. I recommend this book to everyone who wants to learn more about Vim. Thomas Moyer is a graduate student in Computer Science and Engineering at Pennsylvania State University. He is currently looking at areas of Computer Security including trusted computing hardware and Web 2.0 security. He spends a great deal of time using Vim for editing both code and also writing papers. He has completed a Master's degree from Penn State and is currently working on his Ph.D. I would like to thank my wife and daughter for all of their support, and also the rest of my family. I would also like to thank the members of the Systems and Internet Infrastructure Security Lab at Penn State for their continued support.
Table of Contents Preface Chapter 1: Getting Started with Vim Getting Vim vi, Vim, and friends vi STEVIE Elvis nvi Vim Vile Compatibility Vim is charityware Common terminology Summary 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 1 7 8 8 9 9 10 10 11 13 14 15 15 16 17 18 20 21 22 24 25 26 26 28 29 29 32
分享到:
收藏