Skip to content

Instantly share code, notes, and snippets.

@biscuitvile
Last active July 8, 2020 07:15
Show Gist options
  • Save biscuitvile/c0feada498347bce3e8f to your computer and use it in GitHub Desktop.
Save biscuitvile/c0feada498347bce3e8f to your computer and use it in GitHub Desktop.
Up and Running with iTerm, Tmux, Vim, and vim-rails

Up and Running with iTerm, Tmux, Vim, and vim-rails

Make it a point to be able to use the keyboard as much as you can. In OS X the spotlight is great for this. By default the spotlight hotkey is Cmd+Space. Make it a point to try and always use iTerm in fullscreen. Remember that your tmux prefix is set to Ctrl+z

  • Open iTerm with spotlight with Cmd+Space search iTerm and open with Enter
  • Fullscreen iTerm with Cmd+Enter
  • Pop out of iTerm with the hotkey you added Ctrl+Enter
  • Pop back into iTerm with Ctrl+Enter again
  • Nagivate to your intended project directory
  • Check for running tmux sessions with tmux ls (Failed to connect to server just means no tmux sessions yet)
  • Start a named tmux session with tmux new -s myprojectname
  • Detach from that session with prefix d
  • List tmux sessions again with tmux ls
  • Connect to your detatched, running session with tmux att -t myprojectname
  • Split your screen vertically with prefix % or use the alias prefix |
  • Move the split border so that the pane on the right occupies about 80% screen real estate with prefix H or prefix L
  • Move between the vertical splits with prefix h or prefix l
  • Open vim in the large pane. In your project directory run vim .
  • Keep the smaller pane of this window free for test output and running rake tasks or git commands
  • Open a new window with prefix c
  • Split this window vertically with prefix % or prefix |
  • In the pane on the left run rails c and in the pane on the right run rails s or tail -f log/development.log when using POW
  • Go forward and backward between your two windows with prefix n (next) and prefix p (previous), with only two windows it doesn't matter too much which.
  • Learn the vim-rails commands for navigation https://github.com/tpope/vim-rails
  • Learn how :Econtroller, :Emodel, :Eview work to find files. Note that you can type :Eco and tab for example.
  • Create a new model with :Emodel my_new_model!
  • Create a new controller with :Econtroller my_new_controller!
  • Create a new view with :Eview path/to/my_new_view.html.erb!
  • Jump from a controller action to its view template with :Eview from inside the controller action
  • Jump from a view template to its controller with :Econtroller
  • Jump from a model or controller to its test with :A
  • Open an alternate file in a new vertical split with :AV
  • Open an alternate file in a new horizontal split with :AS
  • Open a model in a new tab with :Tmodel and the model name
  • Nagivate splits in vim with the prefix Ctrl+w and then one of h,j,k,l
  • Nagivate tabs in vim with gt and gT
  • Open a controller in a horizonal split with :Scontroller and the controller name
  • Remember you can always open or create new files with the standard vim command :e followed by a space and a filename with or without a relative path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment