<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Today I learned: Vim</title>
    <description>A blog documenting things I learn about Vim, on a (mostly) daily basis</description>
    <link>http://www.tilvim.com</link>
    <atom:link href="http://www.tilvim.com/feed.xml" rel="self" type="application/rss+xml" />
    
    <item>
      <title>Fuzzy finding with FZF.vim</title>
      <description>&lt;p&gt;I’ve been through my fair share of Vim file finding plugins. I first started with Command-T before moving on to CtrlP. I then stole a colleague’s set up which used Gary Bernhardt’s &lt;a href=&quot;https://github.com/garybernhardt/selecta&quot;&gt;selecta&lt;/a&gt; finder. &lt;a href=&quot;https://github.com/jackfranklin/dotfiles/blob/dad7546b3b558900d1b1069c52399a49cbc4c7b6/vim/vimrc#L207&quot;&gt;You can find the config for that in my old vimrc&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;That had been serving me well but I then stumbled upon Junegunn Choi’s excellent &lt;a href=&quot;https://github.com/junegunn/fzf&quot;&gt;fzf&lt;/a&gt;, a great fuzzy finder that (from my experience so far) seems incredibly quick and extremely reliable. Thankfully he’s also created &lt;a href=&quot;https://github.com/junegunn/fzf.vim&quot;&gt;fzf.vim&lt;/a&gt;, a Vim wrapper around some common functionality that fzf provides. It’s this that I want to show you today.&lt;/p&gt;

&lt;p&gt;Installing is fairly straight forward, and it’s recommended you use &lt;a href=&quot;https://github.com/junegunn/vim-plug&quot;&gt;Vim-Plug&lt;/a&gt; to do it:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
Plug &#39;junegunn/fzf&#39;, { &#39;dir&#39;: &#39;~/.fzf&#39;, &#39;do&#39;: &#39;./install --all&#39; }
Plug &#39;junegunn/fzf.vim&#39;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Once done you’ll have access to a bunch of new commands that will use fzf to find files, lines and more.&lt;/p&gt;

&lt;h2 id=&quot;finding-files&quot;&gt;Finding Files&lt;/h2&gt;

&lt;p&gt;You can use the &lt;code&gt;:Files&lt;/code&gt; command to search for files in your directory.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/fzffiles.gif&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;finding-commits&quot;&gt;Finding Commits&lt;/h2&gt;

&lt;p&gt;I’m also a big fan of the &lt;code&gt;:Commits&lt;/code&gt; command, which fuzzy searches through your git commits. Note that you need Fugitive.vim for this to work.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/fzfcommits.gif&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;matching-lines&quot;&gt;Matching Lines&lt;/h2&gt;

&lt;p&gt;You can also use the plugin in insert mode to perform linewise completition based on what you’ve already typed! I’ve mapped this like so:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
imap &amp;lt;c-x&amp;gt;&amp;lt;c-l&amp;gt; &amp;lt;plug&amp;gt;(fzf-complete-line)
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;As shown in the fzf.vim README. This is really useful when you need to type a line you know you’ve typed before - for example, an import or require statement. This is effectively Vim’s linewise completion on overdrive!&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/fzflinewise.gif&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;fzf.vim has really added a lot to my Vim setup and workflow - once you get used to fuzzy finding everything you’ll never look back, and I highly recommend giving it a go.&lt;/p&gt;

</description>
      <pubDate>Wed, 06 Jan 2016</pubDate>
      <link>http://www.tilvim.com/2016/01/06/fzf.html</link>
      <guid isPermaLink="true">http://www.tilvim.com/2016/01/06/fzf.html</guid>
    </item>
    
    <item>
      <title>Opening URLs from Vim</title>
      <description>&lt;p&gt;Big thanks to &lt;a href=&quot;http://twitter.com/smileykeith&quot;&gt;Keith Smiley&lt;/a&gt; for this tip to kickstart this blog once more!&lt;/p&gt;

