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
  • Kevin

    Extra Space was because you make a space between “This is my text” and “wrapp”.

    Nice tuts thx for all

  • http://snedekerdesignz.com/blog/ Craigsnedeker

    WOOHOO this rocks!

  • Neil

    I love both TextMate and E Text-Editor because these have this function built into them, but they are not free. Also, you can configure gedit to work this way as well.

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

    I can’t get the code this code for anchords working (%|), any ideas?

    • http://www.lackofinspiration.com delphiki

      You need to save your hotstring as Text, not as Script :)

      • Somej

        Ah, thanks, I had the same problem.

  • http://www.lackofinspiration.com delphiki

    Awesome! Just what i needed! Thx!

  • http://www.saroverhees.be Saro

    Thanks for pointing that out!

  • http://ivorpadilla.com iPad

    This is great!! RIM takes this idea for the Blackberrys, saves a bunch of time

  • http://www.pcbymp.nl/mennopietersen ThaClown

    Thanks so mutch for this! im saving time already!

    Maybe I could make a “Auto thank Nettuts” and “JW rocks” function”…

    • Chris Simpson

      haha or a kiss-ass + TAB :)

      jokes. good post.

  • Benjamin Reid

    After using it for a while it seems to be playing around with PS CS3 shortcuts. For example, when holding space to get the Hand Tool it toggles it instead & my Save for Web shortcut does nothing.

    Do I have to change some settings?

    • http://themeforest.net/user/JeffreyWay Jeffrey Way
      Author

      Okay – that explains it. I was experiencing the exact same thing. I never made the connection that it might be a Texter issue. I wonder if there is an easy way to fix it. Might be best, for the time being, to close Texter when working in Photoshop.

      • Zarathustra

        Or write your own script in an hour that does exactly what you want it to do, courtesy of AutoHotkey, the scripting program that Texter is written in.

      • Benjamin Reid

        Ah I found that if you set a ‘Global Disable’ shortcut, you can turn it on and off quickly when you are in PS. Hope this helps. :)

    • http://quantumcity.com aa

      I had a similar problem in PS and in CoreldDraw too, then fixed it by playing around the Texter preferences, only can’t remember which. Try turning off “Enable Universal Spelling AutoCorrect” in the texter preferences for example.

      also, a cute functionality under Texter>Preferences>Stats tells you the time you’ve saved typing.

  • http://www.pushingbuttons.net Timothy

    Was not aware of Texter. I’ll have to check it out. I tend to use SciTE, but I don’t think it has this functionality.

  • Pingback: The Dabbler » Archive » Weekly Round Up Thursday

  • http://expressionindesign.com Rick Blalock

    Textmate is great for the mac for this because it’s similar to textexpander but can be “expanded on” (pun intended) to do a lot of other advance things.

    Jeff is right. This stuff saves a TON of time. I created a textmate bundle for joomla just to save on the time because I am always doing joomla templates. With it I converted this template is around 15 minutes: http://vimeo.com/2744604

    http://beautyindesign.com/articles/joomla-15-textmate-bundle-alpha-release/

  • 123

    i bet you pasted in the lorem ipsum:D

  • Ryan

    I’ve been putting this off for a long time, thanks for “push” :>

  • Joe

    E text editor has this functionality, but it’s confined to that application. This program is good because it can be used for everything.

    It’s an awesome little program, but I cannot figure out why the %| variable isn’t working. For example, i have a hotstring called “para” that spits out %|. It should put my cursor between the paragraph tags, but instead it prints out the %|.

    I have it all set to script, but it still doesn’t work correctly. Anyone have any ideas?

    • http://www.lackofinspiration.com delphiki

      Save it as Text ;)

      • Joe

        Oh what the hell. It has to be text? Ugh. <_<

  • Jeff

    Cool.

  • Somej

    Wow, awesome. I’ll definitely be using this in the future. :D

  • http://www.colourpool.com Dan Cave

    Isnt this just macros for notepad?

    dont get me wrong i like the idea, it would take some customization to be any use, even then it would only really work in a place with a large volume of small sites going through. not so good for large bespoke web apps?

  • http://www.nixtutor.com Mark Sanborn

    Vim does this and a whole lot more.

    Gmail also now has templates.

  • http://smilingdesigner.com Bjorn

    Yeah, haven’t ever used. Bookmarked for down the road…

  • http://kivodesigns.com Mike Kivikoski

    On a slightly different note, if you are have to go through multiple folder structures daily on multiple servers you can use a program called Launchy (windows) that lets you set up shortcuts to open the specific folder or program up. http://www.launchy.net/

  • DataTat

    I have to give a shout out to TypeIt4Me, a stalwart Mac alternative that I’ve been using since the days of OS 9. It has lots of advanced features, AppleScript integration, and works in every application. You can read all about it at http://ettoresoftware.com/EttoreSoftware/About_TypeIt4Me.html, and see a feature comparison chart.

    For my text triggers, I always use a preceding comma. I chose this because words never start with a comma, and it helps me to use natural, descriptive language rather than of cryptic, difficult to remember descriptors. This means I can type “jQuery” when that’s the word I want, but “,jQuery” to expand my trigger into a jQuery-related snippet…

  • Pingback: A must for programmers! « SD Blog

  • Pingback: How I Can bCode/b Twice As Fast As You - NETTUTS | Free Full Rapidshare Downloads

  • Joe

    I just made 2 small texter bundles if anyone is interested: an HTML one and a WordPress one.

    To use them, just do Bundles > Import in Texter.

    I didn’t really know where else to host them, so the file is on file dropper.

    Here’s the link: http://www.filedropper.com/texterbundles

    Now I know the bundles do not include EVERYTHING concerning HTML and WordPress, but it’s a start :P

    • http://eyoosuf.blogspot.com/ M.A.Yoosuf

      Thank you brother

      • Joe

        No problem

    • http://www.iammikesmith.com Mike Smith

      ah, you beat me to the punch. I had about half a bundle done last night and am finishing it today. THANK YOU FOR THESE! When I release mine, I’ll add a link to yours on my post as well.

      • Joe

        You’re welcome/Sounds good :)

    • http://tryingtofollow.com Ariah Fine

      Mind re uploading your bundle? I’d love to use it but the link appears to be dead.

  • Pingback: McColley.net » Blog Archive » Use Texter to Supercharge Your Repetitive Typing [Video Demonstration]

  • Texter4Ever

    Perhaps you could share with us your Texter snippets? Just use the export function in texter and post it online?

    TIA

  • Pingback: Use Texter to Supercharge Your Repetitive Typing - Softsaurus.org

  • Pegaso

    I’ve been using PhraseExpress for over 2 years and it’s amazing. I’m not sure about differences with Texter and which one is better.

  • http://www.aldrinponce.com weblizzer

    such a great tips.. it really helps a lot thank you for sharing :)

  • Roland Porth

    TextMate +1 – Love the tab completions (snippets) and bundles!

    • http://www.konus.cl Felipe Navarro V.

      +1 TextMate iks really great!

  • http://www.imblog.info Muhammad Adnan

    i didn’t heard this before , its great information for computer users !
    its saves time !

    Thanks Jeff.

  • Robert DeBoer

    The possibilities goes beyond just programming too. For instance, I am heavily using my resume and cover letter at the moment. So, instead of repeatily pasting them into e-mails and forms, I have created a hot key for my resume, one for my cover letter, and one for both (useful for e-mails). Saves lots of time.

    Another idea is to create a template layout hotkey – emptywordpress + tab would give you a complete index page of the basic and most common tags you use.

  • Jonathan

    Great tutorial, Jeffrey. I myself am quite fond of Lifehacker’s Texter utility. Quite a timesaver.

  • http://bryankwon.net Bryan Kwon

    Great Tuts as always,
    I gotta say TextMate(mac) is perfect for this and more :)

    • brian

      I agree, for mac users these are pretty pointless. nothing presented here that TextMate can’t do better. I also recommend Quicksilver, and Automator for any Mac user that wants to speed up any workflow.

  • Pingback: Avoiding mundane repetition: Single-Sourcing, vs. Text Expansion | Lee's Blog

  • http://www.localhost.com copyleftdev

    sounds like snippets to me , been around for ages and most developer use it to the fullest, most programmer editors have some sort of snippet module , my favorite being textmate, vim has a decent snippet module for the Linux users it is called snippetsEmu.

  • http://irukado.org Lee Braiden

    With all due respect, I thought this solution was far from ideal, so I’ve written up my take on it:

    “Jeffrey Way posted a screencast on NetTuts with the tongue-in-cheek title, How I Can Code Twice as Fast as You.

    The basic premise is that repeating long blocks of code known as boilerplate that are always the same (but are required nonetheless) is time-consuming, and that it’s more efficient to use an editor with text expansion to get around this. There’s a little bit of merit in this under certain circumstances, and Jeffrey’s example was possibly contrived. However, I find it quite a wrong-headed approach to development under most circumstances — so much so, that it’s a pet hate of mine at the moment. I’m going to bemoan it a bit then, and in the process, I’ll also attempt to be constructive, sketching out an altogether nicer alternative.”

    http://irukado.org/archives/2009/03/avoiding-mundane-repetition-single-sourcing-vs-text-expansion/

  • http://www.radacinimotors.ro Radu Martin

    Great program :D i use Editplus and it has some code snippets an i use them a lot especialy for sql query and inser and update bla la .
    but i loved the part with wraping a line of code with the p element. that was sweet.

    love your screencasts.

  • Pingback: Querystring » Use Texter To Supercharge Your Repetitive Typing

  • http://josephmclaughlin.info/blog/ Joseph McLaughlin

    I use TextMate’s built-in snippits and can’t live without them. Can’t really justify buying TextExpander though, seems like TextMate can do everything I want.

  • http://www.randomjabber.com Deron Sizemore

    Wow. Never seen anything like this before but am definitely going to start using it. I use NotePad++ as well, so this should come in handy. Thanks!

  • Bruno

    (mac user) just create a custom textmate bundle with all the snippets you use often… that’s all you need to be fast.

  • http://www.lackofinspiration.com delphiki

    Here are a few scripts I made with some _indented_ html snippets. Hope it could be useful (ul, table, html base code, select…)

    Some words are in french (the html base code is the french one), but you can easily modify them.

    http://www.delphiki.com/downloads/TexterHtmlBundle.rar

  • Pingback: Code Faster using Text Expander Softwares | CNSQ Online Blog

  • http://lentilpraxis.tumblr.com J

    Oh don’t forget you get all this TAB completion in BASH (programmable / extendable completion … (as in lots of the work has been done for you by others!) )

  • Francesco

    Someone has an idea on how to share hotstrings between computers and/or collabs? For example using dropbox? Is it possible to save hotstrings in a custom path?

  • http://www.guliwer.sk Jan

    I’ve found kind of similar : http://flashpaste.com requires a bit more steps to get your snippets, but you do not have to remember all the shortcuts you have, please check out!

  • Pingback: links for 2009-03-06 | This Inspires Me

  • Luc

    Clever idea, too bad you have to choose between the time saved through using your ‘texter’ short cuts & time lost + fustation caused, through conflicting program issues that seem to be generated by using this program. – like not being able to drag n drop emails in Lotus Notes or files in Explorer :(