Skip to content

Instantly share code, notes, and snippets.

@jzb
Created December 29, 2008 13:59
Show Gist options
  • Save jzb/41275 to your computer and use it in GitHub Desktop.
Save jzb/41275 to your computer and use it in GitHub Desktop.
Gist and Vim: Two great tastes that go great together
<p>A few weeks ago, I asked for recommendations for using Gist and Vim together. My appeal to Lazyweb went unanswered, but I happened to stumble onto a Gist plugin for Vim today, and so I'm putting out the procedure for anyone who wants to merge these two powerful forces.</p>
<p>So, first things first, grab yourself a copy of the gist.vim plugin over here on <a href="http://github.com/mattn/gist-vim/tree/master">github</a>. You will need a few things:</p>
<ul>
<li>Vim (of course...)</li>
<li>Git</li>
<li>Curl</li>
</ul>
<p>If you're running openSUSE, you should have Vim installed by default. If you don't have Git or Curl, just use zypper to install them:</p>
<p>
<code>zypper in git</code>
<code>zypper in curl</code>
</p>
<p>You'll also need to set up your Github account with your global Git configuration. To do this, go to your Github account page (<a href="https://github.com/account">https://github.com/account</a> when you're logged in) and click "Global Git Config." You should see something like this:</p>
<p>
<code>git config --global github.user <i>user</i><br />
git config --global github.token XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</code>
</p>
<p>Here <i>user</i> should be replaced with your username, and you should have a unique github.token.</P>
<p>Next, slap gist.vim into your ~/.vim/plugin/ directory, and fire up Vim. Gist commands are prefaced with, no big surprise, <code>:Gist</code>. Now let's look at how to browse Gist.</p>
<p><strong>Browsing Gist</strong></p>
<p>If you want to see your Gists, run <code>:Gist -l</code> or <code>:Gist -l <em>username</em></code> if you just want to see a specific user's Gists. To see everybody's (well, the last 10 in the public timeline) just run <code>:Gist -la</code>.</p>
<p>If you put the cursor on the Gist number in the display and hit enter, Vim will slurp down the file and open it for editing locally. Want to grab one of your own Gists to edit? Run <code>:Gist XXXXX</code> where <code>XXXXX</code> is the number of the gist.</p>
<p>
If you want to paste the current file in its entirety to Gist, just use <code>:Gist</code>.
<p>The only thing missing from gist.vim (as far as I know, anyway &#151; the existing documentation is very sparse) is a way to update an existing post on Gist.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment