0%

Book Description

Mastering Vim, reviewed by Bram Moolenaar, the creator of Vim, covers usage of Vim and Neovim, showcases relevant plugins, and teaches Vimscript

Key Features

  • Expert Vim and Vimscript techniques to work with Python and other development environment
  • Accomplish end-to-end software development tasks with Neovim and Vim plugins
  • Understand best practices for various facets of projects like version control, building, and testing

Book Description

Vim is a ubiquitous text editor that can be used for all programming languages. It has an extensive plugin system and integrates with many tools. Vim offers an extensible and customizable development environment for programmers, making it one of the most popular text editors in the world.

Mastering Vim begins with explaining how the Vim editor will help you build applications efficiently. With the fundamentals of Vim, you will be taken through the Vim philosophy. As you make your way through the chapters, you will learn about advanced movement, text operations, and how Vim can be used as a Python (or any other language for that matter) IDE. The book will then cover essential tasks, such as refactoring, debugging, building, testing, and working with a version control system, as well as plugin configuration and management. In the concluding chapters, you will be introduced to additional mindset guidelines, learn to personalize your Vim experience, and go above and beyond with Vimscript.

By the end of this book, you will be sufficiently confident to make Vim (or its fork, Neovim) your first choice when writing applications in Python and other programming languages.

What you will learn

  • Get the most recent Vim, GVim, and Neovim versions installed
  • Become efficient at navigating and editing text
  • Uncover niche Vim plugins and pick the best ones
  • Discover multiple ways of organizing plugins
  • Explore and tailor Vim UI to fit your needs
  • Organize and maintain Vim configuration across environments
  • Write scripts to complement your workflow using Vimscript

Who this book is for

Mastering Vim is written for beginner, intermediate, and expert developers.The book will teach you to effectively embed Vim in your daily workflow. No prior experience with Python or Vim is required.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Mastering Vim 
  3. Dedication
  4. About Packt
    1. Why subscribe?
    2. Packt.com
  5. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
      1. Download the example code files
      2. Conventions used
    3. Get in touch
      1. Reviews
  7. Getting Started
    1. Technical requirements
    2. Let’s start a conversation (about modal interfaces)
    3. Installation
      1. Setting up on Linux
      2. Setting up on MacOS
        1. Using Homebrew
        2. Downloading a .dmg image
      3. Setting up on Windows
        1. Unix-like experience with Cygwin
          1. Installing Cygwin
          2. Using Cygwin
        2. Visual Vim with gVim
      4. Verifying and troubleshooting the installation
    4. Vanilla Vim vs gVim
    5. Configuring Vim with your .vimrc
    6. Common operations (or how to exit Vim)
      1. Opening files
      2. Changing text
      3. Saving and closing files
        1. A word about swap files
    7. Moving around: talk to your editor
    8. Making simple edits in insert mode
    9. Persistent undo and repeat
    10. Read the Vim manual using :help
    11. Summary
  8. Advanced Editing and Navigation
    1. Technical requirements
    2. Installing plugins
    3. Organizing workspace
      1. Buffers
      2. Plugin spotlight – unimpaired
      3. Windows
        1. Creating, deleting, and navigating windows
        2. Moving windows
        3. Resizing windows
      4. Tabs
      5. Folds
        1. Folding Python code
        2. Types of folds
    4. Navigating file trees
      1. Netrw
      2. :e with wildmenu enabled
      3. Plugin spotlight – NERDTree
      4. Plugin spotlight – Vinegar
      5. Plugin spotlight – CtrlP
    5. Navigating text
      1. Jumping into insert mode
      2. Searching with / and ?
        1. Searching across files
        2. ack
      3. Utilizing text objects
      4. Plugin spotlight – EasyMotion
    6. Copying and pasting with registers
      1. Where do the registers come in?
      2. Copying from outside of Vim
    7. Summary
  9. Follow the Leader - Plugin Management
    1. Technical requirements
    2. Managing plugins
      1. vim-plug
      2. Honorable mentions
        1. Vundle
        2. Do it yourself
        3. Pathogen
      3. Profiling slow plugins
        1. Profiling startup
        2. Profiling specific actions
    3. Deeper dive into modes
      1. Normal mode
      2. Command-line and ex modes
      3. Insert mode
      4. Visual and select mode
      5. Replace and virtual replace mode
      6. Terminal mode
    4. Remapping commands
      1. Mode – aware remapping
    5. The leader key
    6. Configuring plugins
    7. Summary
  10. Understanding the Text
    1. Technical requirements
    2. Code autocomplete
      1. Built-in autocomplete
      2. YouCompleteMe
        1. Installation
        2. Using YouCompleteMe
    3. Navigating the code base with tags
      1. Exuberant Ctags
      2. Automatically updating the tags
    4. Undo tree and Gundo
    5. Summary
  11. Build, Test, and Execute
    1. Technical requirements
    2. Working with version control
      1. Quick-and-dirty version control and Git introduction
        1. Concepts
        2. Setting up a new project
        3. Cloning an existing repository
        4. Working with Git
          1. Adding files, committing, and pushing
          2. Creating and merging branches
      2. Integrating Git with Vim (vim-fugitive)
    3. Resolving conflicts with vimdiff
      1. Comparing two files
      2. vimdiff and Git
        1. git config
        2. Creating merge conflict
        3. Resolving a merge conflict
    4. tmux, screen, and Vim terminal mode
      1. tmux
        1. Panes are just like splits
        2. Windows are just like tabs
        3. Sessions are invaluable
        4. tmux and Vim splits
      2. Screen
      3. Terminal mode
    5. Building and testing
      1. Quickfix list
      2. Location list
      3. Building code
        1. Plugin spotlight: vim-dispatch
      4. Testing code
        1. Plugin spotlight – vim-test
      5. Syntax checking code with linters
        1. Using linters with Vim
        2. Plugin spotlight – Syntastic
        3. Plugin spotlight – ALE
    6. Summary
  12. Refactoring Code with Regex and Macros
    1. Technical requirements
    2. Search or replace with regular expressions
      1. Search and replace
      2. Operations across files using arglist
      3. Regex basics
        1. Special regex characters
        2. Alternation and grouping
        3. Quantifiers or multis
      4. More about magic
        1. Magic
        2. No magic
        3. Very magic
      5. Applying the knowledge in practice
        1. Renaming a variable, a method, or a class
        2. Reordering function arguments
    3. Recording and playing macros
      1. Editing macros
      2. Recursive macros
      3. Running macros across multiple files
    4. Using plugins to do the job
    5. Summary
  13. Making Vim Your Own
    1. Technical requirements
    2. Playing with the Vim UI
      1. Color schemes
        1. Browsing the color schemes
        2. Common issues
      2. The status line
        1. Powerline
        2. Airline
      3. gVim-specific configuration
    3. Keeping track of configuration files
    4. Healthy Vim customization habits
      1. Optimizing your workflow
      2. Keeping .vimrc organized
    5. Summary
  14. Transcending the Mundane with Vimscript
    1. Technical requirements
    2. Why Vimscript?
    3. How to execute Vimscript
    4. Learning the syntax
      1. Setting variables
      2. Surfacing output
      3. Conditional statements
      4. Lists
      5. Dictionaries
      6. Loops
      7. Functions
      8. Classes
      9. Lambda expressions
      10. Map and filter
      11. Interacting with Vim
      12. File-related commands
      13. Prompts
      14. Using :help
    5. A word about style guides
    6. Let's build a plugin
      1. Plugin layout
      2. The basics
      3. Housekeeping
      4. Improving our plugin
      5. Distributing the plugin
      6. Where to take the plugin from here
    7. Further reading
    8. Summary
  15. Neovim
    1. Technical requirements
    2. Why make another Vim?
    3. Installing and configuring Neovim
      1. Checking health
      2. Sane defaults
    4. Oni
    5. Neovim plugin highlights
    6. Summary
  16. Where to Go from Here
    1. Seven habits of effective text editing
    2. Modal interfaces everywhere
      1. A Vim-like web browsing experience
        1. Vimium and Vimium-FF
        2. Alternatives
      2. Vim everywhere else
        1. vim-anywhere for Linux and macOS
        2. Text Editor Anywhere for Windows
    3. Recommended reading and communities
      1. Mailing lists
      2. IRC
      3. Other communities –  learning resources
    4. Summary
  17. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think
34.203.242.200