iA Writer and VimRoom

I think apps like iA Writer are cool -- the idea is to remove all unnecessary GUI chrome to allow the author to focus on the content:

As soon as you type the title bar disappears and all you see is the clean typing sheet, distraction-free, ready for your ideas to take shape. With over 600,000 copies sold, Writer has helped students, journalists, and bestselling authors to find more pleasure in working with text.

Vim, by default, isn't far off this anyway. I find it works great as a tool for the type of technical writing that I do, in addition to the usual programming chores. That's partly due to the amount of code I write inside documentation: trying to write code samples without a dedicated code editor is tricky to say the least.

Read More →

Script Roundup: Bbye, Enhanced JavaScript Syntax

Bbye

Bbye (GitHub: moll / vim-bbye, License: Affero GPL) by Andri Möll allows buffers to be closed without changing Vim's window layout:

Vim by default closes all windows that have the buffer (file) open when you do :bdelete. If you've just got your splits and columns perfectly tuned, having them messed up equals a punch in the face and that's no way to tango.

Once Bbye is installed, you can use it with :Bdelete to unload the current buffer.

Read More →

Open Line on GitHub

Felix Geisendörfer recently wrote Vim Trick: Open current line on GitHub. The idea is to open a repository with GitHub in a browser for the current file and line number in Vim.

GitHub allows you to link directly to line numbers using fragment identifiers. For example, if I wanted to link to line 7 of index.jade which is used to generate this blog, I can share index.jade#L7.

Felix's tip uses a Git alias and xargs and open, along with nnoremap, to figure out the URL of the current file and open it. He also notes that fugitive.vim includes :Gbrowse for doing the same thing.

Read More →

Mobile Vim Cheat Sheet

I have a relatively long daily commute, so I like to use the time productively: if I get a seat on the train I'll work on my blog posts and books, otherwise I'll read on my Kindle. One thing I'd like more of is resources for learning new skills on mobile devices: I think services like Code School are great, but they'd be better if they could cache content for offline reading and had responsive designs so I could learn on the go.

The cheat sheet on an Android device.

This mobile-friendly Vi cheat sheet is partly like that -- it's a cheat sheet that'll look good on your desktop or mobile device. It could work as a companion to VimTouch, or perhaps even something you can use as a mobile flash card for memorising new commands.

There's a discussion on Hacker News about it, where HN readers have submitted suggestions and fixes.

Read More →

Script Roundup: vim-arpeggio, Matchmaker

vim-arpeggio

Thai Pangsakulyanont sent in vim-arpeggio (GitHub: kana / vim-arpeggio, License: MIT/X), by Kana Natsuno. It can be used by setting up aliases. For example, :Arpeggio inoremap fun function, allows the keys fun to be pressed simultaneously to type function.

The vim-arpeggio documentation is detailed, and includes instructions for supporting keyboards without n-key rollover.

Matchmaker

Matchmaker highlights keywords based on a regular expression.

Gez Page sent in Matchmaker (GitHub: qstrahl / vim-matchmaker, License: Vim) by Quinn Strahl. It will highlight words that match the current keyword under the cursor. It can be enabled with :Matchmaker.

Read More →

Include File Searches

Include file searches (:help include-search) can be useful for navigating around large files. You can do things like:

  • List the first line that contains the keyword under the cursor
  • List all lines that match the keyword under the cursor
  • Jump to the first line that contains the keyword under the cursor

Although this feature is tailored to C by default, it can be adapted to work with other languages with some configuration.

Examples

Displaying the first line that matches the keyword.

Download jquery-2.0.3.js and open it in Vim. Move the cursor to line 35 (35G) then move the cursor over document and press [i. At the bottom of the screen you'll see document = window.document, -- Vim is indicating the first match of this keyword from the start of the file. You can also try ]i which shows the next match from the cursor's position.

Read More →

VimGenius

The VimGenius start page.

VimGenius is a web-based service for learning and practicing Vim. It's influenced by VimTutor, but is structured around levels much like Code School. You can pick beginner or intermediate courses depending on your current skill level.

The start of the beginner course.

The first page you see after starting the beginner course shows the material that will be covered by the subsequent exercises. You're expected to memorise these commands. If you forget any, which is likely, you can ask for a hint by pressing the right arrow key.

An exercise at VimGenius.

Exercises work by posing a question, like "delete two words", to which you respond by typing the equivalent key sequence. Questions are timed, so you can improve your response speed over time.

Read More →

Script Roundup: vim-node, ctrlp-tjump

vim-node

vim-node (GitHub: moll / vim-node, License: Lesser GNU Affero General Public License) by Andri Möll is inspired by Rails.vim and Rake.vim. It adds shortcuts for jumping to modules and keyword searching.

When in Normal mode:

  • Use gf on require() to jump to the source file
  • Use [I on a keyword to look for it in the current and required files

ctrlp-tjump

ctrlp-tjump (GitHub: ivalkeen / vim-ctrlp-tjump) by Ivan Tkalin extends CtrlP to support fuzzy search for tags: when the cursor is over a class or method, use :CtrlPtjump to list matching tags. This replaces the :tjump command.

Read More →

Repeat Side-Effects

I'm writing a book in an XML format derived from DocBook, and I often have to deal with repeated lines of XML with incremented numbers:

<callout arearefs="co1">Here be dragons.</callout>

That example is from a code listing that has been annotated with "callouts" -- they're numerical symbols that point to descriptive text, making code examples easier to follow.

I found myself yanking and putting these lines of XML, then doing :s/1/2/, :s/1/3, etc. I realised there must be a better way, so I searched for tips on CTRL-A, which is Vim's increment command. I found an awesome tip on the Vim Wiki that basically did what I wanted: Increasing or decreasing numbers: Making a list.

Read More →

Powerline Escape Fix

Last week I wrote about Powerline Alternatives, and there was also a Hacker News thread about vim-airline where one of the posters had this useful tip about Powerline:

The delay in leaving insert mode used to drive me nuts in vim-powerline. I posted an issue and the author pointed me to this helpful Vim config snippet as a workaround (original link gone as the vim-powerline issue tracker has been removed, so reposting as a gist): https://gist.github.com/brendonrapp/5944296.

The issue is that Powerline causes a delay when leaving Insert mode, but this can be fixed by changing the InsertEnter timeoutlen setting to 0:

Read More →