The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Be More Productive with Better Sublime Snippets for Ruby!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jan Lelis

Posts: 136
Nickname: rbjl
Registered: Aug, 2009

Jan Lelis is an IT student from Dresden/Germany
Be More Productive with Better Sublime Snippets for Ruby! Posted: Dec 9, 2015 10:25 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Jan Lelis.
Original Post: Be More Productive with Better Sublime Snippets for Ruby!
Feed Title: rbJ*_*L.net
Feed URL: http://feeds.feedburner.com/rbJL
Feed Description: Hi, I am a fan of Ruby and like to explore it and the world around ;). So I started this blog, where I am publishing code snippets, tutorials for beginners as well as general thoughts about Ruby, the web or programming in general.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jan Lelis
Latest Posts From rbJ*_*L.net

Advertisement

Long time readers of this blog will remember that I used to tweak GNOME’s gedit editor a lot. However, I ditched it for Sublime Text and I am not looking back. Here are some of the things I like about Sublime:

  • Offers a good out-of-the-box experience, including an amazing “fuzzy search” tool (ctrl+p)
  • It works on ubuntu without any problems
  • Fast (enough)
  • Multiple cursors!
  • Once you have installed Package Control: An integrated extension repository
  • Encourages you to write your own extensions
  • Looks good

Some of the things I dislike about Sublime:

  • Bad syntax highlighting for Ruby (more on this in a later blog post)
  • Default support for programming languages is often broken or outdated
  • Not happy with the default snippets for Ruby and ERB

Introducing “Productive Snippets for Ruby”

The stock Ruby snippets are not particularly bad. But I had problems with the scope they cover. For example, they provide a snippet for “transaction”, which is very Railsish. Also, a lot of snippets for Test::Unit are included. It has workarounds for 1.8 (e.g. getting singleton class), which are not needed any more (2.0 is the oldest officially support Ruby version). And all in all, you will notice a different style across all snippets.

To repeat myself: I am not saying the default snippets suck. What I want ist to have a consistent selection of snippets with more “modern” idioms. And without support for specific gems, other than rake or bundler. This is, what the ProductiveSnippetsRuby package will give you. You can install it via sublime package control.

Removing the Default Snippets

The snippets are meant as a replacement for the default ones, but there is no simple way to remove them. You have to do it manually (at your own risk, of course):

  • Find out where your sublime system packages folder is. This differs depending on your operationg system and how you installed sublime. For example, on my ubuntu machine it is /opt/sublime_text/Packages (not ~/.config/sublime-text-3/Packages).
  • Look for a file called Ruby.sublime-package and backup it
  • Then unzip the file into an extra directory and change into that directory
  • Delete all *.sublime-snippet files (or keep some that you like – for example ProductiveSnippetsRuby does currently not have snippets for all the Enumerable methods).
  • zip together the rest, call it Ruby.sublime-package again and move it to the location of the original file

ERB

The default behaviour in ERB files is wrong, because some tab triggers (e.g. if) generate php code. This is caused by an error in the PHP.sublime-package. If you don’t use PHP, the simplest way to get rid of the wrong snippets, will be to just delete the PHP package (or move it away). You can find it in the same directory where the Ruby.sublime-package is (see last paragraph).

Then install some Rails-free ERB snippets or use this alternative.

CC-BY (DE)

Read: Be More Productive with Better Sublime Snippets for Ruby!

Topic: Action Cable demo by DHH in Rails 5 Previous Topic   Next Topic Topic: Weaponized Agile

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use