&lt;blockquote class=&quot;twitter-tweet&quot; data-partner=&quot;tweetdeck&quot;&gt;&lt;p&gt;Just discovered gx in vim. Totally amazed at how often I find things that will massively improve my usage.&lt;/p&gt;&amp;mdash; Keith Smiley (@SmileyKeith) &lt;a href=&quot;https://twitter.com/SmileyKeith/status/564497433485246465&quot;&gt;February 8, 2015&lt;/a&gt;&lt;/blockquote&gt;
&lt;script async=&quot;&quot; src=&quot;//platform.twitter.com/widgets.js&quot; charset=&quot;utf-8&quot;&gt;&lt;/script&gt;

&lt;p&gt;From within Vim if you position your cursor over any URL and hit &lt;code&gt;gx&lt;/code&gt;, the URL will be opened in your default browser. Simple and incredibly effective!&lt;/p&gt;
</description>
      <pubDate>Sun, 08 Feb 2015</pubDate>
      <link>http://www.tilvim.com/2015/02/08/gx.html</link>
      <guid isPermaLink="true">http://www.tilvim.com/2015/02/08/gx.html</guid>
    </item>
    
    <item>
      <title>Tmux and Vim: the perfect combination</title>
      <description>&lt;p&gt;Last night at &lt;a href=&quot;http://www.meetup.com/Vim-London/&quot;&gt;Vim London&lt;/a&gt; I spoke about some of my favourite plugins and settings for Tmux and Vim that allow me to work with them as I do. It’s very rare these days that I won’t be editing code from Vim, within a Tmux session, but out of the box the immediate advantages of this pairing are not always obvious. It takes some time to get things working.&lt;/p&gt;

&lt;p&gt;The talk was recorded and I will update the post with it once it’s public, but for now I just wanted to link to some of the plugins and settings I mentioned in the talk that I use in &lt;a href=&quot;https://github.com/jackfranklin/dotfiles&quot;&gt;my dotfiles&lt;/a&gt;.&lt;/p&gt;

&lt;h4 id=&quot;tnew-alias&quot;&gt;&lt;code&gt;tnew&lt;/code&gt; alias&lt;/h4&gt;

