Skip to content

Instantly share code, notes, and snippets.

@ecbrodie
Last active March 2, 2020 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecbrodie/503e44c1c0c3a2bc21346c56f1208065 to your computer and use it in GitHub Desktop.
Save ecbrodie/503e44c1c0c3a2bc21346c56f1208065 to your computer and use it in GitHub Desktop.
Evan's RubyMine live templates

RubyMine Live Templates

This is a (mostly complete) list of the custom live templates I use in JetBrains IDEs. I mainly use this for Rails development in RubyMine, but I'm sure that these have usage beyond RubyMine and Rails. Variable names can be configured via "Edit variables", or whatever constructs are available within your IDE of choice.

Ruby/Rails

  • binding.irb:
    require "irb"
    binding.irb
    
  • defi:
    def initialize$END$
    end
    
  • frozen: # frozen_string_literal: true
  • hell: raise "a little hell"
  • ifcli:
    if __FILE__ == $PROGRAM_NAME
      $STATEMENT$
    end
    
  • pp:
    puts "########## $HEADER$ ##########"
    p $EXPRESSION$
    
  • rloge: Rails.logger.error "### $HEADER$: #{$EXPRESSION} ###"
  • rlogi: Rails.logger.info "### $HEADER$: #{$EXPRESSION} ###"
  • rlogw: Rails.logger.warn "### $HEADER$: #{$EXPRESSION} ###"
  • rubocop: (RUBOCOP_RULE = clipboard())
    # rubocop:disable $RUBOCOP_RULE$
    # rubocop:enable $RUBOCOP_RULE$
    

JavaScript

Make sure that the TypeScript context is added alongside JavaScript, if you work on TypeScript projects.

  • clog: console.log("$HEADER$", $EXPRESSION$)
  • eslint-block: (RULE = clipboard())
    /* eslint-disable $RULE$ */
    /* eslint-enable $RULE$ */
    
  • eslint-next-line: // eslint-disable-next-line $RULE$ (RULE = clipboard())
  • lodash: import $package$ from "lodash/$package$" (PACKAGE is empty)
  • react: import React from "react"

BASH

  • bash_boilerplate:
    #!/usr/bin/env bash
    (
      set -euo pipefail
      IFS=$'\n\t'
    )
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment