-
Notifications
You must be signed in to change notification settings - Fork 0
/
vim
11 lines (6 loc) · 2.61 KB
/
vim
1
2
3
4
5
6
7
8
9
10
11
Using Vim and Tmux Effectively
My greatest hurtle when learning to work with Vim was establishing a flow, particularly when navigating multiple files. Most editors, even most applications in general, use a tabbed interface that's become so universal nearly all implement the same keyboard shortcuts - and I've become damn good at it! Naturally then, I jumped into Vim without realizing how much this preconception would work against me.
Past experience told me to run one instance of Vim, a tab for each project, and multiple windows within each tab. That alone is a step up from most other editors. So I learned the tab commands and how to manage multiple current working directories, an issue I realized is merely a symptom of the larger problem - Vim wasn't built this way! In fact, tabs were only recently added in version 7.0, over a decade after the initial release(wiki link).
Finally, I've learned running multiple Vim instances makes for a far better workflow. This isn't always an option with other editors, but Vim is so fast and lightweight that changing my fundamental approach has definitely increased my productivity. The key is customizing a separate environment for each project, or even each task at hand. If you're already working with multiple shells throughout the day, this is much easier than it sounds. Any terminal tool that splits windows would work, but I've come to like Tmux since it's consistently available across all of my workstations and servers.
On every machine I use, I begin by checking for an existing Tmux session. If none are found, I attach to a new session with the same name as my user. When starting a new task, no matter how small it may seem initially, I create a new Tmux window with a very descriptive name - say "check qa diskspace" or "calendar widget bug" for example. Within that window I then customize an environment for the task at hand. That could consist of Vim splits, Tmux splits, SSH connections, tailing files, or anything else that happens along the way. The possibilites are endless, but generally it's just a split or two.
The real benefit is the entire development environment becomes a cheap resource. That's a radical departure from the massive software suites we know and love. Creating new environments takes seconds. Tweaking an environment only affects the current task so far less time is spent rearranging windows and files. Performance is unaffected by dozens, probably even hundreds, of environments. Keep one around for an issue that *might* popup again next month, it doesn't cost anthing. Switching contexts becomes instantaneous, as long as the old brain can keep up :)