I like the idea that programmers should be eclectic:
eclectic [iˈklektik]: adjective deriving ideas, style, or taste from a broad and diverse range of sources: her musical tastes are eclectic.
Playing around with different languages, libraries, and systems can lead to new ideas. One of my favourite programming languages for experimentation has always been Lisp: nobody pays me to use it, but I enjoy it nonetheless.
YouCompleteMe (GitHub: Valloric / YouCompleteMe, License: GPL3) by Strahinja Val Markovic got a huge amount of attention last week (it's quickly approaching 1000 GitHub stars). It's a fuzzy code completion engine, and can use Clang-based semantic completion for C-family languages (including Objective-C).
Completion is invoked automatically, so it behaves more like GUI IDEs rather than Vim's built-in style of handling completion. The <Tab> key can be pressed to accept a match or cycle through results. The matching algorithm is based on the order of characters in a string, so a given sequence of characters can appear interleaved with other characters as long as the order they appear is the same.
You'll need a build system to install YouCompleteMe, and it can be compiled with or without support for semantic matching in C languages. The documentation covers all of this and more, including configuration and detailed command explanations.
Recently I've had several experienced Vim users tell me that they don't use marks. Mastering marks is just a question of practice, and the easiest way to get the hang of them is by using two commands:
:marks: This will list all of the current marks
'': Move to the position before the latest jump
Looking at :marks periodically will help you visualise how marks work. The '' command will potentially improve your workflow: it causes the cursor to move to the position before the previous jump.
Jumps are actually a class of motions. Motions are commands that move the cursor. When you move the cursor, Vim stores the previous position, and the previous position can be accessed with ''.
As I've mentioned before, I do freelance work as an iOS developer. This is, of course, awkward and painful as a Vim user because it can be a challenge to work productively outside of Apple's IDE. I like to keep tabs on resources for working with Vim and iOS/Mac development, so here's one of my latest finds: a detailed post by Benedikt Terhechte about using Vim as an Xcode alternative. The author explains how to install Clang Complete, and some additional libraries like surround.vim and ios.vim.
Inspired by the Vim London meetup, Rob Miller wrote movar (GitHub: robmiller / vim-movar) which adds some motions for moving around variables in PHP and Ruby. He's used the onoremap command with a function that builds up a string that searches using searchpos.
Typing av will select around a variable, while iv selects inner variables (thereby ignoring the variable's prefix, like $). These motions work with operators as well, so you can delete, change, or yank.
vim-fat-finger
vim-fat-finger (GitHub: chip / vim-fat-finger, Vim.org: fat-finger) by Chip Castle supports over 4,000 commonly typed misspellings, which are corrected using the iabbrev command. It doesn't have any settings, but the author has mentioned a toggle feature in the project's TODO file.
Two weeks ago I wrote a Vim 101 on tags, which introduced the basics for working with Vim's tag navigation tools. Something that I hinted at was using tags to help visualise a project's structure. Although Vim's raw editing operations are incredibly powerful, some of us need help in trying to visualise the structure of a project, and to navigate around it. I often find it takes a few hours or even days to get to grips with an already established code base.
There are several popular plugins designed to help visualise code through the use of tags. One such project, Tagbar (GitHub: majutsushi / tagbar, License: Vim, Vim.org: Tagbar) by Jan Larres displays a tag browser at the side of the screen. It automatically generates tags for the current file, and shows a menu of functions and methods, classes, and even things like macros if you're working with C.
I usually find I'll break out Tagbar when I'm trying to figure out the overall structure of files within a new project. Then once I've got a feel for it I'll switch back to a combination of tag navigation and searching.
One thing that came out of my talk on Custom Motions at Vim London was the idea of instinctively hitting the escape key to leave a mode. I first started to think about this when I came back to my computer and the screen had slept. I hit a key in order to wake the screen, and then I was presented with a Vim session. Since I didn't know exactly what key I'd hit, I pressed escape because I knew that would put Vim back into a familiar state.
If you also find yourself doing that, it's probably because at one time or another you've accidentally entered into Operator-pending mode. Vim has no visual indication when this mode is active -- it's like a sub-mode of Normal mode.
Send in your Vim scripts for review through our contact form.
Vimpanel
Vimpanel (GitHub: mihaifm / vimpanel) by "mihaifm" is a new tree explorer, influenced by NERD Tree. Panels can be created based around projects, and can be comprised of different folders and files as required. Sessions are supported, so the state of panels and windows can be reloaded after exiting Vim.
Vimpanel is more like the project navigation panels found in GUI text editors like Sublime Text or TextMate, rather than being purely oriented around file system navigation.
Seek
Seek (GitHub: goldfeld / vim-seek, License: Vim) by Vic Goldfeld shows we still haven't mined the depths of the flexibility provided by the concept of motions. It provides a new motion, s, which works like f. Where f takes a single character as an argument to jump to the next occurrence, Seek takes two characters, thereby reducing the number of potential matches.
Continuing on from last week's Vim 101 on tags, another useful element to a tag-based workflow is the preview window (:help preview-window). There's only ever one preview window per tab page, and it can be used to display tag definitions without interruption.
Typing :ptag tagname will open the preview window for "tagname". If you follow through last week's tutorial using Vim's source, you could type :ptag curbuf to see the definition of EXTERN buf_T in src/globals.h. When the window opens, it won't steal focus, which makes it essential for quickly looking up function signatures without wrecking your concentration when you need to navigate back.
If you type :ptag again, Vim will display "tag 1 of 2 or more" (this will be automatically displayed when there's no other message). Typing :ptnext or :ptprevious allows you to navigate between the matching tags.
Powerline has been rewritten in Python. The old Vim script version is still available at Lokaltog / vim-powerline. There was a discussion last year, Port core code to Python, where Lokaltog (Kim Silkebækken) discussed the merits of porting the core of Powerline to Python. As a result, the same statusline effect can be applied elsewhere: Zsh, Bash, and tmux are all supported.
The only slight wrinkle in this new version, however, is Python on Macs. The Powerline installation instructions have the innocuous line: pip install git+git://github.com/Lokaltog/powerline. Let's just say if you're using a Mac, you may be in for a bit of extra work. It's possible your Vim has been built with a different Python than the one pip uses. You might have even installed Python with Homebrew, and you could have even installed Vim Homebrew as well. Either way: your particular environment might not work out of the box.
If you do have problems running the new Powerline, this comment in the GitHub repository explores it in some detail: Mac OSX 10.8.2 (Fails to load properly). The thing to do is type :python import sys; print(sys.path) from within Vim to determine which site-packages folder should be used to install the Powerline Python module.