Skip to main content

2014 | Buch

Pro Vim

insite
SUCHEN

Über dieses Buch

Pro Vim teaches you the real-world workflows, tips, and tricks of this powerful, terminal-based text editor. This book covers all the essentials, as well as lesser-known but equally powerful features that will ensure you become a top-level performant and professional user, able to jump between multiple sessions while manipulating and controlling with ease many different documents and programming files. With easy-to-digest chapters on all the areas you need to learn, this book is a key addition to your library that will enable you to become a fast, efficient user of Vim.

Using this book, you will learn how to properly configure your terminal environment and work without even touching the mouse. You will become an expert in how Vim actually works: how buffers and sessions work, automation through Macros and shell scripting, real-world workflows, and how to work efficiently and fast with plugins and different themes. You will also learn practical, real-world tips on how to best utilize Vim alongside the terminal multiplexer tmux; helping you to manage files across multiple servers and terminal sessions. Avoid common pitfalls and work with best practice ways to efficiently edit and control your files and sessions from the terminal interface.

Vim is an advanced power tool that is commonly recognized as being difficult to learn, even for experienced developers. This book shows you how to become an expert by focusing on not only the fundamentals of how Vim works, but also by distilling the author's own experiences learning Vim into an easy-to-understand and follow guide. It's time to bring your programming, editing, and workflow skills up to the professional level - use Pro Vim today.

Inhaltsverzeichnis

