Pivotal Labs

Main menu

Skip to primary content
Skip to secondary content
  • About
  • Case Studies
  • Team
    • Executives
    • Locations
      • San Francisco (HQ)
      • Boston
      • Boulder
      • Denver
      • London
      • Los Angeles
      • New York
  • Community
    • Blogs
    • Tech Talks
    • Events
  • Careers
    • Lifestyle
    • Principles & Practices
    • Benefits
    • FAQ
    • Apply
  • Contact
    • Press Room
    • Press Releases
    • In The News
    • Press Kit
  • All
  • Labs
  • Standup
  • Tracker

File Management in RubyMine

Jared Carroll
Sunday, May 12, 2013

As developers, we create, update, and delete files all day long. Managing files from the command-line is one of the first skills we learned. However, constantly switching from your editor to the command-line to execute a simple file command, a command you’ve probably executed thousands of times before, is tedious and slow. Instead, stay in your editor, and let it take care of the boring stuff. In this post, we’ll look at RubyMine’s file commands on OS X.

Creating Files

To create a new file or directory, press control + alt/option + N within the editor or Project tool window.

new in current directory dialog

Copying Files

Use F5 within the editor or Project tool window to copy the current file.

copy dialog

F5 can also be used in the Project tool window to copy directories.

Cloning Files

To create a copy of a file or directory in the current directory, press shift + F5.

clone dialog

Moving Files

Move files and directories with F6.

move dialog

Like the previous file commands, this command works both within the editor and Project tool window.

Renaming Files

Files and directories can be renamed in the Project tool window with shift + F6.

rename dialog

Deleting Files

Delete files and directories in the Project tool window with delete.

safe delete dialog

Locating Files

To locate a file in the Project tool window, press alt/option + F1 in the editor, and then select the Project View option, the default option, from the Select Target dialog.

select target dialog

Select Reveal in Finder to open the file in a new OS X Finder window.

Working with File Paths

Use command + alt/option + F12 to view the complete file path.

file path dialog

Selecting a directory will open the directory in a new OS X Finder window.

Copy the current file path to the clipboard with command + shift + C. Copy a reference, the current relative file path and line with command + alt/option + shift + C.

paste from history dialog

These commands are useful for when you need to work with a file on the command-line.

Relying on Abstractions

A common developer fear is that overreliance on a particular IDE’s features will cause you to forget, or maybe never learn, the underlying commands. I agree that in some cases, e.g., version control, it’s important to know what’s going on under the hood. However, these situations are rare. And when it comes to everyday commands, I’d much rather use higher-level abstractions to free me from the mundane.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Running Programs in RubyMine

Jared Carroll
Sunday, May 5, 2013

A typical Rails development environment includes an editor, a terminal for running a web server, and a utility terminal for managing files, using version control, running tests, etc. During development, you’re constantly switching between your editor and these external terminals. RubyMine, an Integrated Development Environment, can eliminate this tedious back and forth workflow. In this post, we’ll learn how to run programs in RubyMine on OS X; allowing you to stay in RubyMine all day long.

Running Files

To run a file, open the file in the editor or select the file in the project tool window, then press control + shift + R. Rerun a file with control + R.

These commands are commonly used to run test files, but they could also be used to run a simple Ruby script.

Run Tool Window

All running programs are displayed in the Run tool window. Press command + 4 to open the Run tool window.

run tool window

Stop a running program with command + F2. Use command + shift + [ and command + shift + ] to navigate between multiple running programs.

Running Tests

In a test file, press control + shift + R outside of any individual test to run all the tests in the file. Press control + shift + R within an individual test to run just that test.

Run Dialog

Open the run dialog with control + alt/option + R. The run dialog lists recently run programs. This is useful for when you want to rerun a test you ran several tests ago.

run dialog

By default, this dialog also includes commands to run a development server, and your entire test suite.

Ruby/Rails Quick List

Use command + option + R to open the Ruby/Rails quick list. The Ruby/Rails quick list includes several useful commands such as, starting a Rails console, and starting an IRB session.

Ruby Rails quick list

You can run a file or a code selection in an existing IRB or Rails console with alt/option + shift + L. View IRB history with command + E.

IRB history

Running Rake Tasks

Run a Rake task with alt/option + R.

run Rake task

If a custom Rake task doesn’t appear in the list, reload Rake tasks from this dialog or the Ruby/Rails quick list (command + alt/option + R).

Running Rails Generators

Run a Rails generator with command + alt/option + G.

run Rails generator

If a custom Rails generator task doesn’t appear in the list, reload Rails generators from this dialog or the Ruby/Rails quick list (command + alt/option + R).

Take Advantage of Your IDE