&lt;p&gt;I create all my tmux sessions through an alias I have which I’ve called &lt;code&gt;tnew&lt;/code&gt;, which simply calls a function called &lt;code&gt;new-tmux-from-dir-name&lt;/code&gt; (this is taken from the &lt;a href=&quot;https://github.com/thoughtbot/dotfiles&quot;&gt;thoughbot dotfiles&lt;/a&gt;. The function looks like so:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sh
function new-tmux-from-dir-name {
  tmux new-session -As `basename $PWD`
}
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This does two things:
- when you create a new session, it names it based on the directory name
- if you are in a directory that already has a tmux session associated, &lt;code&gt;tnew&lt;/code&gt; will attach you back into the already existing session&lt;/p&gt;

&lt;h4 id=&quot;tmux--os-x-pbcopy&quot;&gt;Tmux + OS X, &lt;code&gt;pbcopy&lt;/code&gt;&lt;/h4&gt;

&lt;p&gt;By default tmux on OS X breaks the &lt;code&gt;pbcopy&lt;/code&gt; command. I’m not going to go into details, but thankfully &lt;a href=&quot;https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard&quot;&gt;Chris Johnsen’s fix&lt;/a&gt; has detailed instructions on how to get that functionality back, and it’s not too tricky either.&lt;/p&gt;

&lt;h4 id=&quot;renumber-windows&quot;&gt;Renumber windows&lt;/h4&gt;

&lt;p&gt;Out of the box, if you have 3 tmux windows numbered 0, 1, 2 and then you delete the one numbered ‘1’, you’re left with two windows: 0, and 2. This is rather odd when you navigate between them. However, you can tell tmux to renumber existing windows automatically with this line in your tmux config:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;
set-option -g renumber-windows on
&lt;/code&gt;&lt;/p&gt;

&lt;h4 id=&quot;vim-tmux-navigator&quot;&gt;vim-tmux-navigator&lt;/h4&gt;

&lt;p&gt;Without a doubt, this is the one thing that makes working with Vim and Tmux so much better, Chris Toomey’s &lt;a href=&quot;https://github.com/christoomey/vim-tmux-navigator&quot;&gt;vim-tmux-navigator plugin&lt;/a&gt;. By installing this and adding a few lines to your tmux config (instructions are in the README), this lets you seamlessly jump between Vim and tmux panes (or splits, as Vim calls them) with the same keystrokes. This means if you have a Vim split next to a tmux pane, you can hop between them even though one of them is Vim, and the other is tmux. It’s fantastic, and really ups the intergration of these two tools by another level.&lt;/p&gt;

&lt;h4 id=&quot;vimux&quot;&gt;Vimux&lt;/h4&gt;

&lt;p&gt;Although there are many choices, I personally have taken to using &lt;a href=&quot;https://github.com/benmills/vimux&quot;&gt;Vimux&lt;/a&gt;, a plugin which lets you send any command to a tmux pane (which it will create if it doesn’t already exist). This means I can set up mappings for running specific commands, such as for testing:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;viml
map &amp;lt;leader&amp;gt;nt :call VimuxRunCommand(&quot;clear; npm test&quot;)&amp;lt;CR&amp;gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It also has a function which you can run that will prompt you for a command, which I have mapped to &lt;code&gt;&amp;lt;leader&amp;gt;x&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;viml
map &amp;lt;leader&amp;gt;x :VimuxPromptCommand&amp;lt;CR&amp;gt;
&lt;/code&gt;&lt;/p&gt;

&lt;h4 id=&quot;tmux-complete&quot;&gt;tmux-complete&lt;/h4&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/wellle/tmux-complete.vim&quot;&gt;This plugin&lt;/a&gt; adds any word visible in a tmux pane to a completion function that you can trigger with &lt;code&gt;&amp;lt;C-X&amp;gt;&amp;lt;C-U&amp;gt;&lt;/code&gt;. It’s rare that I want to type something in Vim that I can see in a tmux pane, but when I do this plugin is always useful and saves coming out of Vim to grab some text.&lt;/p&gt;

&lt;p&gt;So that’s just some of the plugins I use daily when working with tmux and Vim. If you have any to recommend, please do leave a comment!&lt;/p&gt;
</description>
      <pubDate>Wed, 30 Jul 2014</pubDate>
      <link>http://www.tilvim.com/2014/07/30/tmux-and-vim.html</link>
      <guid isPermaLink="true">http://www.tilvim.com/2014/07/30/tmux-and-vim.html</guid>
    </item>
    
    <item>
      <title>Ruby text objects</title>
      <description>&lt;p&gt;Yesterday I discovered a text object within Vim that I’d not realised existed, which served as a perfect tip post up onto this blog (and to try and get back to doing it more regularly!).&lt;/p&gt;

&lt;p&gt;Any seasoned Ruby + Vim user has probably got Drew Neil’s &lt;a href=&quot;https://github.com/nelstrom/vim-textobj-rubyblock&quot;&gt;textobj-rubyblock&lt;/a&gt; plugin installed, which adds the text objects &lt;code&gt;ar&lt;/code&gt; and &lt;code&gt;ir&lt;/code&gt; to select around and inside a ruby block.&lt;/p&gt;

&lt;p&gt;However, what I didn’t know about was the text object &lt;code&gt;im&lt;/code&gt;, which is provided by vim-ruby (which comes with Vim by default), to select the contents within the current Ruby method, and its sibling &lt;code&gt;am&lt;/code&gt;, to select around the method. Hat tip to &lt;a href=&quot;http://twitter.com/tomstuart&quot;&gt;@tomstuart&lt;/a&gt; for that one:&lt;/p&gt;

&lt;blockquote class=&quot;twitter-tweet&quot; lang=&quot;en-gb&quot;&gt;&lt;p&gt;It took me a few minutes to work out how to select the body of a Ruby method in Vim, but I was happy when the answer turned out to be “vim”.&lt;/p&gt;&amp;mdash; Tom Stuart (@tomstuart) &lt;a href=&quot;https://twitter.com/tomstuart/statuses/489776294075592704&quot;&gt;July 17, 2014&lt;/a&gt;&lt;/blockquote&gt;

&lt;p&gt;Drew Neil (&lt;a href=&quot;http://twitter.com/nelstrom&quot;&gt;@nelstrom)&lt;/a&gt;) then followed up explaining that it was recently added to vim-ruby:&lt;/p&gt;

&lt;blockquote class=&quot;twitter-tweet&quot; lang=&quot;en-gb&quot;&gt;&lt;p&gt;&lt;a href=&quot;https://twitter.com/telemachus&quot;&gt;@telemachus&lt;/a&gt; it’s a text object defined in the vim-ruby plugin: &lt;a href=&quot;https://t.co/YZSmUPWr0P&quot;&gt;https://t.co/YZSmUPWr0P&lt;/a&gt;&amp;#10;Should be available out the box in recent Vim builds.&lt;/p&gt;&amp;mdash; Drew Neil (@nelstrom) &lt;a href=&quot;https://twitter.com/nelstrom/statuses/489802266170630144&quot;&gt;July 17, 2014&lt;/a&gt;&lt;/blockquote&gt;

&lt;p&gt;If you’re running a recent version of Vim you should have this functionality, but if you’re not, you can always install the latest version of vim-ruby as a plugin through Vundle / Pathogen. The best solution though if possible is to simply upgrade your Vim.&lt;/p&gt;

&lt;p&gt;Whilst reading to produce this blog post I also discovered the objects &lt;code&gt;iM&lt;/code&gt; and &lt;code&gt;aM&lt;/code&gt;, which select in and around the current Ruby class, too. All of these are going to be really useful in my day to day development.&lt;/p&gt;

</description>
      <pubDate>Fri, 18 Jul 2014</pubDate>
      <link>http://www.tilvim.com/2014/07/18/ruby-text-objects.html</link>
      <guid isPermaLink="true">http://www.tilvim.com/2014/07/18/ruby-text-objects.html</guid>
    </item>
    
    <item>
      <title>Recording Macros for Super Efficiency</title>
      <description>&lt;p&gt;Macros in Vim can be a great time saver, especially for complex and repetitive
line-editing tasks.
A macro is a way of recording a series of actions as a single command. I find this
especially useful when I need to make some formatting changes to a set of lines.
This is perhaps best illustrated by an example, but prior to that let us quickly
look at the syntax for recording and using macros in Vim.&lt;/p&gt;

&lt;p&gt;Recording a macro is split into three steps:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;code&gt;q&lt;/code&gt; followed by a letter to start recording. The letter can be any valid register
of your choice, e.g. &lt;code&gt;m&lt;/code&gt;. If successful you will see &lt;strong&gt;recording&lt;/strong&gt; in the
bottom left of the screen.&lt;/li&gt;
  &lt;li&gt;Carry out whichever actions you require. This isn’t constrained to just
one line of actions, though often this is practical.&lt;/li&gt;
  &lt;li&gt;Press &lt;code&gt;q&lt;/code&gt; again to stop recording.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Using a macro is simply a case of typing &lt;code&gt;@&lt;/code&gt; followed by the register
character chosen, &lt;code&gt;m&lt;/code&gt; in the previous example.&lt;/p&gt;

&lt;h1 id=&quot;a-brief-example&quot;&gt;A brief example&lt;/h1&gt;
&lt;p&gt;An example may make the benefits of macros clearer. Let’s say that we have
the following data in a file and we want to transform this into a CSV file. &lt;em&gt;This
chunk of data is from a wireless sensor network log file that really did need
converting to CSV.&lt;/em&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;StandDev (ToF): 2260ps, Mean (ToF): 64037ps, Errors: 0
StandDev (ToF): 2265ps, Mean (ToF): 66037ps, Errors: 0
StandDev (ToF): 2184ps, Mean (ToF): 82858ps, Errors: 1
StandDev (ToF): 3184ps, Mean (ToF): 82860ps, Errors: 1
StandDev (ToF): 1439ps, Mean (ToF): 55893ps, Errors: 0
StandDev (ToF): 2439ps, Mean (ToF): 75893ps, Errors: 3
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We can change this to form part of a CSV file with a quick macro:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Move to the first line we wish to edit (remember, the macro will capture all
commands, so if you execute a move
command in your macro it will happen on each run).&lt;/li&gt;
  &lt;li&gt;Start recording, &lt;code&gt;qm&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Execute our edit steps. This can be done in &lt;strong&gt;many&lt;/strong&gt; ways. The example
command sequence below prepares a single line by: moving to the start of the
line, systematically removing the words and units, adding a trailing comma.&lt;/p&gt;

    &lt;pre&gt;&lt;code&gt;  ^2df fpxxf 2df fpxxf df A,^[j
&lt;/code&gt;&lt;/pre&gt;

    &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;^[&lt;/code&gt; is the ESCAPE key&lt;/li&gt;
      &lt;li&gt;Note the move down to a new line at then end, &lt;code&gt;j&lt;/code&gt;. We don’t have to use
this approach, alternatives include starting our macro with a search, or
using the &lt;code&gt;normal&lt;/code&gt; command to run the macro on a selection of lines.&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Stop recording, &lt;code&gt;q&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With our macro recorded we can now easily run this on the remaining lines, in
our case five times, starting from the first unedited line using &lt;code&gt;5@m&lt;/code&gt;. As with
many efficient uses of Vim, the power in macros really becomes apparent for
cases where the task is very repetitive.&lt;/p&gt;

&lt;p&gt;Macros are a good way of making you think about the commands you are using. This
becomes more apparent when working on files that are varied. The example above was
originally taken from a log file that had many other lines of different data, some already in the
correct format.
To get to a relevant line for the macro to operate on I included a
search for ‘StandDev’ at the start of the recorded command sequence.&lt;/p&gt;

&lt;p&gt;Remember, &lt;code&gt;@&lt;/code&gt; simply
treats the proceeding register as a list of commands. This means a register used for a
macro can be viewed and edited in the normal ways. This provides a
convenient way to fix any mistakes made during the recording of a macro, by
editing the register. The &lt;a href=&quot;http://vim.wikia.com/wiki/Macros&quot;&gt;Macros&lt;/a&gt; page at
wikia has a good explanation of this, notably including a section on 
saving macros — really useful if you know you will need your
finely-crafted macro for future files.&lt;/p&gt;

&lt;p&gt;Hopefully this post has shown the advantages macros offer in Vim, especially for
those that do a lot of one-time text transformations.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Guest post by &lt;a href=&quot;http://twitter.com/mfalkus&quot;&gt;Martin Falkus (@mfalkus)&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
</description>
      <pubDate>Thu, 01 May 2014</pubDate>
      <link>http://www.tilvim.com/2014/05/01/macros.html</link>
      <guid isPermaLink="true">http://www.tilvim.com/2014/05/01/macros.html</guid>
    </item>
    
    <item>
      <title>Better Pasting from the Clipboard</title>
      <description>&lt;p&gt;Something I find myself doing fairly regularly is copying something from outside of Vim into Vim. Usually this is something like a chunk of code from a Stack Overflow post, or a new reference to add to my Bibtex file (I’m in the middle of my University dissertation…). The problem with pasting some code in is, as you’ve probably seen, that Vim tries to indent the code as you paste it. If the code already has indents (which usually it does) this is a bit of a nightmare, as you end up with incorrect indenting and have to perfom &lt;code&gt;==&lt;/code&gt; on a number of lines to correct it.&lt;/p&gt;

&lt;p&gt;There is a better way. We can run &lt;code&gt;:set paste&lt;/code&gt;, which tells Vim to be in &lt;em&gt;paste&lt;/em&gt; mode. In this mode, when you’re in insert mode and paste in, Vim will not perform any indenting itself, and let what you’re pasting in dictate it. You can then run &lt;code&gt;:set nopaste&lt;/code&gt; to turn off paste mode.&lt;/p&gt;

&lt;p&gt;This is good, but it’s still too many steps for me:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Exit insert mode.&lt;/li&gt;
  &lt;li&gt;Run &lt;code&gt;:set paste&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Go into insert mode.&lt;/li&gt;
  &lt;li&gt;Hit &lt;code&gt;Cmd+V&lt;/code&gt; to paste in.&lt;/li&gt;
  &lt;li&gt;Exit insert mode.&lt;/li&gt;
  &lt;li&gt;Run &lt;code&gt;:set nopaste&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That’s far too much work, and far too many keystrokes. Thankfully, we can turn this into a handy mapping. I should add that credit for this mapping goes to &lt;a href=&quot;https://github.com/r00k/dotfiles/blob/master/vimrc&quot;&gt;Ben Orenstein&lt;/a&gt;, as it was taken directly from his &lt;code&gt;.vimrc&lt;/code&gt; file, all I’ve done is write it up as I thought it warranted it. Here’s the mapping:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;map &amp;lt;Leader&amp;gt;p :set paste&amp;lt;CR&amp;gt;o&amp;lt;esc&amp;gt;&quot;*]p:set nopaste&amp;lt;cr&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Let’s step through that:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;code&gt;:set paste&amp;lt;CR&amp;gt;&lt;/code&gt; turns on paste mode&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;o&amp;lt;esc&amp;gt;&lt;/code&gt; inserts a new line below and goes back into normal mode&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;&quot;*]p&lt;/code&gt; gets the content from the system clipboard, and pastes it in.&lt;/li&gt;
  &lt;li&gt;&lt;code&gt;:set nopaste&amp;lt;cr&amp;gt;&lt;/code&gt; turns paste mode off.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The one oddity there is the use of &lt;code&gt;]p&lt;/code&gt; instead of &lt;code&gt;p&lt;/code&gt; to paste in. Vim’s help can solve that one, &lt;code&gt;:h ]p&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Like &quot;p&quot;, but adjust the indent to the current line.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Effectively it applies the indent within the pasted content from the indent level that you’re at when you invoke the pasting.&lt;/p&gt;

&lt;p&gt;This is a great example in my opinion of the power of Vim and its mappings - this mapping in particular is one I use multiple times a day and really does save me time and keystrokes.&lt;/p&gt;

</description>
      <pubDate>Tue, 18 Mar 2014</pubDate>
      <link>http://www.tilvim.com/2014/03/18/a-better-paste.html</link>
      <guid isPermaLink="true">http://www.tilvim.com/2014/03/18/a-better-paste.html</guid>
    </item>
    
    <item>
      <title>vim-dispatch: I should have used this years ago</title>
      <description>&lt;p&gt;&lt;a href=&quot;https://github.com/tpope/vim-dispatch&quot;&gt;vim-dispatch&lt;/a&gt; is a plugin by Tim Pope that I’d heard a lot about but never really understood the benefits or what it offered me…until now.&lt;/p&gt;

&lt;p&gt;Recently I’ve been working a lot with Makefiles. I’m writing my dissertation in Latex and compiling that through a Makefile, I have a couple of C projects which I’ve similarly used Makefiles to save me time, and I’ve also been using other build tools like Gulp, Grunt, or other command line tools like Bundle.&lt;/p&gt;

&lt;p&gt;Essentially, something I have to do quite a lot is quickly drop out of Vim to run something, usually one of the aforementioned tools or often my tests too. The problem with these is that they take my focus out of Vim. Most of the time as well, I only care about the result of the program I ran if something went badly. If everything went OK, I don’t need to know. So taking my focus out of Vim and losing where I was isn’t worth it most of the time.&lt;/p&gt;

&lt;p&gt;And that’s where Vim Dispatch comes in. It provides two commands. The first, &lt;code&gt;:Make&lt;/code&gt; wraps around Vim’s &lt;code&gt;:make&lt;/code&gt;, but runs it &lt;em&gt;asynchronously&lt;/em&gt;, in the background. Then, once its done, it populates the quickfix list with any problems or errors. If nothing bad happens, you don’t get disturbed. And, most importantly, &lt;strong&gt;at no point is your focus taken from Vim&lt;/strong&gt;. You can keep typing away and coding as your Make command runs in the background. The output from the command is added to the quickfix window, and the quickfix window is populated with the errors. If there is no error, there is no quickfix window population and nothing happens.&lt;/p&gt;

&lt;p&gt;If you don’t want to run Make, but would like to run other commands asynchronously, that’s possible too. Dispatch provides a &lt;code&gt;:Dispatch&lt;/code&gt; command for just this. Some examples:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;:Dispatch bundle install
:Dispatch rspec %
:Dispatch grunt test
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;These work exactly as the &lt;code&gt;:Make&lt;/code&gt; command, but will just run anything you pass it.&lt;/p&gt;

&lt;p&gt;Depending on the context on which you run Vim, Dispatch will run what you give it differently. In tmux, which is where I spend most of my time, it will open a split and run it there. If you’re in iTerm on a Mac, it opens a new window. If you’re not in either, it will just run it in the background entirely. It also has Windows support.&lt;/p&gt;

&lt;p&gt;And for those longer running tasks, you can use &lt;code&gt;:Make!&lt;/code&gt; and &lt;code&gt;:Dispatch!&lt;/code&gt;, which run in the background and don’t disturb you at all. When you need to get feedback from that task, you can hit &lt;code&gt;:Copen&lt;/code&gt; to view any output.&lt;/p&gt;

&lt;p&gt;I seriously recommend checking out Dispatch if you commonly find yourself jumping out of Vim to run a command. It’s really changed my workflow and decreased the time spent jumping out of Vim, which is a massive timesaver.&lt;/p&gt;
</description>
      <pubDate>Thu, 13 Mar 2014</pubDate>
      <link>http://www.tilvim.com/2014/03/13/dispatch.html</link>
      <guid isPermaLink="true">http://www.tilvim.com/2014/03/13/dispatch.html</guid>
    </item>
    
    <item>
      <title>Repeating last command-line with `@:`</title>
      <description>&lt;p&gt;Once you’ve used Vim for a while you become accustomed to repeating the last change in normal mode with &lt;code&gt;.&lt;/code&gt;. Being able to repeat actions easily lends itself to some efficient workflows and Vim also provides a way of repeating the last command-line action from normal mode using &lt;code&gt;@:&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I find &lt;code&gt;@:&lt;/code&gt; useful to repeat commands such as &lt;code&gt;:cn&lt;/code&gt; / &lt;code&gt;:cp&lt;/code&gt; to navigate the quickfix list, &lt;code&gt;:bd&lt;/code&gt; to easily close a bunch of files and to repeat the last substitution.&lt;/p&gt;

&lt;p&gt;See &lt;code&gt;:help @:&lt;/code&gt; for more.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Guest post by &lt;a href=&quot;http://twitter.com/_walkermatt&quot;&gt;Matt Walker (@_walkermatt)&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
</description>
      <pubDate>Wed, 29 Jan 2014</pubDate>
      <link>http://www.tilvim.com/2014/01/29/repeat-cmdline.html</link>
      <guid isPermaLink="true">http://www.tilvim.com/2014/01/29/repeat-cmdline.html</guid>
    </item>
    
    <item>
      <title>Automatic Comment Prefixing Revisited</title>
      <description>&lt;p&gt;A while back, I wrote about &lt;a href=&quot;http://tilvim.com/2013/05/29/comment-prefix.html&quot;&gt;removing Vim’s automatic comment prefixing&lt;/a&gt;. This behaviour is turned on by default, and is best shown with an example:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# some comment {cursor here}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If I was to hit &lt;code&gt;o&lt;/code&gt; or &lt;code&gt;O&lt;/code&gt;, to insert on the line above/below, or be in insert mode and hit enter, Vim would automatically add the comment prefix for me, so it would look like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# some comment
# {cursor here in insert mode}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Vim has automatically added the &lt;code&gt;#&lt;/code&gt; for me.&lt;/p&gt;

&lt;p&gt;I am not a fan of this, and in my original post I advised adding this line to your vimrc to fix it:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;set formatoptions-=or
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;However, that stopped working for me (I’m not sure when - or if it’s related to a new Vim version). Today I managed to figure out the solution. This line does the trick:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt; autocmd FileType * setlocal formatoptions-=r formatoptions-=o
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;To be honest, I’m not sure why the original doesn’t work, and if anyone does, please leave a comment, as I’d be really interested to know why. If you’ve had the same problem, try the new line and see if that solves it.&lt;/p&gt;

</description>
      <pubDate>Mon, 30 Dec 2013</pubDate>
      <link>http://www.tilvim.com/2013/12/30/remove-comment-prefix-2.html</link>
      <guid isPermaLink="true">http://www.tilvim.com/2013/12/30/remove-comment-prefix-2.html</guid>
    </item>
    
    <item>
      <title>Swapping Pathogen for Vundle</title>
      <description>&lt;p&gt;I’ve been a big fan of Tim Pope’s &lt;a href=&quot;https://github.com/tpope/vim-pathogen&quot;&gt;pathogen&lt;/a&gt; for managing my Vim plugins. I wrote a small Ruby script to manage the process of cloning from GitHub, and everything was fine.&lt;/p&gt;

&lt;p&gt;However, recently, a lot of people have been talking about &lt;a href=&quot;https://github.com/gmarik/vundle&quot;&gt;Vundle&lt;/a&gt;. Vundle takes the process of cloning repositories and manages it all for you, so there’s a lot less work for you to do manually.&lt;/p&gt;

&lt;p&gt;The process of setting up Vundle is very straight forward. Firstly, clone Vundle:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now it’s just a case of editing your vimrc. Vundle requires you to add a few lines to your vimrc file. Make sure these lines are at the very top:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Vundle requires &lt;code&gt;filetype&lt;/code&gt; to be off initially, but once you’re finished adding Bundles, you can set it to be on again. Next, load in some bundles. Note that you have to load in the &lt;code&gt;vundle&lt;/code&gt; repo first:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Bundle &#39;gmarik/vundle&#39;
Bundle &#39;tpope/vim-endwise&#39;
Bundle &#39;tpope/vim-git&#39;
Bundle &#39;tpope/vim-surround&#39;
...and so on...
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Vundle will look on GitHub by default for those URLs, but you can also pass it a direct Git URL or even a local Git path.&lt;/p&gt;

&lt;p&gt;After all your &lt;code&gt;Bundle&lt;/code&gt; calls, you are free to add whatever you like to your vimrc, including setting &lt;code&gt;filetype&lt;/code&gt; back to on:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;filetype on
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now, you can install your plugins by running &lt;code&gt;:BundleInstall&lt;/code&gt; within Vim (you’ll need to restart Vim or source your vimrc once more before). In the future, if you want to update your plugins, you can run &lt;code&gt;:BundleInstall!&lt;/code&gt; to update. If you remove a plugin from your vimrc, you can run &lt;code&gt;:BundleClean&lt;/code&gt; to remove the old plugin.&lt;/p&gt;

&lt;p&gt;For me, the main advantage of Vundle is less overhead on my part. I’ve been able to delete my Ruby script for managing my Vim plugins, and the &lt;a href=&quot;https://github.com/jackfranklin/dotfiles/commit/62861ec9e0c6b811b783298ea1ffa994401686e0&quot;&gt;relevant commit in my dotfiles&lt;/a&gt; shows just how much I was able to delete. Keeping the configuration within the &lt;code&gt;vimrc&lt;/code&gt; and just using Vundle’s functions to pull everything together makes a lot of sense.&lt;/p&gt;

</description>
      <pubDate>Sat, 28 Dec 2013</pubDate>
      <link>http://www.tilvim.com/2013/12/28/pathogen-for-vundle.html</link>
      <guid isPermaLink="true">http://www.tilvim.com/2013/12/28/pathogen-for-vundle.html</guid>
    </item>
    
  </channel>
</rss>