Frontmatter
Chapter 1. Vim Primer
Abstract
It seems that starting something new is always the hardest part, and the same is true of the topic of this book, Vim. But after that initial tension—once the ball starts rolling—we usually find that what we struggled with in the beginning now becomes easier, as we start flowing with the tide, rather than trying to fight against it. This common stumbling block is an important first point to remember: everything gets easier with experience and confidence.
Mark McDonnell
Chapter 2. Installation and Configuration
Abstract
You may find this strange, but this chapter is arguably one of the most important of the entire book. It’s also, ironically, one of the most daunting. The reason why is because it covers the fundamental aspects of setting up both Vim and your terminal environment to have saner configuration and key bindings/plug-in settings, as well as making the terminal and Vim look more visually pleasing than it would by default. For most readers, this time spent configuring our environment will be the key difference in how successful they are in learning and using Vim.
Mark McDonnell
Chapter 3. Fundamentals
Abstract
In this chapter, we’ll be reviewing the fundamental concepts of how Vim works. This includes looking at how Vim opens files and the different editing modes available. We’ll also take a quick look at features such as windows and tabs, which allow us to better manage our workspace environment.
Mark McDonnell
Chapter 4. Files
Abstract
In the previous chapter, you learned a lot about the fundamentals of Vim (commands, buffers, windows, tabs, editing modes, etc.), but before moving on to learning how you can edit files and their content, let’s first review the multitude of ways you can utilize Vim to open and manage multiple files.
Mark McDonnell
Chapter 5. Commands
Abstract
In this chapter, we’ll be looking at Vim’s editing capabilities. This is where we finally get to use Vim for its primary function: editing and manipulating text-based content.
Mark McDonnell
Chapter 6. Registers
Abstract
Vim provides a mechanism for allowing you to store arbitrary pieces of content in a list called a “register.” There are nine different registers; each one handles different content that has been placed into it, via a specific user action. We will see what these different registers are in just a moment.
Mark McDonnell
Chapter 7. Folding
Abstract
Folding is the process of compressing multiple lines of content into a single line. Once folded, the content can then be expanded by executing a specific key binding. This type of feature is typically prevalent in programming environments, but it can be useful for any type of content you happen to be working with. The decision to utilize folding comes down to whether you consider a particular threshold of complexity for your content to have been reached.
Mark McDonnell
Chapter 8. VISUAL-BLOCK Mode
Abstract
We’ve already seen how Vim allows us to visually select content and manipulate the selection, using a wide range of commands. But Vim also provides a variation of the selection feature known as VISUAL-BLOCK mode.
Mark McDonnell
Chapter 9. Bulk Command Processing
Abstract
Vim provides an incredibly powerful (and flexible) set of commands, which allow a set of arbitrary commands to be executed against an entire list. In Vim parlance a “list” could be one of the following: a group of open buffers, tabs, windows, and even Vim’s argument list (which I’ll explain near the end of this chapter).
Mark McDonnell
Chapter 10. Editing Workflow
Abstract
Editing in Vim is a combination of mode swapping and command execution. What this ultimately means is that to be comfortable editing in Vim requires practice—and lots of it. There are many resources available to help you practice (I cover some popular options at the end of the chapter). We’ll also be looking at some of the commands, operators, and editing tricks I personally use in my day-to-day workflow.
Mark McDonnell
Chapter 11. Search and Replace
Abstract
One of the cornerstones of a solid text editor is the ability to find files and content and to replace the latter with new content. Many editors provide a GUI abstraction on top of underlying code that implements the search criteria for you. Vim doesn’t try to hide it and, instead, exposes it to you via the COMMAND-LINE mode.
Mark McDonnell
Chapter 12. Buffer/Window/Tab Management
Abstract
Once you start becoming comfortable with how Vim works and its fundamentals (such as editing commands, registers, handling files, etc.), your next area of concern may well be your workflow. In this chapter, we’ll take a look at how best to manage our environment when working from buffers, windows, and tabs.
Mark McDonnell
Chapter 13. Automation
Abstract
Vim provides a myriad of solutions to the problem of automation. But what do we mean exactly by the phrase “automation”? Well, automation could be considered the act of preventing yourself from having to repeat any particular action.
Mark McDonnell
Chapter 14. Lists
Abstract
There are two types of lists in Vim: a “change list” and a “jump list.” They both work in fundamentally similar ways but offer subtly different solutions. The former allows us to move our cursor back and forth between a set of edits we’ve made to a buffer, whereas the latter allows us to move our cursor back and forth between a set of cursor jump points across multiple buffers.
Mark McDonnell
Chapter 15. Marks
Abstract
When you start dealing with large project code bases, you’ll likely find that being able to navigate through all your files (and even within individual files that are quite lengthy) can become quite difficult. Vim provides multiple ways to solve this problem (for example, vimgrep and specific plug-ins such as CtrlP—which we’ll see in Chapter 17—for fuzzy searching), but what if you already know the type of contents certain files contain, but you want an easy way to get back to specific sections more easily than carrying out the same search over and over?
Mark McDonnell
Chapter 16. Sessions
Abstract
In this chapter, I’m going to cover a topic that it would seem most other books on the subject of Vim ignore: sessions. The principal idea behind sessions is that we’re creatures of habit, and we typically find ourselves repeating things that we know and understand. Imagine a recurring project in which you end up having the same layout open (and maybe even the same files open). Why not record that setup into a session? It’ll make getting up and running much quicker.
Mark McDonnell
Chapter 17. Plug-ins
Abstract
Here we are, finally, at the section that new Vim users are usually most excited about: plug-ins! So why is this such an interesting part of the Vim experience? Well, this is where the fun part happens. You get to enhance Vim with all sorts of additional functionality. If you can imagine it, chances are someone has written a Vim plug-in for it. For some users, plug-ins are as much a part of their fundamental Vim experience as choosing a color scheme for your editor.
Mark McDonnell
Chapter 18. Diffing
Abstract
Regardless of whether you’re working with a Version Control System (such as Git/SVN/Mercurial) or not, being able to compare different versions of the same file can be very useful in the right circumstances.
Mark McDonnell
Chapter 19. Custom Commands and Bindings
Abstract
Once you feel as though you’ve mastered all that Vim has to offer, you will eventually decide that you want to optimize your efficiency even further, by abstracting away some of the commands that currently require multiple steps and reducing them to a few keystrokes. These optimizations are both fun and (in practical terms) useful when you become a heavy-duty Vim user.
Mark McDonnell
Chapter 20. Terminal Integration
Abstract
Although there are graphical user interface (GUI) versions of Vim, the original software was designed primarily around running Vim from the terminal environment. You’ll typically find that when you become comfortable using Vim, your workflow naturally tends to shift toward working more and more within the terminal environment as well. You’ll start to take an interest in more Unix/Linux-based commands (such as navigating through your file system and manipulating files and content), instead of using a separate suite of GUI applications.
Mark McDonnell
Chapter 21. Working with Code
Abstract
At the beginning of this book, in the introduction, I made a claim that Vim isn’t only for programmers, and that it is, in fact, a very serviceable text editor for many users, whether they be system operators, authors, or students. If you work with text, you will find immense value in working with Vim.
Mark McDonnell
Chapter 22. Practical Tips and Tricks
Abstract
We now have arrived at the final chapter for the Vim half of this book! I hoped you have enjoyed your journey so far and are excited at the prospect of using Vim as your future text editor of choice. What you are soon to discover is that the real fun with Vim starts here, because now that you are more than proficient at using Vim, you can begin to experiment and define your own workflow.
Mark McDonnell
Chapter 23. Terminal Multiplexer
Abstract
The terminal emulators we use on a day-to-day basis do their job admirably. Having direct access to the shell environment is a fundamental way of life for most software engineers, as it gives us a sense of power and efficiency that cannot be matched by GUI-based applications and mouse interactions.
Mark McDonnell
Chapter 24. Fundamentals
Abstract
In the previous chapter, we became acquainted with the concept of tmux and what this program could offer us in the way of resolving some standard terminal emulator annoyances. In this chapter, we’re going to start using tmux and investigate some of its different constructs and terminology, such as the following:
Mark McDonnell
Chapter 25. Modifications
Abstract
Using tmux “out of the box” is useful enough as it is, but most of the time, we’ll want to make our lives a little easier, by adding some additional customizations (such as we did in Chapter 23, when we added custom configuration to our .tmux.conf file).
Mark McDonnell
Chapter 26. Copy and Paste
Abstract
One of the most arduous tasks within tmux is the need to be able to copy and paste content from a buffer. The problem isn’t so much copying content from our buffer (although that isn’t the simplest of tasks, as we’ll see in the first few sections of this chapter), but more so that there is no native capability to paste content that has been copied from a tmux buffer into other external programs.
Mark McDonnell
Chapter 27. Pane/Window Management
Abstract
Being able to efficiently manage your tmux windows and panes is a skill that usually is acquired over a long period of time, as you find yourself becoming more comfortable with this powerful screen-management tool.
Mark McDonnell
Chapter 28. Scripting and Automation
Abstract
In this chapter, we’ll review some different built-in tmux commands that allow us to control to a very granular level how existing tmux sessions look and function, as well as modifying the boot-up process to open multiple sessions and to construct complex environment layouts within those sessions.
Mark McDonnell
Chapter 29. Pair Programming
Abstract
When using tmux, we sometimes forget how powerful the client/server model that it implements is. For example, we all know that because of the client/server model, we can create multiple sessions on a single server and then at any point, we can jump between sessions, as we are able to connect to any session on the tmux server that we have running in the background.
Mark McDonnell
Chapter 30. Workflow Management
Abstract
Software engineering and web development in particular have changed quite significantly over the past few years. We now have tools at our disposal that would seem almost magical in the past. In this chapter, I am going to demonstrate some of these programs alongside tmux and Vim, to show you how you can get a more realistic and accurate development environment. I’ll also be demonstrating use of the programs Reptyr and tmux-resurrect, so you can see how they fit into your typical workflow.
Mark McDonnell
Backmatter
Metadaten
Titel
Pro Vim
verfasst von
Mark McDonnell
Copyright-Jahr
2014
Verlag
Apress
Electronic ISBN
978-1-4842-0250-0
Print ISBN
978-1-4842-0251-7
DOI
https://doi.org/10.1007/978-1-4842-0250-0