Script Roundup: tbone.vim, Niji

Send in your Vim scripts for review through our contact form.

tbone.vim

tbone.vim (GitHub: tpope / vim-tbone, License: Vim) by Tim Pope provides some integration between Vim and tmux. The :Tmux command executes arbitrary tmux commands with tab completion, and :Tyank and :Tput gives you access to tmux's buffers.

Would you like to paste a shell command into another pane over and over again? I am sorry but you will have to install one of the 300 other Vim plugins for tmux.

Niji

Niji (GitHub: amdt / vim-niji, License: Vim) by Alastair M. D. Touw is another rainbow parentheses plugin that has been influenced by previous similar plugins, including RainbowParenthsis.vim, Lisp.vim, and rainbow_parentheses.vim.

Read More →

Spellchecker Wrangling

I've been writing a whole lot of XML lately. Doesn't sound like fun, does it? Well, it's not all that bad, because I'm well-versed in working with XML in Vim.

One oddity you'll run into when editing XML is spell checking won't work as expected. This is partly because of how the XML syntax file is configured ($VIMRUNTIME/syntax/xml.vim). To force Vim to check spelling, you can run these commands:

:set spell
:syntax spell toplevel

Afterwards, press CTRL-l to redraw the screen so you can see any spelling mistakes. The last command basically forces spell checking in text where the syntax file hasn't defined any other behaviour. If you've got an XML file open, you should see spell checking in each element's content, but tags themselves will be ignored.

Read More →

VimSpeak: Control Vim with Speech Recognition

VimSpeak by "AshleyF" is a program that allows you to speak to Vim:

You can say "select three words" to type v3w or "change surrounding brackets to parens" to type cs]) or crazy things like "change occurrences of 'foo' into 'bar', globally, ignore case, confirm" to type :%s/foo/bar/gic. Of course in insert mode you may dictate whatever you like. To learn the grammar, have a look at the unit tests and the code.

There's an introduction video on YouTube that explains how the source for VimSpeak works, and how to use it:

Read More →

Script Roundup: MarkMyWords, breeze.vim

Send in your Vim scripts for review through our contact form.

MarkMyWords

MarkMyWords (GitHub: dahu / MarkMyWords, License: Vim) by Barry Arthur allows you to create bookmarks for files and Vim's documentation. Creating a bookmark is as simple as typing :MMWMarkLine, and jumping to a bookmark is performed with :MMWSelect <tag>.

The bookmarks are saved in markmywords.tags, so anything you save should be available between sessions.

Breeze

Breeze (GitHub: gcmt / breeze.vim, License: MIT) by Giacomo Comitti is a plugin for working with HTML. It has EasyMotion-inspired navigation, tag matching, element highlighting, and DOM navigation.

Read More →

Irregular Expressions

Believe it or not, Vim's regular expressions are unique. They're not Perl-compatible regular expressions, or even POSIX regular expressions. Many tools that you use day to day as a programmer use the Perl compatible (PCRE) C library. It's BSD licensed and widely adopted. Also, programming languages themselves often use Perl-derived regular expressions.

Therefore, it's not surprising that Vim's non-standard pattern matching language brings puzzlement to newcomers, but it's simply a question of heritage. Vim is derived from vi, which evolved from ed. Now, ed itself dates back to 1971, when it was created by Ken Thompson, who also created Unix. So the next time someone bemoans Vim for not supporting PCRE, you can say "so what? Did Larry Wall invent Unix as well?!"

In Vim's version of the universe, we have "patterns", and they have some interesting irregularities next to PCRE. While I was researching this post, I found Vim Regexes by Andrew Radev that introduces Vim's regular expression modes, keyword patterns. This is a great introduction to some of the features that make Vim's patterns unique. He also references Refining search patterns with the command-line window on Vimcasts.org, which is a tutorial that will help you build complex search patterns.

Read More →

E492: Not an editor command: W

I was looking at dotfiles on GitHub for something completely unrelated, and noticed this snippet by Gianni Chiappetta:

" Remap :W to :w
command W w

This will help when :W is accidentally typed instead of :w and Vim displays E492: Not an editor command: W. I occasionally do this when I'm making a lot of rapid changes and my finger lingers on the shift key.

Creating an alias with :command (or :com for short) will result in something slightly different to the real :w though, because it won't copy the arguments. Ingo Karkat posted a response to a Stack Overflow question about the same problem: Is there a way in vim to make :W to do the same thing as :w?.

Read More →

Script Roundup: Join, reprocessed.vim

Send in your Vim scripts for review through our contact form.

Join

Join (GitHub: sk1418 / Join) by Kai Yuan is an enhanced :join command. It can join lines with a separator, trim whitespace, join lines in reverse and even join lines while leaving the original content.

The command's syntax is :[range]Join[!] [separator] [count] [flags]. The GitHub project readme has further details and screenshots.

reprocessed.vim

reprocessed.vim (GitHub: willpragnell / vim-reprocessed) by Will Pragnell brings some Processing support to Vim. It adds syntax highlighting for the Processing language, documentation integration, and it can invoke sketches from Vim.

Read More →

Practical: Joining and Splitting Text

The J (:help J) command is the kind of thing that seems suboptimal when initially learning Vim, but I find I use it with surprising regularity:

Join [count] lines, with a minimum of two lines. Remove the indent and insert up to two spaces (see below).

I even used it to join the previous lines after I pasted them from Vim's manual! The weird thing is, there's no equivalent "split" command. You might be tempted to split text on a single line using a regular expression, and while that does the job there are other ways to do it. Let's look at one method that uses registers as an excuse to practice working with registers and repeats.

Read More →

Vim's Startup Screen

vim-startify

vim-startify (GitHub: mhinz / vim-startify, License: Vim) by Marco Hinz adds a startup screen to Vim with a menu that displays recently used files, sessions, and bookmarks. It effectively replaces Bram Moolenaar's message with something potentially productivity enhancing, particularly if you like using sessions.

If, for some reason, you like the idea of customising the startup message, but don't want to use vim-startify, then take a look at :help 'shortmess'. This is a setting that can be placed in your .vimrc to customise Vim's behaviour when it starts up. For example, to turn off Bram's message, use I:

Read More →

Script Roundup: vim-table-mode, Gundo

Send in your Vim scripts for review through our contact form.

vim-table-mode

vim-table-mode (GitHub: dhruvasagar / vim-table-mode, License: MIT) by Dhruva Sagar is an Emacs-inspired Table Mode plugin that makes it easier to work with ASCII formatted tables. The author wrote a blog post with a bit of background behind the plugin (it was derived from earlier work by Tim Pope), and some videos that illustrate how it works.

Using Table Mode is dead simple. You simply start typing on a new line with the table separator - |g:table-mode-separator|, and you just type away! The plugin does the rest automatically for you as you type. With each additional separator you add, it aligns the table properly, without having to do anything else.

Gundo

I was going through Steve Losh's plugins, after referencing Learn Vimscript the Hard Way in a talk I gave earlier this year about Vim. I stumbled on Gundo (GitHub: sjl / gundo.vim, License: GPLv2+), which was released before I started writing usevim, but I thought it was worth writing about because I know many people struggle with Vim's undo system.

Read More →