Yan Pritzker photographer, entrepreneur, software engineer, musician, skier

Blog :: Git Workflows Book :: Dotfiles :: Photography :: About Me

TwitterCounter for @skwp

Get the news feed
Get updates by email
Follow me on twitter

hello, i'm yan

I am a photographer, entrepreneur, software engineer, guitarist, climber, and telemark skier

This blog is about startups, blogging, Ruby On Rails, virtualization and cloud computing, photography, customer service, marketing, ux and design, git, and lots more.

Enterprise intelligence with prediction markets

Find out what your team, colleagues and partners really know about the future — and leverage their knowledge to improve business decisions.

I'm the founder of Planypus, the place to share your plans!

Archives

Contact

Reach me at yan at pritzker.ws

The cleanest vimrc you’ll ever see

Posted 20 January 2012 @ 12pm Tagged vim Comments: 17 Comments

So many of us use vimrc files that are a frankenstein’s monster, cobbled together from spare parts, gists, and snippets from wikis. One day I decided I was no longer going to treat my vimrc as a garbage dump. As programmers, we strive toward well factored code, so why do we accept such ugly vimrc’s that are impossible to understand, and even worse impossible to share because of their complexity. Let’s stop the insanity! It turns out it’s very easy…

Since vim automatically loads everything in ~/.vim/plugin/, you can just add a directory like ~/.vim/plugin/settings and put each semantic piece in its own snippet. Put your keymaps in ~/.vim/plugin/settings/keymap.vim. Put your visual setup like font and colors into ~/.vim/plugin/settings/gui.vim, etc.

After I did this, I ended up with a vimrc that’s only about 90 lines long including very detailed comments about every section.

I think this is the cleanest vimrc you’ll see on the web. All my vim plugin settings are broken down into individual files, following a convention of one file per vim plugin that I use, plus some extra ones that are too small to be plugins.

Think your vimrc is better? Show me! I want to learn :)

My vimrc and the rest of my vim setup is available as part of my YADR (Yet Another Dotfiles Repo) project. Come check it out, I need alpha testers!


Convert rspec pending to xit with vim

Posted 3 January 2012 @ 12pm Tagged rspec, vim Comments: Be the first!

RSpec has two ways of disabling tests: pending and xit. Except one of them is truly evil. Pending actually still runs the before block even when it’s disabled. This is bad when you have a test with a very expensive before block. Changing the pending to xit is a great strategy, but tedious. Vimscript to the rescue! The functionality is available as part of my dotfiles repo, but you can just grab the script by itself and type ,rxit to use it on a file.

For more awesomeness, check out my dotfiles repo called YADR (Yet Another Dotfiles Repo), featuring 100% clean vimrc with all custom keymapping done in well factored scripts inside vim/plugin/settings, and a list of plugins perfectly tailored for Rails development, currently in alpha preview.


Learn to speak vim – verbs, nouns, and modifiers!

Posted 16 December 2011 @ 12pm Tagged vim Comments: 15 Comments

Using vim is like talking to your editor in ‘verb modifier object’ sentences, turned into acronyms

  • learn some verbs: v (visual), c (change), d (delete), y (yank/copy). these are the most important. there are others
  • learn some modifiers: i (inside), a (around), t (till..finds a character), f (find..like till except including the char), / (search..find a string/regex)
  • learn some text objects: w (word), s (sentence) p (paragraph) b (block/parentheses), t (tag, works for html/xml) there are others

To move efficiently in vim, don’t try to do anything by pressing keys many times, instead speak to the editor in sentences

  • delete the current word: diw (delete inside word)
  • change current sentence: cis (change inside sentence)
  • change a string inside quotes: ci” (change inside quote)
  • change until next occurrence of ‘foo’: c/foo (change search foo)
  • change everything from here to the letter X: ctX
  • visually select this paragraph: vap (visual around paragraph)

If you understand the verbs and objects you’re dealing with, you will soon realize that adding a new plugin and learning a new verb or noun exponentially increases your productivity, as you can now apply it in all the sentences you already know. It’s just like learning a language.

Let’s add some new text object plugins!

  • install surround.vim: vim-surround- you get a new noun, the ‘surround’ (s or S)
    • visually select a word and surround it with quotes: viwS”
    • change surround from single quote to double quote: cs’”
  • install vim-textobj-rubyblock – you get a new noun, the ‘ruby block’ (r)
    • delete current ruby block: dir (delete inside ruby block)
    • visually select a ruby function: var (visual around ruby block)
    • visually select the innards of a function: vir (visual inside ruby block)
  • install tComment – new verb: “gc” (go comment)
    • comment the current ruby method: gcar (go comment around ruby)

Now go out and learn a new verb or noun every day!

Resources and Further Reading


← Before