Testing One-off Scripts

I was recently teaching some non-programmers Ruby, and I used TextMate 2 as the editor. The reason I used TextMate 2 was because it's open source, easy to install, and can run Ruby programs with a quick press of cmd-r.

It seems like a lot of people miss this feature when they switch to Vim. Thomas Allen wrote a post about how to write your own program execution mappings, called Testing One-off Scripts in Vim. The basic idea is to create a Vimscript dictionary that maps file types to command-line programs, so you can type <C-p> to run a script instead of :w !python, or the equivalent command for your programming language.

I liked Thomas's example because even though it's written with Vimscript, which is known for being inscrutable, it's easy to follow and extend. This may help you ease yourself into Vim from your previous editor of choice.

Read More →

Script Roundup: t9md

A sample of t9md's work.

A reader sent in t9md's GitHub profile, which contains some cool Vim projects:

  • vim-choosewin has a tmux-inspired window numbering system
  • vim-ezbar is a minimalist status bar plugin
  • vim-smalls supports EasyMotion-style jumping with highlighting, fold skipping, and more features
  • vim-chef, a plugin for jumping around Chef recipes

The person that sent this in said they discovered t9md when looking at Shougo's .vimrc. He has also written lots of cool Vim projects, like Unite.vim and NeoBundle.

There are many more plugins than the ones I've mentioned here, so I think it's worth exploring t9md's projects to see what else he's made.

Read More →

Why Atom Can't Replace Vim

Why Atom Can't Replace Vim by Mike Kozlowski discusses why we love Vim:

Vi is fundamentally built on command composability. It favors small, general-purpose commands that can be combined with objects to compose larger commands. By contrast, Emacs and its philosophical descendants (including Sublime Text and Atom) use monolithic, special-purpose commands.

And composability is about more than just power, it's also learnability and consistency. The command for copying text in Vim is y. Do you know how to copy to the end of the line/file/paragraph? Of course you do: It's y$, yG, and y} respectively. The command for increasing the indent is >, so you instantly know >$, >G, and >}. Convert to lowercase is gu, so... sure enough: gu$, guG, gu}.

Read More →

LLDB Vim Frontend

Ahoy there, fellow binary wrangler. If you work with LLDB and want better Vim integration, then you may want to take a look at Tobias Pflug's vim-lldb. It's a fork of LLVM's Vim plugin -- the goal of the fork was to simply remove the pathogen dependency and improve the documentation.

Tobias thinks the script is useful but underused, so he'd like to get people to try it out. It requires Vim 7.3 and above, and the lldb executable needs to be in the current path.

It supports breakpoints, watchpoints, threads, and locals. That's pretty much everything I use from Xcode anyway, minus the beachballs which I hear are an exclusive feature baked into Xcode.

Read More →

Script Roundup: Wipeout, Patternjump

Wipeout

Wipeout by Artem Nezvigin is a small plugin that closes all buffers that are not open in any tabs or windows. It's adapted from this Stack Overflow question.

Patternjump

Patternjump (GitHub: machakann / vim-patternjump, License: NYSL) by Masaaki Nakamura is a plugin for defining cursor jumps based on patterns. The patterns can be per-mode, so you can limit them to Normal, Visual, Operator-pending, Command-line, and Insert modes.

Patterns can have a head or a tail, or both. "Head" patterns will cause the cursor to move to the first matching character, and tail moves to the end. It's like a DSL for defining complex motions. The documentation explains everything in much more detail than the readme and vim.org pages, so dive in there if you're interested.

Read More →

Atom has a Vim Mode

Atom

Atom is a desktop text editor that supports Node and is based on web technology.

Yes, there's a Vim mode. I haven't yet had a chance to try it out, but I've requested a beta invite. Incidentally, a beta invitation for an open source text editor seems weird to me.

Read More →

Neovim

Neovim (GitHub: neovim / neovim) is a project to "aggressively refactor" Vim. Some of the project's goals are:

  • Migrate to CMake
  • Switch to libuv for I/O
  • Replace the plugin architecture
  • Change how GUIs are handled

Neovim was started by Thiago de Arruda, who has created some innovative patches for Vim. His work on threads in particular has drawn interest from sites like Hacker News and reddit.

He announced the project on the vim_dev mailing list. Bram Moolenaar responded, and a heated debate followed:

Read More →

Script Roundup: excel.vim, ExtractLinks

excel.vim

excel.vim (GitHub: yakiang / excel.vim, License: MIT) by Yakiang Zhong is a Python-based script that can display the data from an Excel file. You can install the necessary Python module with pip install xlrd, and it will display each worksheet as a separate tab which is cool.

I'm one of those people that opens everything in Vim, so I quite like the idea of this plugin.

ExtractLinks

ExtractLinks by Ingo Karkat helps manage long links in arbitrary text snippets. If you're writing a Markdown file, or a comment for a post on a site like Stack Overflow, then :ExtractLinks can help manage lists of references to keep the text tidy.

Read More →

Non-Blocking Vim

A few weeks ago, I wrote about Thiago Arruda's multithreaded Vim port. A reader sent in a link to Thiago's second attempt which changes the approach.

Rather than threads, it uses a job manager that polls for I/O events. If I understand the patch correctly, it uses select with a zero timeout to multiplex I/O, then poll for the results.

Internally, polling is done in a function that replaces ui_inchar and interrupts the blocking wait every 100 milliseconds to check for job activity. When a job sends some data, it returns a special key code to the calling loop, which will trigger the autocommand, similar to how the CursorHold event is implemented.

Read More →

Why I Use Vim Powered by Gif

I found Why I Use Vim by Jonathan Warner on /r/vim, and I thought it was worth sharing due to the serious amount of gifs.

Some concepts are easier to illustrate graphically, and animations definitely help me when I'm trying to learn new Vim tricks. Most of the ideas the author mentions are what I would consider Vim essentials, but they're illustrated in really practical ways.

He's got real code in the examples, so it helps see how to use the suggested techniques in daily editing chores.

Read More →