Vim Tips and Tricks
The following tips and tricks can be put into your .vimrc file
Remap jj to esc
imap jj <Esc>
Quickly leave edit mode and back to visual mode with jj. This is probably the fastest key combination possible and one of the most frequent key combinations while editing in vim.
Remap semicolon “;”
nnoremap ; :
Instead of shift, semicolon (which produces a colon) just remap the semicolon to a colon while in visual mode.
You can alias commands with vim
command Tab, :tabnew
The only caveat is that your alias must start with a capital letter.
Git: development Git gitignore productivity rm source control workflow
by bseanvt
leave a comment
Git Untrack Already Tracked Files
To remove files that are currently being tracked by git, you have to remove them from the “cache”. Note, doing this will NOT delete the file on your local machine. It will still be there but not be tracked.
git rm -r --cached supersecretpasswords.txt
You then need to add the file to the .gitignore file in the root of the project so that it isn’t tracked again on your next commit.
vim .gitignore supersecretpasswords.txt
.gitignore files are tracked so remember to check in these changes.
git commit -am'my super secret passwords are safe!'
If you want to completely delete the file, on your local machine and from git
git rm supersecretpasswords.txt
If you’re working with a directory remember to add the -r flag for recursive removal!
Ruby on Rails: annotations productivity rake tasks todo
by bseanvt
leave a comment
TODO and Custom Annotations in Rails Applications
While writing software it’s common to leave comments for your future self. For instance, if you have written some code but realize that it should be refactored to be more efficient, you may place something along the lines of “TODO: change active record find method and replace w/ a custom sql select finder “. With rails, if you follow this convention, you can get a list of your annotations with a rake task.
rake notes:todo
which will print out the file where the the todo was found along with the line number and the comment…
app/controllers/application_controller.rb: * [ 8] fix me
Rails defines several other annotation types for you
rake notes # Enumerate all annotations rake notes:fixme # Enumerate all FIXME annotations rake notes:optimize # Enumerate all OPTIMIZE annotations rake notes:todo # Enumerate all TODO annotations
And you also may define your own
# SEAN: please rewrite this method to query only chunky bacon
you may find all instances of “SEAN” by running
rake notes:custom ANNOTATION=SEAN
Programming: app command line launch photoshop productivity psd terminal workflow
by bseanvt
leave a comment
Launch Photoshop (Or Any App) From The Command Line on Mac OS X
I often find myself coding with the terminal open. Cding around a web app project I usually end up at some point launching Photoshop. Either to touch up or work on a psd, png, jpg …etc. I fire up Photoshop and then navigate to the app’s public directory, where the site images are kept. Then begins the hunt in finder for the image. This takes some time and if I’m already at the command line it would be nice to launch Photoshop with the exact file I want with a single command! To accomplish this just make an alias in your bash profile like so…
#fire up your text editor and edit your profile vim ~/.bash_profile #create the alias command alias psd="open -a /Applications/Adobe\ Photoshop\ Elements\ 3/Photoshop\ Elements\ 3.app"
You need to fire up a new terminal instance before this setting will take place. CMD+N.
Then from the command line type
psd my-image.psd
Note, I didn’t use “ps” as the alias because this is already taken by the system. Also the path to the application may be different on your system. Make sure you use the correct path or you may have an error like
LSOpenFromURLSpec() failed with error -10827 for the file...


