Send in your Vim scripts for review through our contact form.
vim-scroll-position
vim-scroll-position (GitHub: junegunn / vim-scroll-position) by Junegunn Choi is another plugin that uses Vim's sign feature (:help :sign-intro). This one displays the relative position of the cursor, and indicates the latest jump and change positions.
interactive-replace
interactive-replace (GitHub: hwrod / interactive-replace, License: MIT) by Harold Rodriguez adds a new command, :InteractiveReplace, which can be used to interactively substitute search matches.
Harold's documentation includes an example where variables are substituted for various values that stem from a ..
There are times when you're tempted to lift your hand from the keyboard to the mouse, idly wondering if there's a better way. One such case is taking text from a buffer and placing it into Command-line mode. For example, performing text substitution with %s, or invoking a shell command with :!. Many Vim users will reach for the mouse and use the operating system's copy and paste feature to do this, but there's a quicker way provided by Vim's registers.
The CTRL-R (:help i_CTRL-R) command can insert the contents of a register in Insert or Replace mode. This is known as a "special key" (:help ins-special-keys). The great thing about this shortcut is you can reuse it to put registers into Command-line mode. For example, let's say you've got some text you want to search for in a buffer. First yank the text into a register, and then paste it with CTRL-R:
In Normal mode, type "ayw to yank a word
Press escape, and then / to search
Then press CTRL-R and a to put register a
A shorter way to do this is to use the default register. Typing yw will yank up to the word boundary into the default register, and then typing CTRL-R_" will put it into the command-line. It's worth practicing using this, particularly if you haven't got used to working with registers yet.
Tern is an open source JavaScript project designed to run as a server that sends completion results to compatible editors. The author is looking for a "Vim expert" to help finish the Vim plugin. The project has an Indiegogo funding page and quickly met its goal.
"Tern is a piece of software. It dives into the muddy depths of a JavaScript system to locate the information that it was asked for. Combined with an editor plug-in, it can make the life of a JavaScript programmer a lot more pleasant."
The project was created by Marijn Haverbeke and is currently on GitHub, released under the MIT license. The source is based on the Acorn parser.
Send in your Vim scripts for review through our contact form.
obsession.vim
obsession.vim (GitHub: tpope / vim-obsession, License: Vim) by Tim Pope provides some sugar for working with Vim's session files. It automatically calls :mksession before exiting, and whenever the layout changes.
To start using it, type :Obsess with an optional file or path. Session files can then be loaded with vim -S or :source.
The search command, /, is actually a motion, which means it can be used with operators. Any operator can be combined with search just by typing the desired search and pressing return.
For example, when in Normal mode, d/,<CR> will delete up to a comma. Although dt, would be more efficient, there are times when a search is more specific and useful than the other motions.
Much like last week's HTML editing with text objects, understanding how this works in terms of Vim's grammar gives you a greater understanding that can improve your productivity. The lesson is simply that / can work as a motion, because motions are just instructions that move the cursor in some way.
Eloy Durán's port of MacVim, complete with a file drawer.
Here's a curious thing: a Mac-friendly file drawer GUI for MacVim. It was made by Eloy Durán, and is available at alloy / macvim on GitHub. To try it out, follow the build instructions on the fork's wiki.
The sidebar itself behaves as you'd expect: it's "global", so it always looks the same even when tabs are in use. It also works correctly in full-screen mode. File system commands like :cd are reflected in the drawer, and switching buffers causes the highlighted file to change.
The General settings panel has options that pertain to the file drawer, so you can change the side which it appears on and make it always open by default.
Send in your Vim scripts for review through our contact form.
VimL Parser
VimL Parser (GitHub: ynkdir / vim-vimlparser) by Yukihiro Nakadaira is a Vim Script parser that, given a suitable file, will output a parenthesized Polish prefix notation version of the script. For example, call vimlparser#test('.vimrc') will display a parsed version of your Vim configuration.
The project also includes tests, with examples of the expected output. The source in this plugin is pretty huge, so you might like to check it out if you want to see something extreme in Vim Script.
If you're working with XML or HTML, then the at and it text objects are useful. You can remember at with the mnemonic "a tag block", and it as "inner tag block". The difference is that at includes the tags.
Consider the following example:
<p><a href="http://example.com/1">This is a link</a> and <em>this is an emphasis</em>.
<a href="http://example.com/2">This is another link</a>, which points to another page.</p>
If I position the cursor anywhere inside the <em> tags and type dat, it'll remove the text and tags, because it means "delete a tag block":
I was searching GitHub to see what weird and wonderful characters people use for their 'listchars' setting. This all started because I was using a Chromebook, and the built-in shell had trouble displaying some of the characters I use for showing invisible characters. Looking at my .vimrc, I realised my 'listchars' setting hadn't been changed in years, and it was probably due a bit of refactoring.
The purpose of the 'list' (:help 'list') setting is to visualise tabs, spaces, and line endings. The 'listchars' setting (:help 'listchars', abbreviation: 'lcs') determines the strings that will be used when list mode is active. It includes just about everything a programmer generally needs for keeping track of pesky invisible characters:
eol: The character to show at the end of each line
tab: The characters used to show a tab. Two characters are used: the second will be repeated for each space
trail: Character to show for trailing spaces. This is probably the thing most of us are looking for
There are more settings which are all documented, but these are the ones that are used the most often. A typical 'listchars' setting might look like this:
Send in your Vim scripts for review through our contact form.
Git Gutter
Vim Git Gutter (GitHub: airblade / vim-gitgutter, License: MIT) by Andrew Stewart shows a symbol in the sign column to indicate where lines have been added, modified, or deleted. This is based on Git Gutter for Sublime Text 2.
Vim's documentation in :help sign-intro explains what the sign column is for if you're not familiar with it.
vim-nodejs-complete
vim-nodejs-complete (GitHub: myhere / vim-nodejs-complete) by Lin Zhang adds 'omnifunc' support for Node developers. For example, typing: