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 →

Vim 101: Let

Over the last few weeks on Vim 101 I've been writing about :set and :setlocal. These commands are used to display and change Vim's settings. There are other times when you'll need to store values outside of built-in settings. In particular, plugin documentation may state that a variable can be set to control its behaviour.

For example, the amazingly popular NERD tree plugin uses several variables that you can change or query:

  • NERDTreeShowHidden: Show or hide hidden files
  • NERDTreeShowLineNumbers: Show line numbers in the NERD tree window
  • NERDTreeMinimalUI: Hide the Bookmarks label

These are just a few examples, NERD tree actually has a lot more! To change one of these variables, use the :let command:

Read More →

ViCiOUS for Xcode

ViCiOUS from 5vor9 is a commercial ($19.95) Xcode plugin that makes Xcode behave like Vim. I've previously talked about XVim, a Vim keybinding plugin for XCode, but ViCiOUS is more elaborate. It supports various editing modes: Normal, Visual, and Visual Block are all supported. The current mode is displayed in the top-right of each editing window. Selections can be yanked into named registers, and my most frequently used motions work as well (like f and t).

ViCiOUS editing status

Repeat works (.) but @: doesn't seem to be supported. Macros work, and the mode display changes to read (recording) just like Vim.

Read More →

Script Roundup: vimcat, SlowDown.vim

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

vimcat

vimcat (GitHub: kitover / vimpager) is a script for printing out syntax highlighted code to the terminal. It's based on the vimpager project by Rafael Kitover.

This script is a little bit like less.sh (which you should have as part of your Vim distribution), but it's more elaborate. It uses a combination of shell and Vim scripting to get Vim to work as a supercharged pager.

SlowDown.vim

SlowDown.vim (GitHub: artemave / slowdown.vim, License: Vim) by Artem Avetisyan is a plugin for slowing down Vim. It causes an input delay, therefore compelling you to reconsider the commands you're using.

Read More →

Vim 101: Auto Settings

Over the last few weeks I've been writing about :set and :setlocal, but I haven't yet touched on how Vim sets options itself. I don't usually find myself getting into a mess trying to visualise how I arrived at a particular cocktail of settings, but it's useful to have a generalised picture of how Vim loads settings when starting up and opening files.

When Vim starts, it reads the .vimrc found in $HOME or $VIM, depending on your platform. This file is a list of Ex commands, and after they're processed plugin scripts are loaded. Other files are also read -- the entire process is documented in detail under :help initialization.

Another way options are set is when a file is opened using autocommands. Autocommands associate files with commands, which means anything can happen when any file is opened. This is typically used to associate editor settings with specific programming languages. FileType can also be used, so I have this in my .vimrc:

Read More →

Integrating Vim and GPG

In Integrating Vim and GPG by Andrew Cowie, the author describes a GPG-based workflow for encrypting notes.

He discovered vim-gnupg (GitHub: jamessan / vim-gnupg, License: GPL2) by James McCoy, which provides a transparent means of editing GPG encrypted text files. When opening a file with a recognised extension (.gpg, .pgp., .asc) it'll encrypt and decrypt the file as required.

It works using the gpg binary, so you'll need to install that to use it.

Read More →

Script Roundup: dragee.vim, BufNameComplete

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

dragee.vim

dragee.vim by "emma-dev" is a Vim distribution that aims to improve the default settings, and make it easier to share Vim dotfiles. It uses a few Vim scripts and VAM to manage both settings and plugins.

Plugins are defined in the .vim/addon/rc file using a tree structure, core settings are stored in .vim/core and "patch" settings are kept in .vim/patch. Core settings are probably what you usually dump in your .vimrc file, while patch settings are plugin-specific settings. The example Emma uses is patch/endwise+double-tap.vim.

BufNameComplete

BufNameComplete by Ingo Karkat is a filename completion plugin that only matches filenames in the current buffer list. This is based on i_CTRL-X_CTRL-F (used in Insert mode) which displays matches for files in the current directory. For a bit of background on this plugin, see the following StackOverflow post: Vim Completion Based on Buffer Name.

Read More →