ebook img

Hacking Vim: A Cookbook to get the Most out of the Latest Vim Editor: From personalizing Vim to productivity optimizations: Recipes to make life easier for experienced Vim users PDF

224 Pages·2007·4.62 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Hacking Vim: A Cookbook to get the Most out of the Latest Vim Editor: From personalizing Vim to productivity optimizations: Recipes to make life easier for experienced Vim users

Hacking Vim A cookbook to get the most out of the latest Vim editor From personalizing Vim to productivity optimizations: Recipes to make life easier for experienced Vim users Kim Schulz BIRMINGHAM - MUMBAI Hacking Vim A cookbook to get the most out of the latest Vim editor Copyright © 2007 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, Packt Publishing, nor its dealers or 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 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: May 2007 Production Reference: 1140507 Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK. ISBN 978-1-847190-93-2 www.packtpub.com Cover Image by www.visionwt.com Credits Author Project Manager Kim Schulz Patricia Weir Reviewers Project Coordinator Brian Jørgensen Sagara Naik James Eaton-Lee Kenneth Geisshirt Indexer Sven Guckes Bhushan Pangaonkar Development Editor Proofreader Nanda Nag Chris Smith Nikhil Bangera Layouts and Illustrations Technical Editor Shantanu Zagade Ajay S Cover Designer Editorial Manager Shantanu Zagade Dipali Chittar 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 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 at 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. I would like to thank my girlfriend, Line, for letting me take the time to write this book. Without her positive attitude and help, I would never have got this book ready. I would also like to add a great thank you to Bram Moolenaar, for developing the Vim editor, and making it what it is today. About the Reviewers Brian Jørgensen was born in 1982 in Northern Jutland, Denmark. His early interest in computers and programming on the Commodore 64 and later the PC resulted in him studying computer science at Aalborg University, from where he is about to graduate with a masters degree in software engineering. In the late 90s he found a great interest in the Linux operating system, which he has been using since. When he is not studying or working as a freelance developer, his spare time is spent working on Open Source software projects. He is one of the core developers on the Fundanemt CMS. His main interests are in programming languages, Internet technologies, and keeping a tap on a wide range Open Source projects. Brian has a personal website (http://qte.dk/) where he runs a blog and writes about his software projects. James Eaton-Lee works as a Consultant specializing in Infrastructure Security and has worked with clients ranging from small businesses with a handful of employees to multinational banks. He has a varied background, including experience working with IT in ISPs, manufacturing firms, and call centers. James has been involved in the integration of a range of systems, from analogue and VOIP telephony to NT and AD domains in mission-critical environments with thousands of hosts, as well as Unix and Linux servers in a variety of roles. James is a strong advocate of the use of appropriate technology, and the need to make technology more approachable and flexible for businesses of all sizes, but especially in the SME marketplace in which technology is often forgotten and avoided. James has been a strong believer in the relevancy and merit of Open Source and Free Software for a number of years and —wherever appropriate—uses it for himself and his clients, integrating it fluidly with other technologies. Kenneth Geisshirt is a chemist by education, and is a strong free-software advocate. He spent his Christmas holidays in 1992 installing SLS Linux, and GNU/Linux has been his favorite operating system ever since. Currently, he does consultancy work in areas like scientific computing and Linux clusters. He lives in Copenhagen, Denmark with his partner and their two children. You can find him at http://kenneth.geisshirt.dk/. Table of Contents Preface 1 Chapter 1: Introduction 7 Vi, Vim, and Friends 8 vi 8 STEVIE 9 Elvis 9 Nvi 10 Vim 11 Vile 12 Compatibility 13 Vim is Charityware 14 Summary 14 Chapter 2: Personalizing Vim 15 Where are the Config Files? 16 vimrc 16 gvimrc 17 exrc 17 Changing the Fonts 18 Changing Color Scheme 19 Personal Highlighting 20 A More Informative Status Line 24 Toggle Menu and Toolbar 25 Adding Your Own Menu and Toolbar Buttons 26 Adding a Menu 27 Adding Toolbar Icons 30 Modifying Tabs 30 Work Area Personalization 34 Adding a More Visual Cursor 35 Table of Contents Adding Line Numbers 36 Spell Checking Your Language 37 Adding Helpful Tool Tips 40 Using Abbreviations 43 Modifying Key Bindings 45 Summary 47 Chapter 3: Better Navigation 49 Faster Navigation in a File 50 Context-Aware Navigation 50 Navigating Long Lines 55 Faster Navigation in Vim Help 55 Faster Navigation in Multiple Buffers 57 Open Referenced Files Faster 58 Search and You Will Find 59 Search the Current File 59 Search in Multiple Files 61 Search the Help System 62 X Marks the Spot 63 Visible Markers—Using Signs 64 Hidden Markers—Using Marks 66 Summary 68 Chapter 4: Production Boosters 69 Using Templates 70 Using Template Files 70 Abbreviations as Templates 72 Using Tag Lists 74 Easier Taglist Navigation 77 Other Usages of Taglists 77 Using Auto-Completion 78 Auto-Completion with Known Words 79 Auto-Completion using Dictionary Lookup 80 Omni-Completion 81 All-in-One Completion 83 Using Macro Recording 85 Using Sessions 87 Simple Session Usage 87 Satisfy your own Session Needs 90 Sessions as a Project Manager 91 Registers and Undo Branching 92 Using Registers 93 The Unnamed Register 94 [ ii ] Table of Contents The Small Delete Register 94 The Numbered Registers 94 The Named Registers 95 The Read-Only Registers 95 The Selection and Drop Registers 95 The Black Hole Register 96 Search Pattern Register 96 The Expression Register 96 Using Undo Branching 97 Folding 100 Simple Text File Outlining 104 Using vimdiff to Track the Changes 105 Navigation in vimdiff 106 Using Diff to Track Changes 108 Open Files Anywhere 108 Faster Remote File Editing 110 Summary 111 Chapter 5: Advanced Formatting 113 Formatting Text 113 Putting Text into Paragraphs 113 Aligning Text 116 Marking Headlines 117 Creating Lists 119 Formatting Code 120 Autoindent 121 Smartindent 122 Cindent 122 Indentexpr 123 Fast Code Block Formatting 123 Auto Format Pasted Code 126 Using External Formatting Tools 127 Indent 127 Berkeley Par 128 Tidy 129 Summary 130 Chapter 6: Vim Scripting 133 Syntax-Color Schemes 133 Your First Syntax-Color File 134 Syntax Regions 135 Color Scheme and Syntax Coloring 139 Using Scripts 140 Script Types 140 Installing Scripts 141 [ iii ]

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.