How I Can Code Twice As Fast As You
videos

How I Can Code Twice As Fast As You

We’re all familiar with text expander programs; though I would surmise that the percentage of us who use them when coding is quite low. To change things up a bit, today I’m going to you how to create custom text-expander scripts that will save you a great deal of time. If you’re unfamiliar with such programs, you must watch this! After reviewing the screencast and tutorial, I’d love to hear how you save time when developing.

Okay – so I’m mostly teasing with this article’s title. Many, many techniques factor into writing quick and efficient code. Nevertheless, you’ll be astounded at how much time you can potentially save by using a simple text-expanding program. Watch the screencast below to learn one of my tricks.

Why Use a Text Expander?

How many times have you typed the following:

<script type="text/javascript" src="js/somefile.js"></script>

<script type="text/javascript">
...my code
</script>

Granted, it only takes ten seconds or so, but imagine multiplying that figure by 100. How much time can you potentially save by assigning a simple keystroke to a block of code? With a text-expanding program, I can simply type “startjs” (or any other key that I define), and press tab. Once I do, all of the code above will be pasted in.

Many IDEs offer a snippets section. Definitely utilize these for more complicated procedures. However, it’s important to keep in mind that Texter works anywhere. It’s not dependent upon one specific program.

How Fast?

As an example, I took a 100% blank page and was able to create all of the code below in about ten seconds, without copying and pasting. I utilized about five snippets.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/default.css" />
<link rel="stylesheet" href="css/reset.css" />
<title>Untitled Document</title>
</head>

<body

<div id="container">
	<form method="" action="">
		<label for="name">Name</label><input type="text" name="name" id="name" />
		<label for="name">Email</label><input type="text" name="email" id="email" />
		<input type="submit" name="submit" value="Submit" />
	</form>
	
	<p>
		Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 
		Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure 
		dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non 
		proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
	</p>
</div><!--end container-->

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">

$(function() {

});

</script>

</body>
</html>

What You Need to Get Started

Your best option is to do a Google search for “free text expander”. There are plenty of pay versions, but if you look hard enough, you should be able to find a few apps that will work perfectly. Here are some worth consideration.

Out of the options listed above, only “Texter” is 100% free. The other two offer a free 30-day trial. If any of you have other options, leave a comment and I will update this list. For this tutorial, we’ll be using Texter (Windows), but most of the techniques can be easily translated into a different piece of software.

How Do I Use It?

Texter

It’s easy! Grab a block of code and paste it into your clipboard. Try to keep the code as general as possible; that way you won’t have to modify it too much. Open Texter, or your expander of choice, and choose a unique key. Next, paste in your code – and you’re done! To test it, return to your document, type in your key and press tab!

What Else Would I Use it For?

I literally have dozens of shortcuts assigned – ranging from simple snippets to more complicated scripts (which you’ll learn about in the screencast). Some of my favorites are listed below:

Import jQuery

// Typing jquery + tab gives me:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

Open Inline Javascript Stuff

// Typing beginjq + tab gives me:
<script type="text/javascript"><script>
   $(function() {

   });
</script>

Insert Lipsum Text


Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. 
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure 
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non 
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Simple Conveniences

Don’t forget about the simple three second timesavers. Those add up quickly over the course of a week!


<img src="" alt="" />

If we’ll spend an extra minute or so, we can write a quick script that will position the cursor between the “src” quotation marks. (Remember – the goal is to touch the mouse as little as possible.) Change the option in Texter from “Text” to “Script”, and paste in the following:

<img src="" alt="" />^{LEFT}^{LEFT}^{LEFT}{LEFT}{LEFT}

In this little script, We add our image tag, and then use a combination of “Control Left” and “Left” to place our cursor correctly.

  • ^ = Control
  • + = Shift
  • # = Windows Key
  • ! = Alt

  • {TAB} = tab key
  • {BS} = backspace key
  • {LEFT} = left arrow key
  • {HOME} = home key
  • …etc.

Tutorial Writing!

Any time that we post a tutorial on nettuts+ that contains scripts, we must add the correct “name” and “class” attributes to our pre tags. This allows for the syntax highlighting. For example…

<pre name="code" class="html">
author's script goes here...
</pre>

As you can imagine, it can be a pain to type, or even copy and paste, those wrapping pre tags fifteen times per article. Sounds like a great usage for text expanding! However, just inserting that snippet into our program of choice isn’t enough. We need to add a simple script. The following will work for Texter; just make sure that you’ve selected the “Script” option, rather than “Text”.

<pre name="code" class="">{ENTER}{ENTER}</pre>{UP}

When we wish to tell Texter to perform a specific keystroke, we simply wrap the name of the key within braces. For example, when I typed {UP} at the very end, I did so because I wanted the cursor to ultimately end up between the two pre tags, not after.


<pre name="code" class="html">
(cursor will be right here)
</pre>

Keep In Mind