IDEs increase your productivity by combining all of your development tools into one program. Frequent context switching to external tools not only slows you down, but also requires more in-depth knowledge of each tool. Try gradually replacing external tools with their IDE equivalents. Over time, your knowledge of shell command options and obscure Git commands will no longer seem very important to you.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Breakdown Your Work in RubyMine with Tasks

Jared Carroll
Sunday, April 28, 2013

In RubyMine, you can create tasks to breakdown and structure your work. A task can be a simple local task, or it can correspond to a feature, bug, or chore, in an issue-tracking system. Each task in RubyMine includes the current state of the editor, allowing you to switch between tasks and resume exactly where you left off. In this post, we’ll explore RubyMine’s tasks on OS X.

Creating Tasks

Press alt/option + shift + N to open the task dialog. Enter the task’s name, then press Enter to create the task.

create task

By default, RubyMine will clear your current context and create a new changelist.

Switching Tasks

A context is a set of opened files. Each task has an associated context. When you switch tasks, its context is automatically loaded.

To switch between tasks, use alt/option + shift + T.

switch task

Isolating Work with Changelists

A changelist is a set of related source code changes. Each task has an associated changelist.

task changelist

Changelists allow you to isolate each task’s changes. Use command + K to commit the current task’s changelist. RubyMine will now consider the task closed, and ask if you want to delete its changelist.

Pivotal Tracker Integration

Instead of manually creating tasks, you can configure RubyMine to load tasks from Pivotal Tracker.

In project settings, command + ,, create a new Pivotal Tracker server in the Tasks Servers section. Then add your Pivotal Tracker project id (located in the Pivotal Tracker project’s settings page) and API token.

pivotal tracker settings

Pivotal Tracker stories will now appear in the task dialog.

Pivotal Tracker tasks

Creating a new task from a Pivotal Tracker story allows you to update the story as in-progress. However, it won’t set you as the owner of the story. Also, closing the task won’t finish the story.

Clean Context Switching

RubyMine’s tasks are well-suited for serial development. But if you constantly switch contexts, like most developers, they fall short, because switching tasks brings along committed work. If each task consists of a single commit, then this isn’t a problem. However, I prefer to commit frequently; resulting in many small, granular commits. So, in my opinion, using a distributed version control system, e.g., Git, and a branch-per-feature workflow, is a better development strategy than RubyMine’s tasks. Branches keep your work isolated from the main line of development, and it’s still possible to cleanly switch contexts.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Searching Code with RubyMine’s Usage Search

Jared Carroll
Sunday, April 21, 2013

When browsing a codebase, you often want to view the definition of a particular class, method, or variable. However, sometimes you want to do the reverse; you want to see where a particular class, method, or variable is used. Typically this involves using your editor’s text search, or a command line tool, such as grep or ack. Unfortunately, text searches may return false positives, such as log file data, or similarly named constructs. The problem is that you want to search code not text.

RubyMine has text search, but it also includes a powerful, code-based usage search. Usage search is smarter than text search, because RubyMine is aware of code constructs such as classes, methods, and variables. This results in a more accurate search; allowing you to quickly view and navigate actual usages. In this post, we’ll explore RubyMine’s usage search on OS X.

Find Usages

To find where a particular class, method, variable (instance or local), or parameter is used, place your cursor on it, and press alt/option + F7. Results will be displayed in the Find tool window.

find usages

command + alt/option + Up/Down navigates the results. Use F4 to jump to the source code of a particular usage.

Recent usage search results can be viewed again with command + E.

recent usages

Find Usages in File

By default, find usages is scoped to the entire project. To scope it to the current file, use command + F7. command + G and command + shift + G navigate the results.

Show Usages

command + alt/option + F7 can be used to show usages inline. Instead of displaying usages in the Find tool window, they appear in a pop-up window.

show usages

Searching Code

RubyMine’s usage search demonstrates an advantage an IDE has over a text editor. By being aware of code constructs, such as classes, methods, and variables, IDEs can offer powerful tools that allow you to quickly and accurately explore a codebase.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Mark Your Place: Bookmarks in RubyMine

Jared Carroll
Sunday, April 14, 2013

Like many text editors, RubyMine supports bookmarks. A bookmark is a reference to a particular line in a file. They are visually indicated by an icon in the editor gutter. Bookmarks can be used as a form of navigation based on interested parts of a codebase. In this post, we’ll explore (using the Mac OS X 10.5+ keymap) the three types of bookmarks in RubyMine: anonymous, numbered, and lettered.

Anonymous Bookmarks

Anonymous bookmarks can be created with F3. They appear as a checkmark icon in the editor gutter.

anonymous bookmark

Unfortunately, there are no default keyboard shortcuts to navigate anonymous bookmarks. Instead, use the Find Action command,command + shift + A, to search for the “Next Bookmark” and “Previous Bookmark” anonymous bookmark navigation commands. These commands will only navigate through anonymous bookmarks in the current file.

