You have an existing block of text or code in vim. You want to re-format it to wrap to 80-characters.
:set textwidth=80
You might want this setting to apply automatically within certain file types like Markdown:
au BufRead,BufNewFile *.md setlocal textwidth=80
We have that setting in thoughtbot/dotfiles.
Select the lines of text you want to re-format:
v
Reformat it:
gq
Learn more:
:h gq
Written by Dan Croak.
We recently switched from RVM to rbenv for managing Ruby versions.
> “Make each program do one thing well.” - Tenet #2 of The UNIX Philosophy
The UNIX philosophy espouses an approach to software in which small, sharp tools are designed and used to address discrete needs. By this standard, RVM simply does too much. RVM is responsible not only for changing Ruby versions, but for installing rubies and managing gemsets, as well.
Breaking these responsibilities apart and selecting a tool for each job is a good alternative to using RVM. Along with rbenv, we’re using Bundler to manage gems (replacing gemsets) and ruby-build to install rubies.
rbenv rehash command after new Ruby executables are installed (rehashing can be automated with the gem rehash plugin)~/.rbenv/Check out our laptop script to see our process for installing rbenv, or follow the steps below.
If you’re a tmux user, be sure to kill all your tmux sessions before installing rbenv to prevent RVM from polluting your environment.
In your root directory, remove RVM from your system:
rvm implode
Restart your shell to ensure you’re beginning your rbenv installation in a clean environment:
exec $SHELL -l
Next, install rbenv using homebrew:
brew update
brew install rbenv
Configure your bash or zsh profile:
echo 'eval "$(rbenv init -)"' >> ~/.zlogin
source ~/.zlogin
Install ruby-build and rbenv rehash gem using homebrew:
brew install rbenv-gem-rehash
brew install ruby-build
Install your preferred version of Ruby and set it as the global default:
rbenv install 1.9.3-p392
rbenv global 1.9.3-p392
Update to the latest Rubygems version:
gem update --system
Install gems critical to Rails development, e.g.
gem install bundler foreman pg rails thin --no-rdoc --no-ri
You can set project-specific Ruby and gem versions by running the rbenv local command within your project directory:
rbenv local 1.9.3-p385
If you follow the steps above and find you’re having issues with rbenv, check your echo $PATH. Most likely you’re not seeing the appropriate ~/.rbenv dir.
If so, you either haven’t added the init to your zsh profile, or something else is mangling the path.
bundle exec when you run commandsWritten by Laila Winner
This job shouldn’t be taking this long!
That’s not a great thing to have to say, is it? However, I bet you’ve said it before and may not have immediately know why.
With liberal use of puts and maybe pry, you can figure out what a problem might be next time you run it, but sometimes you need to figure out what that problem is right now.
As it turns out, and I know this is a shocker, Ruby processes are just regular processes. They can be debugged with gdb.
Having recently had the need to find out why a job of mine was running particularly slowly, I found out about this lovely tool the hard way: frantic googling. I found some very useful functions for gdb in a blog post by Rasmus on Ruby callstacks.
define redirect_stdout
call rb_eval_string("$_old_stdout, $stdout = $stdout, File.open('/tmp/ruby-debug.' + Process.pid.to_s, 'a'); $stdout.sync = true")
end
define ruby_eval
call(rb_p(rb_eval_string_protect($arg0,(int*)0)))
end
How to use these:
gdb by running gdb /path/to/ruby PID, where /path/to/ruby is the full path to the actual ruby binary and PID is the process ID of the ruby you want to check out.~/.gdbinit for later).redirect_stdout, which will put all the ruby output into a file called /tmp/ruby-debug.PID where PID in this case if the process id of gdb — not terribly important, but a differentiator in case you do this a lot.ruby_eval('Kernel.caller') and object_id and things like that. You should be able to get local variables from wherever you broke into the program.These ruby_eval commands will output into the tempfile that redirect_stdout created, so you’ll need to tail -f that file in a different console. Now, with that small headache over with, you can see exactly where your program is and if there is a stupid loop where you forgot to check a boundary condition, or what thing you’re doing with a regular expression on where you should have just used String#index.
Written by Jon Yurek.
Shoulda Matchers has been around for a long time. Unfortunately, it’s starting to suffer from feature bloat so we’re narrowing its focus to keep releases fast and the maintenance burden low.
The following matchers were deprecated in 1.5 and will be removed in 2.0 . If you’re currently using these methods you should consider testing the code in another way.
The assign_to matcher allows you to ensure you have set an instance variable properly. We do not use this because we typically cover those types of assertions implicitly through an integration test. An integration test may be slower than a unit test, but it provides more thorough coverage.
The validate_format_of matcher allows you to perform the same operation as the allow_value matcher. Please use the allow_value matcher instead.
should validate_format_of(:email).with('user@example.com')
should allow_value('user@example.com').for(:email )
We recommend email-spec for testing emails in your apps. It has the added benefit of working with your integration suite as well as your unit tests.
The respond_with_content_type matcher is not a matcher we use often. This behavior can be tested using the response object in your controller tests without the need for a matcher.
We do not have a recommended solution for a replacement on this matcher.
The strong_parameters and delegate matchers will also be removed in 2.0. We ran into some trouble implementing them but hope to re-implement them in a less troublesome way soon.

As part of the move to 2.0, we will also be dropping support for Rails 2 & ruby 1.8. We will continue to support Rails 3.x and ruby 1.9.x and will be adding support for ruby 2.0 soon.
We are trying to keep Shoulda Matchers a tight focused gem and make sure the matchers we do support are as robust and thorough as possible. Do you think there are any other matchers we should remove?
Written by Jason Draper.
We’ve been offering a video version of The Playbook for some time, and now we’re happy to announce the evolution of that concept, the new Playbook Workshop.
This workshop is the real-time, expanded version of The Playbook. We’ll start with the video lessons and then work together on practical examples and your own real ideas. We will go through an example of building an actual application and we’ll explore all of the pieces of the web design and development process, including the tools and team.
The first session of this new workshop runs from April 8th to the 19th, and is available for registration individually for $499, or you can subscribe to Learn Prime, to get access to this workshop, and all our other workshops, books, and screencasts for just $99/month.
Learn more and register today. I hope to see you in the workshop!