Using rails-footnotes with vim/gVim

Netbeans, Ruby on Rails No Comments »

Few gems or plugins speed up Rails development like rails-footnotes by José Valim and others. Especially useful is its ability to open files directly in the a text editor from Firefox.

Out of the box, this gem works with Textmate, but it’s quite easy to get it to work with Netbeans. To apply the same process for Vim/gVim integration, proceed like so:

Adjust Filter Prefix

Change your configuration in environment.rb of your Rails project to, for example:

if defined?(Footnotes)
Footnotes::Filter.prefix = ‘gvim://open?url=file://%s&line=%d&column=%d’
end

The protocol can be anything you like, this will now be configured in Firefox.

Configure Firefox

Open about:config in your Firefox location bar and

Right Click > New > String “network.protocol-handler.app.gvim” with content ~/.editor_gvim.rb

Right Click > New > Boolean “network.protocol-handler.external.gvim” with value true

Create Editor Script

Create a script, for example in you home directory, and don’t forget to make it executable:

touch ~/.editor_gvim.rb && chmod +x ~/.editor_gvim.rb

The script could look like so:

#!/usr/local/bin/ruby
file = ARGV.first.split(’file://’).last.split(’&’).first
line = /\&line\=(\d+)/.match(ARGV.first)[1] rescue 0
`gvim –remote-tab-silent “+#{line}” #{file}`
`wmctrl -a “GVIM”`

The last two lines are delimited by backticks and it’s two hyphens (- -) before remote-tab-silent, which might all get eaten by Wordpress, so be sure to adjust after copying and pasting the code above.

Install wmctrl

sudo aptitude install wmctrl

Adjustments

The command in the script above

`gvim –remote-tab-silent “+#{line}” #{file}`

will open each file in a new tab.

If you want every file in a new buffer, simply change it to

`gvim –remote-silent “+#{line}” #{file}`

Finally, nothing stops you from opening the file in gVim and Netbeans simultaneously just by adding

`”/path/to/your/netbeans/executable” “#{file}:#{line}”`

`wmctrl -a “Netbeans IDE 6.5.1″`

NB will usually pick up all the changes automatically but in gVim you’ll have to reload with :e!

The Vim/gVim startup options are not easy to fathom (options go before files etc.), but here is the the documentation.

Update:

Here’s a version which also sets the current vim directory (check with :pwd) to your rails root (prevents overwhelming fuzzy finder):

#!/usr/local/bin/ruby
file = ARGV.first.split(’file://’).last.split(’&’).first
line = /\&line\=(\d+)/.match(ARGV.first)[1] rescue 0
rails_root = /\&rails_root\=(.*)/.match(ARGV.first)[1] rescue ‘~’
`gvim –remote-silent “+cd #{rails_root}” “+#{line}” #{file}`
`”/home/dirk/netbeans-6.5.1/bin/netbeans” “#{file}:#{line}”`
`wmctrl -a “Netbeans IDE 6.5.1″`
`wmctrl -a “GVIM”`

With these settings in environment.rb:

if defined?(Footnotes)
  Footnotes::Filter.prefix = “gvim://open?url=file://%s&line=%d&column=%d&rails_root=#{Rails.root}”
end

Vimperator

Now with the Vimperator plugin for Firefox you have round-trip development with gVim and Firefox without touching the mouse.

Hope it helps.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Fixing FuzzyFileFinder::TooManyEntries

Vim/Gvim No Comments »

If you get

FuzzyFileFinder::TooManyEntries

edit your ~/.vim/plugin/fuzzyfinder_textmate.vim file and set the following line to a higher value, for example 50000

let g:fuzzy_ceiling = 10000

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

gh-pages -> gh-pages (non-fast forward) when creating github project page

Git No Comments »

If you get

! [rejected] gh-pages -> gh-pages (non-fast forward)

when following the instructions to create a github project page, you might just try to delete the gh-pages branch

git push origin :gh-pages

and then push the gh-pages branch again

git push origin gh-pages

Hope it helps.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Rubyonrails.org Stolen?

Uncategorized No Comments »

Here in Thailand I currently get the page below at http://www.rubyonrails.org and http://www.rubyonrails.com. The domain name registration seems to be ok, but there was an update yesterday (April 20th). And it’s a garish parking page that in the colors of Django?! Is it some regional DNS screw-up? Am I mistyping Ruby?

UpdateJust checked via US-based proxy, the issue is confirmed, it’s not a regional Asian DNS snafu.

Update 2The same happened last year and it looks like it happens every year around April 20th, April Fools + 20 or sth.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

“Delete Facebook Account” Most Popular Deletion at Google

Unspecific Ramblings No Comments »

So the most popular search term starting with “delete” seems to be “delete facebook account”. In the face of recent changes to “fan” and profile settings that “deepen the marketing graph“, it could become even more popular. Wonder what all the buzz is about…

Delete Facebook Account Google

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in