Mnemonic Bookmarks

There are two types of mnemonic bookmarks: numbered and lettered.

Numbered Bookmarks

You can have up to 10 numbered bookmarks: 0-9. To create a numbered bookmark, press control + shift + <number>, e.g., control + shift + 4.

numbered bookmark

To navigate to a numbered bookmark press control + <number>, e.g., control + 4.

Lettered Bookmarks

You can have up to 26 lettered bookmarks: A-Z. To create a lettered bookmark press option + F3, then choose a letter to use for the bookmark.

lettered bookmark

To navigate lettered bookmarks, use the bookmarks dialog (discussed below), command + F3.

Deleting Bookmarks

All three types of bookmarks can be deleted by pressing F3 when on the bookmarked line.

Viewing Bookmarks

You can view all existing bookmarks with command + F3.

bookmarks dialog

This dialog also allows you to delete, and navigate bookmarks.

Last Edit Location “Bookmark”

When editing, it’s common to stop for a second to view another part of the file (or a different file), and then navigate back to the original edit location.

Instead of using bookmarks to quickly navigate back to the original edit location, use the Last Edit Location command, command + shift + Backspace.

Experimenting with Bookmark Navigation

After trying out the different types of bookmarks in RubyMine, I find numbered bookmarks to be the most useful. They are both easy to create and navigate. Lettered bookmarks offer a greater number of possible bookmarks, but navigating them requires several commands. I think anonymous bookmarks could also be useful, if you create shortcuts for their navigation commands.

Try them all and see what works best for you.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Navigate Code, Not Text: How to Navigate Effectively in RubyMine

Jared Carroll
Sunday, April 7, 2013

Terminal text editors often allow you to navigate in terms of basic text objects, such as, characters, words, or lines. For maximum speed, the commands for these simple navigations are usually available on home row keys; so you don’t have to use the arrow keys.

Unfortunately in RubyMine, performing these basic movements requires using the arrow keys. However, I saw this disadvantage as an opportunity to research alternative navigations. RubyMine may make simple movements tedious, but it adds many powerful code-based navigations. By being aware of programming constructs such as methods, and classes, RubyMine demonstrates the difference between IDEs and text editors. In this post, we’ll look at some of these unique navigation commands for OS X.

Navigating by Symbol

command + option/alt + O is for when you know what you’re looking for, but not where it is. This shortcut performs a fuzzy search of project symbols. It allows you to quickly find classes and methods.

find by symbol

Navigating by Method

When browsing an unfamiliar file, it’s common to want to move through it one method at a time. This allows you to quickly scan method signatures, and browse implementation. Use control + Up/Down to move forward and backward by method.

Navigating to a Specific Method

If you know the method you’re looking for, then navigating by method is too slow. Instead, use command + F12 to open a file structure dialog, then begin typing the method name to navigate to it.

navigate to a specific method

Navigating to a Declaration

Navigating directly to a type declaration is one of RubyMine’s best features. This is often available in terminal text editors via ctags. However, I’ve never been able to successfully configure ctags to work as powerful as RubyMine’s version.

Press command + B when your cursor is on a class/module object to open its declaration. If you don’t want to open the declaration, use command + Y to quickly view it in a separate window.

quick definition

Press command + B when on a variable to navigate to its declaration. Navigate to the declaration of the type of a variable with control + shift + B.

Navigating Class Hierarchies

If you’re interested in the subclasses of a particular class, press command + option/alt + B on a class object.

view implementation

Use command + U within a class declaration to navigate to its superclass. Within an overridden method, command + U will navigate to its superclass definition.

Navigating to Related Files

RubyMine’s awareness of Rails allows you to quickly move between models, views, helpers, controllers, and their tests. When editing, use control + command + Up to be presented with a menu of related files.

Navigating Tests

When test driving a Rails project, it’s great to be able to quickly switch between test and non-test code. Use command + shift + T to move between a file and its corresponding test file (and vice-versa). In a split tab layout, for example, a vertical split between test and non-test code, command + shift + T will move between the splits.

After running your tests, use command + option/alt + Up/Down to quickly navigate between failing tests.

Navigating Between Changes

Version control introduces an interesting way of navigating. In RubyMine, file changes are highlighted (in various colors) in the editor’s gutter. Use option/alt + shift + control + Up/Down to move between these changes.

navigate changes

Navigating Through Navigations

RubyMine even provides commands to navigate backward and forward through executed navigation commands. Use command + [/] to move through your navigation command history.

IDEs vs. Editors

A text editor doesn’t know what kind of text it’s editing. Code aware extensions are usually added on via plugins, distorting the editor’s basic purpose. An IDE, like RubyMine, with its powerful code-based navigations, really shows the advantages an IDE has over a basic text editor.

