Tuesday 3 April 2012

TextMate Shortcuts Cheatsheet Navigation

→ and ← (option right and left arrow) – jump between words
→ and ← (command right and left arrow) – go to beginning or end of line
↑ and ↓ (option up and down arrow) – jump up and down to beginning and end of same level of indentation section
↑ and ↓ (command up and down arrow) – jump up and down to beginning and end of page
and (option page up and page down), keeps your cursor at center of the screen
fn ↑ and fn ↓ (function-option arrow up and arrow down), keeps your cursor at center of the screen (on laptop)
t (command-t) – Go to File
t (shift-command-t) – Go to Symbol within a file
← and → (command-option left and right arrow) – switches between tabs in textmate
~ (command – ~ tilda) – switch between textmate projects (if you have multiple project windows opened)
(escape key) – used for word completion. type part of a word and then press the escape key to see the different word options.
↓ (option-command-down arrow) – jump between related files
↓ (shift-option-command-down arrow) – jump between related files (model, controller, functional test, unit test and fixture) – if one of the files doesn’t exist, it can be used to generate one for you
Add shift key to any of the above hotkeys.
→ and ← (shift-option right and left arrow) – highlights words
→ and ← shift-command right and left arrow – highlights to end of line or beginning of line
↑ and ↓ (shift-option up and down arrow) – highlight everything above or below cursor
(option-delete) – delete single word to left of cursor
fn (function-option-delete) – delete single word to right of cursor
fn or k (function-command-delete OR control-k) – delete everything to right of cursor
k (shift-control-k) – delete entire line or selection
mate dir1 dir2 – open dir1 and dir2 in textmate project
tcs – create a new column of type string
tci – create a new column of type integer
tct – create a new column of type text
tcb – create a new column of type boolean

Models DB Schema

Inside the model, place cursor on Model name and type: control-shift-command-s to open up a window which displays database schema associated with that model.

Models Associations

hm – has_many (then click tab again to tab through areas you want to customize)
ho – has_one (then click tab again to tab through areas you want to customize)
hmt – has_many :through (then click tab again to tab through areas you want to customize)
bt – belongs_to (then click tab again to tab through areas you want to customize)

Models Validations

t (control-command-t) Then type ‘validate’ to narrow down

Models After-Before Filters

t (control-command-t) Then type ‘after’ to narrow down
t (control-command-t) Then type ‘before’ to narrow down
def – creates a method stub
cla – creates a class stub
: – gives you available options for that particular section. For example, for creating a new route, open up routes file, type map-tab and at the end type :-tab to create key value pairs.
t (control-command-t) and then type “find” (find methods)
p (control-p) – shortcut for params hash to use within find method, for example.
rest – creates respond_to block
defcreate – creates stub for create action.
t (control-command-t) and then type “redirect” for different types of redirect_to methods
rep – redirect_to a path (but first create a route. see below)
t (control-command-t) and then type “map”
map – create a named route.
mapr – create a single restful route
maprs – create nested restful routes
deft creates a method stub for a test
| (control-shift-|) (pipe) – Clone Development DB to Test DB
r (command-r) – run a test. (must be in the test rb file. test db must be created already)
ft – creates a form_tag
ff – creates form_for
ffe – creates form_for with error messages at top of it
use the following with the form_for tags:
f. – provides a menu of different form fields (use this one within the form_for tag)
ffl – creates form label field
fftf – creates form text_field
ffta – creates form text_area
ffcb – creates form check_box
ffrb – creates form radio_box
ffpf – creates form password_field
ffhf – creates form hidden_field
ffff – creates form file_field
ffs – creates form submit field
div – creates a div tag
div – creates a div tag but assume you don’t want to set id, you can type option-escape at that point to see a list of other attributes you can use instead of id.
. (control-shift-. (period)) – gives you <%= %>, <% %>
create a partial by doing: select piece of view and do h (shift-control-h) to
rpo – render partial by passing an object
rpc – render partial by passing a collection
t (control-command-t) – then type link_to to see all types of link_to





http://ionrails.com/2009/09/23/textmate-shortcuts-cheatsheet/

No comments:

Post a Comment