Learn Vim
Learn Vim
The Smart Way
About the Book
The average Vim user needs something more than vimtutor and less than the help manual. This guide attempts to bridge that gap by highlighting only the key features to learn the most useful parts of Vim in the least time possible.
Chances are you won't need all 100% of Vim features. You probably only need to know about 20% to become a powerful Vimmer. This guide will show you which Vim features you will find most useful.
This is an opinionated guide. It covers techniques that I often use when using Vim. The chapters are sequenced based on what I think would make the most logical sense for a beginner to learn Vim.
This guide is examples-heavy. When learning a new skill, examples are indispensable, having numerous examples will solidify the concepts more effectively.
You can read this guide online here entirely for free.
Purchasing this guide will keep this project sustainable and support future guides.
Some of you may wonder why do you need to learn Vimscript? In my first year of using Vim, I was content with just knowing how to use Vim. Time passed and I started needing Vimscript more and more to write custom commands for my specific editing needs. As you are mastering Vim, you will sooner or later need to learn Vimscript. So why not sooner? Vimscript is a small language. You can learn its fundamentals in just four chapters of this guide.
You can go far using Vim without knowing any Vimscript, but knowing it will help you excel even farther.
This guide is written for both beginner and advanced Vimmers. It starts out with broad and simple concepts and ends with specific and advanced concepts. If you're an advanced user already, I would encourage you to read this guide from start to finish anyway, because you will learn something new!
For more Vim tips and tricks, follow @learnvim on Twitter!
Table of Contents
-
New To Vim? Read This First
- Why This Guide Was Written
- How To Transition To Vim From Using A Different Text Editor
- How To Read This Guide
- More Help
- Syntax
- Vimrc
- Future, Errors, Questions
- I Want More Vim Tricks
- Thank Yous
-
Ch01. Starting Vim
- Installing
- The Vim Command
- Exiting Vim
- Saving A File
- Help
- Opening a File
- Arguments
- Opening Multiple Windows
- Suspending
- Starting Vim The Smart Way
-
Ch02. Buffers, Windows, and Tabs
- Buffers
- Exiting Vim
- Windows
- Tabs
- Moving In 3D
- Using Buffers, Windows, and Tabs The Smart Way
-
Ch03. Searching Files
- Opening And Editing Files
- Searching Files With Find
- Find And Path
- Searching In Files With Grep
- Browsing Files With Netrw
- Fzf
- Setup
- Fzf Syntax
- Finding Files
- Finding In Files
- Other Searches
- Replacing Grep With Rg
- Search And Replace In Multiple Files
- Learn Search The Smart Way
-
Ch04. Vim Grammar
- How To Learn A Language
- Grammar Rule
- Nouns (Motions)
- Verbs (Operators)
- Verb And Noun
- More Nouns (Text Objects)
- Composability And Grammar
- Learn Vim Grammar The Smart Way
-
Ch05. Moving In A File
- Character Navigation
- Relative Numbering
- Count Your Move
- Word Navigation
- Current Line Navigation
- Sentence And Paragraph Navigation
- Match Navigation
- Line Number Navigation
- Window Navigation
- Scrolling
- Search Navigation
- Jump
- Learn Navigation The Smart Way
-
Ch06. Insert Mode
- Ways To Go To Insert Mode
- Different Ways To Exit Insert Mode
- Repeating Insert Mode
- Deleting Chunks In Insert Mode
- Insert From Register
- Scrolling
- Autocompletion
- Executing A Normal Mode Command
- Learn Insert Mode The Smart Way
-
Ch07. The Dot Command
- Usage
- What Is A Change?
- Multi-line Repeat
- Including A Motion In A Change
- Learn The Dot Command The Smart Way
-
Ch08. Registers
- The Ten Register Types
- Register Operators
- Calling Registers From Insert Mode
- The Unnamed Register
- The Numbered Registers
- The Small Delete Register
- The Named Register
- The Read-Only Registers
- The Alternate File Register
- The Expression Register
- The Selection Registers
- The Black Hole Register
- The Last Search Pattern Register
- Viewing The Registers
- Executing A Register
- Clearing A Register
- Putting The Content Of A Register
- Learning Registers The Smart Way
-
Ch09. Macros
- Basic Macros
- Safety Guard
- Command Line Macro
- Executing A Macro Across Multiple Files
- Recursive Macro
- Appending A Macro
- Amending A Macro
- Macro Redundancy
- Series Vs Parallel Macro
- Learn Macros The Smart Way
-
Ch10. Undo
- Undo, Redo, And UNDO
- Breaking The Blocks
- Undo Tree
- Persistent Undo
- Time Travel
- Learn Undo The Smart Way
-
Ch11. Visual Mode
- The Three Types Of Visual Modes
- Visual Mode Navigation
- Visual Mode Grammar
- Visual Mode And Command-line Commands
- Adding Text On Multiple Lines
- Incrementing Numbers
- Selecting The Last Visual Mode Area
- Entering Visual Mode From Insert Mode
- Select Mode
- Learn Visual Mode The Smart Way
-
Ch12. Search And Substitute
- Smart Case Sensitivity
- First And Last Character In A Line
- Repeating Search
- Searching For Alternative Words
- Setting The Start And End Of A Match
- Searching Character Ranges
- Searching For Repeating Characters
- Predefined Character Ranges
- Search Example: Capturing A Text Between A Pair Of Similar Characters
- Search Example: Capturing A Phone Number
- Basic Substitution
- Repeating The Last Substitution
- Substitution Range
- Pattern Matching
- Substitution Flags
- Changing The Delimiter
- Special Replace
- Alternative Patterns
- Substituting The Start And The End Of A Pattern
- Greedy And Non-Greedy
- Substituting Across Multiple Files
- Substituting Across Multiple Files With Macros
- Learning Search And Substitution The Smart Way
-
Ch13. The Global Command
- Global Command Overview
- Inverse Match
- Pattern
- Passing A Range
- Normal Command
- Executing A Macro
- Recursive Global Command
- Changing The Delimiter
- The Default Command
- Reversing The Entire Buffer
- Aggregating All TODOs
- Black Hole Delete
- Reduce Multiple Empty Lines To One Empty Line
- Advanced Sort
- Learn The Global Command The Smart Way
-
Ch14. External Commands
- The Bang Command
- Reading The STDOUT Of A Command Into Vim
- Writing The Buffer Content Into An External Command
- Executing An External Command
- Filtering Texts
- Normal Mode Command
- Learn External Commands The Smart Way
-
Ch15. Command-line Mode
- Entering And Exiting The Command-line Mode
- Repeating The Previous Command
- Command-line Mode Shortcuts
- Register And Autocomplete
- History Window And Command-line Window
- More Command-line Commands
- Learn Command-line Mode The Smart Way
-
Ch16. Tags
- Tag Overview
- Tag Generator
- Tags Anatomy
- The Tag File
- Generating Tags For A Large Project
- Tags Navigation
- Tag Priority
- Selective Tag Jumps
- Autocompletion With Tags
- Tag Stack
- Automatic Tag Generation
- Generate A Tag On Save
- Using Plugins
- Ctags And Git Hooks
- Learn Tags The Smart Way
-
Ch17. Fold
- Manual Fold
- Different Fold Methods
- Indent Fold
- Marker Fold
- Syntax Fold
- Expression Fold
- Diff Fold
- Persisting Fold
- Learn Fold The Smart Way
-
Ch18. Git
- Diffing
- Vim As A Merge Tool
- Git Inside Vim
- Plugins
- Vim-fugitive
- Git Status
- Git Blame
- Gdiffsplit
- Gwrite And Gread
- Gclog
- More Vim-Fugitive
- Learn Vim And Git The Smart Way
-
Ch19. Compile
- Compile From the Command Line
- The Make Command
- Compiling With Make
- Different Make Program
- Auto-compile On Save
- Switching Compiler
- Creating A Custom Compiler
- Async Compiler
- Plugin: Vim-dispatch
- Learn Compile The Smart Way
-
Ch20. Views, Sessions, And Viminfo
- View
- Sessions
- Viminfo
- Using Views, Sessions, And Viminfo The Smart Way
-
Ch21. Vimrc
- How Vim Finds Vimrc
- What To Put In My Vimrc?
- Basic Vimrc Content
- Organizing Vimrc
- Running Vim With Or Without Vimrc And Plugins
- Configure Vimrc The Smart Way
-
Ch22. Vim Packages
- Pack Directory
- Two Types Of Loading
- Organizing packages
- Adding Packages The Smart Way
-
Ch23. Vim Runtime
- Runtime Path
- Plugin Scripts
- Filetype Detection
- File Type Plugin
- Indent Files
- Colors
- Syntax Highlighting
- Documentation
- Lazy Loading Scripts
- After Scripts
- $VIMRUNTIME
- Runtimepath Option
- Learn Runtime The Smart Way
-
Ch24. Vimscript Basic Data Types
- Data Types
- Following Along With Ex Mode
- Number
- Float
- String
- List
- Dictionary
- Special Primitives
- Learn Data Types The Smart Way
-
Ch25. Vimscript Conditionals And Loops
- Relational Operators
- If
- Ternary Expression
- Or
- And
- For
- While
- Error Handling
- Learn conditionals the smart way
-
Ch26. Vimscript Variables And Scopes
- Mutable And Immutable Variables
- Variable Sources
- Variable Scopes
- Using Vim Variable Scopes The Smart Way
-
Ch27. Vimscript Functions
- Function Syntax Rules
- Listing Available Functions
- Removing A Function
- Function Return Value
- Formal Arguments
- Function Local Variable
- Calling A Function
- Default Argument
- Variable Arguments
- Range
- Dictionary
- Funcref
- Lambda
- Method Chaining
- Closure
- Learn Vimscript Functions The Smart Way
The Leanpub 60-day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
Do Well. Do Good.
Authors have earned$11,712,765writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Top Books
Recipes for Decoupling
Matthias NobackWrite software that survives
OpenIntro Statistics
David Diez, Christopher Barr, Mine Cetinkaya-Rundel, and OpenIntroA complete foundation for Statistics, also serving as a foundation for Data Science.
Leanpub revenue supports OpenIntro (US-based nonprofit) so we can provide free desk copies to teachers interested in using OpenIntro Statistics in the classroom and expand the project to support free textbooks in other subjects.
More resources: openintro.org.
CQRS by Example
Carlos Buenosvinos, Christian Soronellas, and Keyvan Akbary- Leverage your Software Architecture skills by learning everything about CQRS in detail with lots of examples
- Develop faster applications by applying CQRS and fostering Read Models and Projections
- Learn how to apply CQRS into a brownfield project from a pragmatic approach
Maîtriser Apache JMeter
Philippe Mouawad, Bruno Demion (Milamber), and Antonio Gomes RodriguesToute la puissance d'Apache JMeter expliquée par ses commiteurs et utilisateurs experts. De l'intégration continue en passant par le Cloud, vous découvrirez comment intégrer JMeter à vos processus "Agile" et Devops.
If you're looking for the newer english version of this book, go to Master JMeter : From load testing to DevOps
Ansible for DevOps
Jeff GeerlingAnsible is a simple, but powerful, server and configuration management tool. Learn to use Ansible effectively, whether you manage one server—or thousands.
C++20 - The Complete Guide
Nicolai M. JosuttisAll new language and library features of C++20 (for those who know previous C++ versions).
The book presents all new language and library features of C++20. Learn how this impacts day-to-day programming, to benefit in practice, to combine new features, and to avoid all new traps.
Buy early, pay less, free updates.
Other books:
Jetpack Compose internals
Jorge CastilloJetpack Compose is the future of Android UI. Master how it works internally and become a more efficient developer with it. You'll also find it valuable if you are not an Android dev. This book provides all the details to understand how the Compose compiler & runtime work, and how to create a client library using them.
The PowerShell Scripting and Toolmaking Book
Don Jones and Jeff HicksLearn the patterns, practices, and details of PowerShell Scripting and Toolmaking from the industry's two most recognized experts on the subject.
The C4 model for visualising software architecture
Simon BrownA guide to visualising your software architecture with the C4 model.
Mastering STM32 - Second Edition
Carmine NovielloWith more than 1200 microcontrollers, STM32 is probably the most complete ARM Cortex-M platform on the market. This book aims to be the most complete guide around introducing the reader to this exciting MCU portfolio from ST Microelectronics and its official CubeHAL and STM32CubeIDE development environment.
Top Bundles
- #1
Software Architecture
2 Books
"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before... - #2
CCIE Service Provider Ultimate Study Bundle
2 Books
Piotr Jablonski, Lukasz Bromirski, and Nick Russo have joined forces to deliver the only CCIE Service Provider training resource you'll ever need. This bundle contains a detailed and challenging collection of workbook labs, plus an extensively detailed technical reference guide. All of us have earned the CCIE Service Provider certification... - #4
Pattern-Oriented Memory Forensics and Malware Detection
2 Books
This training bundle for security engineers and researchers, malware and memory forensics analysts includes two accelerated training courses for Windows memory dump analysis using WinDbg. It is also useful for technical support and escalation engineers who analyze memory dumps from complex software environments and need to check for possible... - #6
All the Books of The Medical Futurist
6 Books
We put together the most popular books from The Medical Futurist to provide a clear picture about the major trends shaping the future of medicine and healthcare. Digital health technologies, artificial intelligence, the future of 20 medical specialties, big pharma, data privacy, digital health investments and how technology giants such as Amazon... - #8
The Python Craftsman
3 Books
The Python Craftsman series comprises The Python Apprentice, The Python Journeyman, and The Python Master. The first book is primarily suitable for programmers with some experience of programming in another language. If you don't have any experience with programming this book may be a bit daunting. You'll be learning not just a programming...