You might have to tweak your scripts for your IDE of choice. Keep in mind that some IDEs apply automatic indentation, code completion, etc. This can screw up your scripts slightly. To compensate, it might be easiest to disable those features.

What Are Your Tricks?

I’m always on the lookout for shortcuts. It’s all about keeping your hourly wage as high as possible, without producing an inferior product. How do you save time when developing?

Paste Your Scripts Into the Comments

I, and I’m sure the other readers, would appreciate it if you’d paste in your custom Texter “mini-scripts” along with a short description of how they help you!

  • Subscribe to the NETTUTS RSS Feed for more daily web development tuts and articles.


Tags: Videos
Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://www.crearedesign.co.uk Martyn

    I’ve used TextMate and I think that’s pretty good. I can tend to remember the code i usually repeat and dreamweavers facility of predicting is ok. (just)

  • Kevin

    In most Windows programs that I’ve used, to delete whole words like you were demonstrating in the video you can just use CTRL-Backspace or CTLR-Delete (I guess that would be ^{BS} or ^{DELETE}).

  • Terry

    I’ve used this before. It’s pretty cool:

    http://www.humanized.com/enso/

    Not advertising, just sharing…

  • Adel

    i just looooove u jeff.
    thanx man, u really changed my life

  • http://www.nineliondesign.com Chikezie Ejiasi

    This is why I love DW snippets so much. They save so much time. I use it for my CSS Framework, Mootools development, and certain XHTML site structures.

    Thanks for sharing!

  • http://www.ejcm.com.br Diego Machado

    If’s somebody uses some other language on Windows that’s not US will get some issues with Texter.

    For example, my Windows language is Brazilian Portuguese. If i create the block of code ” name=”email” “, when i use it Texter will produce “name=ëmail”.

    To solve that, just use one space before ‘e’, like ” name=” email” ” that Texter will produce as expected.

    Awesome post Jeff. Already using it.

    Thanks from Brazil !

  • Micheal

    is it possible to add scripts like this to Dreamweaver ?

  • http://joomla.ly Taimur Aziz

    WaW .. That’s gonna save my time while I’m coding a dozens of Joomla templates .. Thank you so much for the cast

  • Pingback: sethetter.com / blog » Intro To Text Expanders: NET Tuts

  • http://zencarttuts.com Meshach

    This was on LifeHacker

    • Joe

      They know… And Lifehacker made it.

  • http://www.cruor.be Pieter

    Hmm, never used a textexpander.
    I think starting from a basic xhtml template speeds up your coding process enough.

  • jakm

    Oh well, should have been nice, but on my system (Windows XP Sp2), it disabled Windows+Key combination (Win+R, Win+E, Win+L, etc…)

    Strange enough.. I couldn’t drag (to re-arrange) Mozilla (v.3.0.6) tabs while Texter is running..

    Any ideas would be appreciated….

  • Pingback: Use Texter to Supercharge Your Repetitive Typing [Video Demonstration] - 203th Edition | Technology Revealed

  • Will

    I used to use Quicktext for notepad++ but development stopped on that a while back and it doesn’t work in Vista :(

    It’s so nice have to this feature back. Thank you! Any more tips like this would be great.

    • ali

      I’am using Quicktext in Vista and it’s perfectly working. If you still have problem or anyone else just send me an email. I can send you the copy of the plugin i have.

  • Richard Schmitt

    Another more advanced and free windows program is Auto-it.

    An excellent, though not free program is Activeword. Give it a try. http://www.activewords.com/

  • Pingback: Textexpanders - DoubleJWeb.Net

  • Pingback: Use Texter to Supercharge Your Repetitive Typing - Knowledgepedia

  • http://www.dekorfilm.se Tommie Hansen

    This application seriously did some bad things to my Vista Ultimate 64 install. Explorer stopped working correctly, drag & drop stopped working.. PS CS3 begun to be less useful etc.

    I thought i’ve been infected even though i got a pretty tight security. I tracked it down to this software and upon uninstall everything works again …

  • Pingback: JeremiahTolbert.com » Blog Archive » links for 2009-03-08

  • http://mhuntdesign.com Matthew Hunt

    coda’s clip feature can save you lots of time. Although I do like text expander’s fix typo feature.

  • http://www.hautter.com Ana

    I saw this on your tweet and TextExpander is the best thing since peanut butter. I love it. I used it for 5 minutes and bought it.

  • http://tom.kulturlounge.de Tom

    Hey ho,

    why not just use activaid? http://www.heise.de/ct/activaid/default_en.shtml
    It has an extension called hotstrings and a lot of other useful stuff :)

  • http://www.antonagestam.se/ Anton Agestam

    Very useful indeed!
    Cheers!

  • Pingback: FTL Weekly Review - Vol. 5 - ForTheLose.org

  • Pablo

    Wow! I though that I was fast enough typing + using EIDEs.

    Thanks Jeffrey. Great tip!

    • Pablo

      Woops…. typo… blame TextExpander. I meant I was fast using IDEs

  • mildo

    Great Idea.. I will try it!

  • http://www.cofilew.de Nico

    Nice Tool Dude! I love it!

  • Surya L

    %ds not working in script mode

  • paul

    Hey Jeff

    I see that texter has an nifty export option, do you fancy exporting ur key strokes for the lazy ones.

    Ps im a tuts+ member wink wink nudge nudge :P

  • http://zencarttuts.com Meshach

    Has anyone noticed texter interfering with Photoshop? It’s so annoying!

    • http://jayj.dk Jay

      Yes!

      • http://designer1993@gmail.com Meshach

        Help!! How do I fix it?

  • http://diggerdesignlabs.com Steve Robillard

    Jeffrey,

    Typinator a text expansion app for the mac is free for signing up at macheist.com

  • http://blog.seanja.com SeanJA

    Don’t most big name IDEs have this? It is called code completion

    I know if I type swi(ctrl+space) it will build a switch statement for me in both Eclipse and Netbeans… I rarely use switch statements though…

  • http://www.ronoerlemans.nl/ Ronn0

    I use this one:

    +{HOME}^x{ENTER}{ENTER}{ENTER}{ENTER}{ENTER}{ENTER}{UP}{UP}{UP}{TAB}

    Thanks for this screencast, love it!

  • http://dotspiral.com Anraiki

    I have a doubtful feeling on “Text Expander” whether it allows for faster coding or lazy programming.

    I am leaning to “lazy programming”.

    Then again…. I never gave it a try.

    Although, Copy Pasta is always the fastest…

  • Pingback: Web and Graphic Design by Seth Etter | sethetter.com

  • http://healthcareforamericanow.org/ Bob Parker

    I used macro’s 25 years ago, but have stopped for a few reasons:
    - did not know of any for Window’s (after MS DOS),
    - stopped coding and doing ‘repetitive’ stuff,
    - ended up on too many different computers
    - kept forgetting what I had developed as macro’s
    - autofill in Firefox met much of my need

    Times change and this looks like a good tool to go ‘back to the future’.

    For me the biggest reason to use something like this is for accuracy. Just watching the video shows how much we all tend to make mistakes, more macros/text expansion = less errors.

  • Pingback: 30+ Amazing Mac Apps for Developers | Programming Blog

  • Pingback: 30+ Amazing Mac Apps for Developers - Nettuts+

  • Pingback: 30+ Amazing Mac Apps for Developers | Ouech.net

  • Pingback: Designfeed.me » 30+ Amazing Mac Apps for Developers

  • Rick Bross

    Heres a good script for Yahoo/ATT Mail:

    Hi +{TAB}+{TAB}+{TAB}{HOME}^+{RIGHT}^c{TAB}{TAB}{TAB}{TAB}{TAB}{BS}{BS}{BS}{BS}{BS}{BS}{BS}{BS}^v{BS}, {ENTER}{ENTER}How are you? {ENTER}{ENTER}Rick

    • Rick Bross

      Just List the Gmail one, but it works with Yahoo and ATT email.

  • Meshach

    How do I stop it from interfering with photoshop?? :O

    Please help!

    • http://ronfolio.com/ Ron

      You could disable it temporarily while you’re in photoshop. Right click on the system tray icon and click Disable.

      • http://twitter.com/vastudio Meshach

        Hey Ron,

        Thanks a lot buddy.

  • Pingback: 30+ Amazing Mac Apps for Developers30+ Amazing Mac Apps for Developers « Nvmindmedia

  • Pingback: En vrac (20090409) « Gahanima’s Weblog

  • Dave

    But, ConText has language specific macros with scrolling navigation for variations and descriptions within a prompt in case you forgot your macro. Plus it has exe macros your can apply to scripts, ie; compile and run. I still can’t figure out why peeps use anything else to develop on a PC.

  • Pingback: 30+ Amazing Mac Apps for Developers30+ Amazing Mac Apps for Developers « NVMIND

  • Steve

    Great tips! Using textexpander for mac all day and it really saves a lot of time :)
    Btw, your voice sounds like Steve Jobs :D

    Cheers

  • Will

    I know this is an old post, but has anyone else experienced Texter being really slow in Aptana?

    In every other program, it is near instant. But in Aptana, it looks like someone is actually typing it all out. It’s faster than I could type, but not faster than copy/paste. Especially on a big block of text (like lipsum).

    Ideas?

  • http://zettersten.com Erik

    Yes, I have actually.
    Texter v.06 is much better than .05 in Aptana

  • Andreas

    Hi!
    Gotta edmit that I’m a huge newb ^_- but I always wanted to start scripting HTML and or JAVA and stuff like that, since I love to design, scripting wouldn’t be a dum idea to know =) so my question is… WHERE SHOULD I BEGIN!?

    Send me a e-mail or maybe add me to your msn if you wish to guide me :P

    Cheers
    Andreas