Hacking
February 26, 2007 12:53 AM PST

Even though I've been using computers for longer than I haven't, there are always shortcuts and cool, but unknown features, in the ever increasing amount of software that I come to depend on. Here are some of the tips and tricks that John, J and I have picked up over the years.
Please add yours!
Bash shell
- ctrl-u deletes from the cursor to the beginning of the line.
- ctrl-k deletes from the cursor to the end of the line.
- ctrl-r search your command history.
- Linux and mac: the program lsof (list open files) is incredibly useful for seeing what files a particular pid has open.
- Type "explorer ." to open the Windows explorer in the shell's current directory. To do this from a Mac OS X Terminal prompt, type "open ."
- ctrl-z to suspended current running program; typing fg brings that process to the foreground.
- Drag and drop a file into the shell on windows or mac, and the full file path is entered for you.
Firefox
- Type the domain name (ie "amazon", "google") and then ctrl-enter and it completes the "http://www." and ".com".
- Type "nullstream" then shift-enter, completes to www.nullstream.net
- Type "nullstream" then shift-ctrl-enter, completes to www.nullstream.org.
- ctrl-backspace deletes path segments one part at a time.
- ctrl-e gets you to the search bar (ctrl-k on Linux).
- Type something in the search bar and hit alt-enter, your search opens in a new tab.
- ctrl-t to open a new tab, ctrl-w to close the current tab.
- alt-home takes you to your home page.
- ctrl-L puts the keyboard focus on the address bar.
- alt-left, alt-right are back and forward, respectively.
- When on any web page with an image you want to save, simply click and drag the image to the desktop.
- Middle click on links to open them in new tabs.
- Shift click to open links in a new window.
- Middle click on a tab to close it.
- ctrl-tab, shift-ctrl-tab to switch between tabs.
- The bookmarks in the bookmarks toolbar folder show the favico from the site. You can edit these bookmarks to remove the name, and you just get a little button with the icon of the site. Very compact "site launcher", and also works with "live bookmarks". Does not work on the mac.
Visual Studio
- You can switch tabs by hitting ctrl-tab and then using the cursor keys to select the tab you want.
- If you want to have a visual marker at 80 columns, create a new registry string value under HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\Text Editor with the name Guides, and the value (which is an RGB color value and column number) RGB(255,128,128) 80. You can specify multiple markers with a comma separated list RGB(255,128,128) 80, 120, ... Then restart Visual Studio.
- ctrl-up or ctrl-down to scroll the page without moving the cursor location. Also works in most good editors like source insight, notepad++ Kdevelop.
Windows Explorer
- Instead of dragging and dropping things, I right click and drag and drop. This gives you a contextual menu on the drop target that allows you to choose "move" or "copy", which is useful for systems with more than one disk. John showed me this trick in the GoAhead days, and it was one of the first "nerd power up exchanges" we had.
- WIN key + E to open a new explorer window with the folder tree open.
- WIN key + L to lock the screen.
- WIN key + R to open the "Run program" dialog.
- CTRL-SHIFT-ESC brings up the task manager (ctrl-alt-del also brings up the task manager).
- WIN key + break brings up system properties.
vi(m)
- In your vi initialization file (.exrc in your home directory) add the line set ts=4 to get tabs every 4 characters (or whatever your coding standard dictates).
Mac OS X
- Fn-delete performs an actual 'del' of the character following the cursor.
QuickTime
- ctrl-K (it's also under the Window menu) brings up a dialog that lets you slow down a song up to 50% (change the tempo) without affecting the pitch, which is useful for transcribing the notes in a song.
- cmd-opt-ctrl-8 toggles the inverting of your display. Useful when you want to browse with really low screen glow on your laptop.
Comments (13)
More VI(M) powerups:
:set ic -Turn on ignore case for searches
Ctag commands:
:ta [tagname] - edit the file with tagname.
:po - pop to previous location
:ts [tagname] - list the tags that match
Ctag keystrokes:
Ctrl-] - jump to name under cursor
Ctrl-T - pop to previous location
To use above you must have previously built ctags for your source project. For example:
ctags -R *.c *.h
Power searching with Firefox using
smart keywords. Once you use this, you won't go back.
I've extended this to do specialized Google searches, where I want to search only one web site. I'm often looking up API documentation on MSDN, and I don't want other sites to show up in the search results. So, I'll type a query like this into Google:
But typing all that site:... junk is a pain, and I always seem to mistype the word Microsoft. So, I've combined the site specific search with a Firefox smart keyword so that you can type the following into the Firefox address bar to get the same results:
To do this:
1. Go to Google and right click inside the search box.
2. Choose "Add a Keyword for this Search".
3. In the Name field, type MSDN search (this name will be displayed in the bookmarks menu).
4. In the Keyword field, type ms.
5. Click OK.
6. Go to the Bookmarks menu in Firefox, and right click on MSDN Search and select Properties.
7. For the Location field, enter this string: http://www.google.com/search?q=%s+site%3Amsdn.microsoft.com
8. Click OK.
The key part is the q=%s in the search query, and that will get filled in with everything after the ms keyword that you type in the address bar.
Super awesome vim commands.
Gmail power select: to select multiple consecutive email threads, click the Select checkbox of the first thread, then hold down shift and click the Select checkbox of the last thread. Gmail will select (or unselect) all the threads between the two.
Mac OS X comes with retarded key bindings for somethings, like having Home/End go to the start/end of the document, instead of start/end of the line.
Fixes for this here and here.
On Mac OS X, hold down ctrl and use the scroll wheel of the mouse, or the two finger track pad scroll. It magnifies the screen and you can scroll around the area magnified.
To list just the subdirectories of a directory in Linux:
To look for text in a bunch of files recursively through directories:
Windows Update is really convenient, except when an update is installed that requires a restart of the computer. A dialog then gives two choices: "Restart Now" or "Restart Later". If you choose later, it'll pop up the dialog box 10 minutes later and keep doing so until you finally reboot.
Here is how you can turn off this ridiculous nagfest.
Firefox keyboard shortcuts.
Web development cheat sheets, from Mr. Mosaic + Netscape himself!
Silence the PC speaker beeps.
Even better home and end key handling for Terminal.app.
When using emacs and X11 on the Mac, you have to do some key remapping so that the meta (alt) key works properly:
1. In X11 preferences: uncheck follow system keyboard layout.
2. In X11 preferences: uncheck enable key equivalents under X11
3. Create the file ~/.Xmodmap, and add the following lines to it:
clear Mod1
clear Mod2
keycode 63 = Mode_switch
keycode 66 = Meta_L
add Mod1 = Meta_L
add Mod2 = Mode_switch
Go this from here.