Edit: updated keyboard shortcuts from the Mac OS X keymap to the Mac OS X 10.5+ keymap.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Beginning Mouse-Free Development in RubyMine

Jared Carroll
Sunday, March 31, 2013

As a long time terminal text editor user, and accordingly not a big fan of the mouse, after switching to RubyMine, I immediately began memorizing the keyboard shortcuts. RubyMine shortcuts can look intimidating, especially the three and four-key shortcuts that resemble guitar chords. However after several months of using RubyMine, I’ve found that efficient, painless, mouse-free development is possible. Here are some suggestions in helping you move away from the mouse.

Choosing a Keyboard

It’s important to choose a keyboard with modifier keys (Shift, Control, Option/Alt, and Command) on both the left and right sides, because RubyMine shortcuts often involve pressing one or more modifier keys. Having a set of modifier keys for each hand allows for more natural shortcut fingerings.

I use RubyMine on a Mac with the apple keyboard with numeric keypad. This keyboard has two sets of nice-sized modifier keys.

Respect the Dividing Line

The dividing line on a keyboard determines which hand types which keys. It usually lies on a diagonal between 5 and 6, T and Y, G and H, and B and N.

Almost all RubyMine shortcuts involve a key combination: pressing one or more modifier keys plus a non-modifier key. For safety and speed, always use the modifier key(s) on the opposite side of the non-modifier key. For example, when typing command-f, the find shortcut, use the right command key.

Touch Typing the Function Keys

RubyMine shortcuts make extensive use of the function keys (F1-F12). Most developers have little experience using these keys because editors often neglect the function keys.

Touch typing the function keys is essential for maximum speed. Extend the dividing line to the function keys between F5 and F6. This may vary depending on how your keyboard lays out the function keys.

Key Combination Fingerings

Finding the optimal key combination fingerings can help make shortcuts comfortable and easy to remember. I’ve found the following fingerings for common RubyMine shortcuts to be intuitive and painless.

  • command-option index + ring
  • command-control index + pinky
  • command-option-control index + ring + pinky
  • command-shift index + pinky
  • command-option-shift index + ring + pinky
  • option-control ring + pinky
  • option-shift index + ring
  • option-shift-control index + middle + ring
  • control-shift pinky + ring

Mouse-free Development

RubyMine publishes keyboard shortcuts for each supported OS. In future posts, we’ll explore each category of shortcuts, moving towards complete, mouse-free development.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter

Why are all the Stories in Pivotal Tracker Missing Descriptions?

Jared Carroll
Sunday, March 24, 2013

I asked my pair on my first day here at Pivotal.

That’s on purpose. A user story is a promise to have a conversation. When we start a story, we’ll have a discussion with the client to fill in the details.

Ok. So we’ll just ping them on Skype or something?

No. They’re sitting at the desk right over there.

The Onsite Customer

In XP, the onsite customer is a domain expert that is part of the development team. Their responsibility is to answer questions, resolve disputes, and set small-scale priorities [1].

In past projects, contacting a client involved emails, IMs, or phone calls. My stories needed detailed descriptions. Description-less stories risked building the wrong thing. So I labeled them “blocked”, and project velocity suffered.

Benefits of having an Onsite Customer

In my current project, having an onsite customer has made a huge impact.

Eliminating story descriptions has simplified iteration planning meetings. Just write down a short title and move on. Discuss the details later.

Constant client communication has helped avoid misunderstandings. Not once has a pair built the wrong thing. Developer time isn’t wasted.

Delivered stories rarely go untested for longer than an hour. A quicker turnaround has shortened system feedback time.

Get Serious About Succeeding

An onsite customer was one XP practice that was missing from my past projects. What client would be willing to give up one of their full-time employees? After four weeks of working on a team with an onsite customer, to me, the answer is clear: a client that wants their product to succeed.

[1] Kent Beck, Extreme Programming Explained: Embrace Change (Addison-Wesley Professional, 2000), 60.

  • 0 Shares
  • Share on Facebook
  • Share on Twitter
Jared Carroll

Jared Carroll

Subscribe to Jared's Feed

Author Topics

keyboard (6)
mouse-free development (7)
productivity (6)
rubymine (7)
agile (1)
onsite customer (1)
pivotal tracker (1)
xp (1)
  • About
  • Case Studies
  • Team
  • Community
  • Careers
  • Contact
  • Labs
  • Events

Contact Us

contact@pivotallabs.com
+1 415-77-PIVOT
TwitterLinkedInFacebook

Pivotal Tracker

Tracker is the award-winning agile project management tool that enables real-time collaboration around a shared, prioritized backlog.
Visit pivotaltracker.com >