Vim - Change Colorscheme Based on Iterm profile

I like to change my (neo)vim colorscheme quite frequently, and when I do I want it to match my iterm colors. Many colorscheme authors also provide an iterm color palette, so you can import the .itermcolors file, create a new iterm profile with that palette, start a new session and you have the same vim colorscheme in your iterm. But then, when you launch vim, you still have to type :colorscheme somecolor....

December 19, 2016 · 2 min · metalelf0

Vim - sort ruby methods by name

Yesterday I had to refactor a very large ruby class. It had a lot of methods and, to make it cleaner, I decided to sort methods alphabetically. Is there a way to do this in vim? Of course there is, and it’s quite tricky - so let’s see how we can do it. The basic idea is taken from this post on wincent.com, I just adapted it for ruby. All credits to this guy for his work :)...

July 29, 2016 · 2 min · metalelf0

Vim regexp example: make a variable out of params

Today I wrote a regexp to change params[:page] into page. Here you are: :'<,'>s/params\[:\(\p\{-}\)\]/\1/g Let’s explain it briefly: the first part, :'<,'>s/, is the vim command to substitute a pattern (or a regexp) with another one. The <,'> part tells vim to operate on the visually selected text. the second part is the trickiest one. Let’s see it part to part: params\[: is the first part of the string we want to match....

July 9, 2012 · 2 min · metalelf0

Add bundle dir to your ctags

Ctags are a great way to improve navigation between large codebases. Used together with vim they allow to quickly jump to any method definition with just a keystroke - C-]. Adding your bundle dir when generating the tags file will allow jumping to the internals of the ruby gems you are using. Let’s see how to do this. The setup needed is the following: install Exuberant Ctags. I suggest using brew install ctags, and remember to fix your $PATH so that running ctags --version shows Exuberant Ctags....

March 26, 2012 · 2 min · metalelf0

The right colors for your VIM

I have a lot of Vim colorschemes, and I like to change them very often, reflecting my mood. I needed a way to showcase them all and quickly pick one. The original Vim Color Scheme Test script by maverick.woo is written in Perl and the build works on Windows systems. I wanted to add some new features, and to test it with my own colorschemes, but as I’m not very confident with Perl, I preferred to start over with a new Ruby version instead of forking his project....

February 6, 2012 · 2 min · metalelf0