Skip to content

Instantly share code, notes, and snippets.

View gnapse's full-sized avatar

Ernesto García gnapse

View GitHub Profile

Switch To Vim For Good

This guide is coming from an email I used to send to newcomers to Vim. It is not intended to be a complete guide, it is about how I did the switch.

Some background: my decision to switch to Vim has been made a long time ago. Coming from TextMate 1, I wanted to learn an editor that is Open Source (so I don’t lose my time learning a tool that can be killed), cross platform (so I can use it everywhere), and powerful enough (so I won’t regret TextMate). For these reasons, Vim has always been the editor I wanted to learn, but it took me several years before I did it in a way that works for me. I tried to switch progressively, using the Janus Vim distribution for a few months, then got back to using TextMate 2 for a time, waiting for the next attempt… here is what finally worked for me.

Non Optional

  1. Watch the Derek Wyatt videos in order (at least the “Novice” ones for now): http://derekwyatt.org/vim/tutorials/
  2. Read the first part of this Sta
@gnapse
gnapse / xhr.js
Last active August 29, 2015 14:23 — forked from mythz/xhr.js
//Adds $.xhr and jQuery-like $.ajax methods to the prescribed namespace.
//Inspired from David Flanagans excellent cross-platform utils http://www.davidflanagan.com/javascript5/display.php?n=20-1&f=20/01.js
//Includes underscore.js _.each and _.extend methods
//modified to behave like jQuery's $.ajax(), not complete.
(function($) {
var win=window, xhrs = [
function () { return new XMLHttpRequest(); },
function () { return new ActiveXObject("Microsoft.XMLHTTP"); },
function () { return new ActiveXObject("MSXML2.XMLHTTP.3.0"); },
function () { return new ActiveXObject("MSXML2.XMLHTTP"); }
@gnapse
gnapse / post-notifications.coffee
Last active August 29, 2015 14:14
Some features implemented with and without reactive programming
Kefir.Observable.prototype.withIndex = (mapType, fn) ->
index = 0
this[mapType]((value) -> fn(value, index++))
ApiController = Ember.Controller.extend
# With reactive programming
# (also needs the function withIndex in the top of this file)
postNotifications: (startCallback) ->
@gnapse
gnapse / Testing.scala
Last active March 7, 2017 15:04
Testing if it's possible to have Scala class parameters not becoming instance attributes
// Regarding these discussions about Scala class constructor parameters:
// http://stackoverflow.com/questions/15639078/scala-class-constructor-parameters
// http://stackoverflow.com/questions/1889454/in-scala-how-do-you-define-a-local-parameter-in-the-primary-constructor-of-a-cl
// Class parameter `fake` is not prefixed by either `val` or `var`
class Testing(fake: Boolean) {
val buffer = if (fake) null else new StringBuilder()
def output(str: Any): Unit = {
// The class parameter `fake` is accessible beyond the construction phase
@gnapse
gnapse / keybase.md
Last active October 30, 2017 02:53

Keybase proof

I hereby claim:

  • I am gnapse on github.
  • I am gnapse (https://keybase.io/gnapse) on keybase.
  • I have a public key ASCLxlhSQ3ZoFyZr7YlHbhD-jI9RoitJ0FdwytXR6XEF7Qo

To claim this, I am signing this object:

@gnapse
gnapse / pr.md
Created August 26, 2013 18:38 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@gnapse
gnapse / visual-surround.vim
Created August 19, 2013 16:07
Convenient key-bindings for an easier use of the vim-surround plugin. See http://gnapse.github.io/2013/08/12/easier-use-of-the-vim-surround-plugin/ for details.
" Surround text currently selected in visual mode
" (The surrounded text is kept selected after being surround)
vmap <leader>" S"lvi"
vmap <leader>' S'lvi'
vmap <leader>` S`lvi`
vmap <leader>( S)lvi(
vmap <leader>{ S}lvi{
vmap <leader>[ S]lvi[
vmap <leader>< S>lvi<