Script Roundup: vim-nerdtree-tabs, Recover.vim

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

vim-nerdtree-tabs

Something that I see a lot of people asking about is how to make NERD Tree stay open across all tabs. vim-nerdtree-tabs by Jiří Stránský is a plugin that can do this. All expanded and collapsed file tree nodes will appear the same in every tab, and it can be configured to always open when Vim launches.

It also automatically closes the panel when the last file is closed, so NERD Tree is never left hanging open by itself.

It comes with several commands, mappings, and configuration options.

Read More →

Vim 101: Help Tags

I've seen many people confused by Vim's help system, particularly when installing a new plugin. An IRC friend of mine had installed Tim Pope's rails.vim, and couldn't work out why :help rails didn't work. The reason for this is Vim has to be told about new help files through the :helptags command.

Vim itself has documentation for :helptags in :help :helptags, and the command can be abbreviated to :helpt. Running it with the directory your plugin was installed to will make the help file available.

Let's say you've installed rails.vim to ~/.vim/bundle/vim-rails because you use Pathogen, then to generate the help tags you'd have to type :helpt ~/.vim/bundle/vim-rails/doc.

Read More →

Christmas Gifts for Vim Hackers

It's testament to how popular programming and Vim have become that it's not actually too difficult to come up with gift ideas for Vim hackers. This year has seen some cool projects take off thanks in part to crowdsourcing sites, but also due to a resurgence of interest in Vim.

Here are just some of my gift ideas for Vim hackers.

Book: Practical Vim

Practical Vim

Read More →

Script Roundup: rsi.vim, Tablify

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

rsi.vim

rsi.vim (GitHub: tpope / vim-rsi, License: Vim) by Tim Pope adds Readline/Emacs-style bindings to Vim. It does sometimes feel like everything apart from Vim has the same shortcuts, and so Tim has made a plugin that brings them to Vim without overriding commonly used existing bindings.

The Readline mappings work in the Insert and Command-line modes. You can review the mappings here: rsi.vim.

Tablify

Tablify (GitHub: Stormherz / tablify) by Vladimir Shvets turns structured data into tables. Pressing \tt turns a selection into a table with left-aligned text. The example from the readme is as follows:

Read More →

Vim 101: Insert Mode Shortcuts

When editing a file in Insert mode, it sometimes feels restrictive in terms of editing shortcuts. However, many shortcuts used elsewhere in Unix and other text editors are available. For example, CTRL-w (:help i_CTRL-W) will delete the word before the cursor, and CTRL-u (:help i_CTRL-U) will delete the current line. Pressing CTRL-[ (:help i_CTRL-[) quits Insert mode and goes back to Normal mode.

There's even a shortcut for putting text from a register: CTRL-r {reg} (:help i_CTRL-R). This is extremely useful when working with the system paste buffer.

You may already know about these, but CTRL-n and CTRL-p (:help CTRL-N) will invoke Vim's auto completion, displaying a menu of matches.

Read More →

Vimulator

Vimulator

The Vimulator (GitHub: thoughtbot / vimulator, License: MIT) project by thoughtbot is a simulation of certain Vim features that provides a novel way to visualise how edits are made. In the blog post about Vimulator, George Brocklehurst describes the reasons behind its creation:

"Vim's just not designed for demonstrations, and for a beginners talk at a Stockholm Vim meetup I needed something that looked a little less magical. The solution was to write Vimulator, a JavaScript Vim simulator that's designed to explain each key stroke as it happens and delay the effect on the text long enough for a casual observer to see what's going on."

Read More →

Script Roundup: textobj-indblock, qfnotes

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

textobj-indblock

textobj-indblock (GitHub: glts / vim-textobj-indblock) is a set of text objects for selecting whitespace based on the current line's indentation. It supports Visual and Operator-pending modes, and it built with textobj-user by Kana Natsuno.

qfnotes

qfnotes (GitHub: khorser / vim-qfnotes) by Sergey Khorev allows files to be annotated using a quickfix window. With a file open, pressing \qn displays a prompt for a note, and then notes can be loaded later with :QFXLoad. If search or compiler output overwrites your notes, then :colder will refresh them.

Read More →

Vim 101: The Vim Distribution

If you're a Vim beginner, it's likely that you've seen a screencast, blog post, or colleague that employs a wide range of impressive Vim plugins. This might be the reason you've been compelled to learn Vim, and why you're reading yet another Vim 101 post.

However, before you rush off to install lots of plugins, take some time to look at what actually comes with Vim. The raw Vim distribution, without any operating system package manager interference, comes with some command-line scripts, syntax highlighting files and colour schemes, autoload scripts, and several plugins.

Scripts

As well as vim, you should also be able to run vimtutor and vimdiff. The vimtutor command opens Vim with a tutorial that's worth trying if you've never seen it before.

Read More →

Operator-Pending Mode

Reading through public dotfiles is one of the ways that I research articles for usevim, and also how I learn new Vim techniques. However, one thing that I find surprisingly lacking is operator-pending mappings (:help omap-info). To understand this cryptic term, you need to revisit operators and motions.

After typing an operator command, Vim will wait for a motion. For example, typing yw when in Normal mode will yank the word under the cursor: y is the operator command and w is the motion. The operator is said to be pending in the time between typing the operator command and the motion.

Operator-pending mappings can be used to map characters during this time.

Read More →

Script Roundup: TabLineNumbers, yankstack.vim

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

TabLineNumbers

TabLineNumbers (License: WTFPL), by Dmitry Konishchev and added to vim.org by Alexander Tarmolov, adds numbers to tabs in Vim. The original plugin can be found on Dmitry's blog, and this edited version has comments in English. It uses a function that rebuilds the tabline, inserting numbers and close symbols as required.

yankstack.vim

yankstack.vim (GitHub: maxbrunsfeld / vim-yankstack, License: Vim) by Max Brunsfeld allows yank, delete, and put to act more like a stack by changing the behaviour of the default register. This is inspired by the Emacs kill ring.

The stack can be displayed by typing :Yanks, the output of which is similar to :reg.

Read More →