I <3 Steve McConnell*
Coding Horror
programming and human factors
by Jeff Atwood

April 10, 2006

(Very) Basic Textbox Keyboard Shortcuts

Everyone knows how to use the arrow keys to navigate within textboxes. But not many people know there are a slew of handy keyboard shortcuts for editing text in textboxes. And these keyboard shortcuts work everywhere, even in the most basic input areas-- including vanilla HTML forms, such as the Wikipedia edit box.

Moving the cursor

Ctrl + left

Move cursor to next word

Ctrl + left

Move cursor to previous word

Ctrl + left

Scroll text area up (only works in some apps)

Ctrl + left

Scroll text area down (only works in some apps)

End

Move cursor to end of line

Home

Move cursor to start of line

Ctrl + Home

Move cursor to beginning of text

Ctrl + End

Move cursor to end of text

Selecting text

Ctrl + A

Select all text

Shift + left

Extend selection one character to the right

Shift + left

Extend selection one character to the left

Shift + left

Extend selection down one line

Shift + left

Extend selection up one line

Shift + Home

Extend selection to beginning of line

Shift + End

Extend selection to end of line

Shift + Ctrl + left

Extend selection to next word break

Shift + Ctrl + left

Extend selection to previous word break

Shift + Ctrl + left

Extend selection to below paragraph

Shift + Ctrl + left

Extend selection to above paragraph

Shift + Ctrl + Home

Extend selection to top of text

Shift + Ctrl + End

Extend selection to bottom of text

Cut, Paste, and Undo

Ctrl + X, or Shift + Del

Cut selected text

Ctrl + C, or Ctrl + Ins

Copy selected text

Ctrl + V, or Shift + Ins

Paste selected text

Ctrl + Z

Undo last edit

Ctrl + Y

Redo last edit

Deleting text

Ctrl + Del

Delete forward to word break

Ctrl + Backspace

Delete back to word break

Navigation

Tab

Move to next input area on form

Shift + Tab

Move to previous input area on form

All of these shortcuts work in the comment textboxes at the bottom of this post. Try them out!

Posted by Jeff Atwood    View blog reactions

 

« How Much Power Does My Laptop Really Use? It's Better Than Nothing »

 

Comments

Don't forget about:

SHIFT + END

Select to the end of the current line

SHIFT + HOME

Select to the beginning of the current line

Very useful for coding.

Declan on April 10, 2006 05:40 PM

The quickest way to learn these is to spill Red Bull into your keyboard at 1:00am when you have a major programming assignment due the next day.

You be amazed how easy it is to use Windows with no mouse when things get hairy.

Ian Muir on April 10, 2006 06:56 PM

Jeff,

Have you got the images for Next Word and Previous Word (the first two images) round the wrong way?

John Rusk on April 10, 2006 07:55 PM

@Ian: If you spill Red Bull into your keyboard, trying to use your Windows box w/ no mouse isn't really going to help as your keyboard will be hosed (more than likely at least).

Great job on the keyboard 101 Jeff.

jayson knight on April 10, 2006 08:39 PM

Declan, I *knew* I was forgetting something -- and that was it! Added.

I also fixed the typo that John pointed out.

Thanks guys.

Jeff Atwood on April 10, 2006 11:47 PM

No worries, sorry about the triple post!

I've had doubles before, but triple? Sheesh...

Declan on April 10, 2006 11:58 PM

Real Men (tm) use these:

Ctrl+Ins = Copy
Shift+Ins = Paste
Shift+Del = Cut

I could never understand people using Ctrl+XCV for those tasks. Those shortcuts are FAR from being convenient and usable. And unless you use them with both hands, you risk severe left hand injuries.

But you're a n00b girlie anyway if you have gone the XCV way.

Here's also one great shortcut: Ctrl+Bckspc. Select the address bar in your browser, move to the end, and try it. It works in most other apps as well, but you'll get a better impression of it on URL's.

Anonymous on April 11, 2006 12:39 AM

I agree with Anonymous. Ctrl+Ins,
Shift+Ins and Shift+Del are killer.

Hermann Klinke on April 11, 2006 12:43 AM

Thanks anonymous. I had forgotten that there were those Ins/Del alternatives for copy/paste! And I completely neglected backspace as a deletion method. Added.

Jeff Atwood on April 11, 2006 12:47 AM

Jeff you are a rock star blogger. :)

What about:

CTRL + A : Select all

dont know if they belong here, mostly vs keys.

[tab] or [shift] + [tab] for increasing or decreasing the tab indent of the selected text.

[ctrl] + [return] insert line below


And what about the PageUp / PageDown keys, do you use those ? Could be PageUp + Shift for selecting text a page up..

Peter Palludan on April 11, 2006 02:05 AM

Hmm these key bindings are pretty much identical to the Visual Studio keybindings. I remember this set of bindings as coming from Wordstar, but wikipedia seems to think that wordstar used a different set. Anyone know where this set first originated?

Factory on April 11, 2006 02:16 AM

The advantage of the XCV shortcuts are that those keys are in the same place on a QWERTY keyboard, whereas Ins and Del tend to wander around from keyboard to keyboard; the current trend seems to be to rearrange the cluster into two columns, enlarging the Del key and doing away with Ins, so the old shortcuts are going to disappear soon. (Laptops suffer from a similar "where's the ****ing Ins key gone!" problem.)

Still, that's progress for you...

Mat Hall on April 11, 2006 02:28 AM

hey, I once had a linux system up, where you could work with the emacs shortcuts in textboxes as well. But I don't know how to set that up on my linux machine. Any ideas? thx.

tester23 on April 11, 2006 04:30 AM

I didn't know about CTRL+DEL/BACKSPACE

The rest I use (including the INS/DEL series for copy/cut/paste).

I am right handed, but I run my mouse on the left (when working). Makes it easier to use the numeric keypad, and the INS/DEL for copy/paste/cut is easier.

Eric D. Burdo on April 11, 2006 04:30 AM

Peter, nice catch on CTRL+A. Added. CTRL+RETURN is a nice trick for multi-line textboxes (avoids default button behavior), but I'm not sure where to stick it in the list.

Jeff Atwood on April 11, 2006 08:44 AM

Probably a little off topic, but I use this combination a lot in Visual Studio text windows: Ctrl+LMB = select word = same as double-click

I like it in combination with Ctrl+F or Ctrl+C immediately afterwards.

Or, Shift+LMB = extend selection to mouse cursor.

My left Shift, Ctrl keys are badly worn as a result. Maybe the keyboard+mouse combinations are a whole new topic, albeit some are application specific.

D. Howell on April 11, 2006 09:19 AM

But isn't the real message here "Don't think that you can program to catch all of the standard keyboard shortcuts"? I've seen many programmers try to disable things like copy and paste by simply swallowing the CTRL-C and CTRL-V keystrokes on the text box. But there are way too many ways to do the same thing with text box controls. You will NEVER get them all.

matt on April 11, 2006 10:41 AM

interesting post, should probably specify whether these shortcuts are OS specific (i.e. Windows only) or browser specific (IE / Firefox only) or whatever constraints there are.

love your blog btw

oldman on April 11, 2006 11:11 AM

I assume these are Windows specific, but I'm not sure (any Mac users care to test?). They are definitely NOT browser dependent.

Jeff Atwood on April 11, 2006 11:47 AM

This probably doesn't belong with this post, but I'm going to spit it out anyway. My favorite keyboard shortcut by far (well, other than ctrl+z) is windows+m which minimizes all the open windows.

I probably use this 40 times a day, and can't imagine life without it.

Ryan on April 11, 2006 12:05 PM

> there are a slew of handy keyboard shortcuts
> for editing text in textboxes
> They are definitely NOT browser dependent.
> -- Jeff Atwood

Not to rain on your parade, but these common shortcuts apply to almost every Windows text-manipulation user interface : text boxes, text editing, Word documents, etc.

In fact, all but 7 of these shortcuts work the same way in Notepad (1 works slightly differently) & all but 1 work in Word.

Sorry, I was just surprised as to why you listed these shortcuts specifically for "textbox editing" when they are much more generic to almost all Windows text-manipulation apps.

Ian Johns on April 11, 2006 12:48 PM

> "textbox editing" when they are much more generic to almost all Windows text-manipulation apps

Well, I meant textbox in the sense of "Windows Common Control Textbox", of which HTML forms is a typical case. Sorry if I was unclear.

Jeff Atwood on April 11, 2006 02:50 PM

> My favorite keyboard shortcut by far (well, other than ctrl+z) is windows+m which minimizes all the open windows.

Indeed, I am a big fan of that windows key, and I'm happy the new Lenovo Thinkpads actually HAVE a Windows key.. at last!

I have a seperate post for the Windows key shortcuts:

http://www.codinghorror.com/blog/archives/000378.html

Jeff Atwood on April 11, 2006 02:52 PM

Jeff, these shortcuts are all also correct when working in KDE, for the record. That includes Konqueror and Firefox as far as browsers go.

Declan on April 11, 2006 03:42 PM

It's all well and good, until you get to the Linux side. Damned Firefox deletes the whole contents of the address bar when I press Ctrl+Backspace. It's the little things that kill you, right?

pinano on April 11, 2006 05:34 PM

Oh. Apparently I should switch from Gnome to KDE, then? Wonder why Gnome changes it like that...?

pinano on April 11, 2006 05:35 PM

CTRL + BACKSPACE is supposed to delete the whole URL in an address bar, because there's no word break for it to jump to :)

Declan on April 11, 2006 09:47 PM

Declan: Nope :) Word boundaries are between [a-zA-Z0-9_].

As for missing inserts on keyboards, I think keyboard manufacturers will come to their senses and bring them back; it's just a current hype which will quietly go away soon. If not, well, I still have two replacement IBM clickety-click keyboards which should last at least until a true human-computer neural interface gets implemented.

I <3 me my IBM's!

Anonymous on April 12, 2006 02:16 AM

"Damned Firefox deletes the whole contents of the address bar when I press Ctrl+Backspace. It's the little things that kill you, right?"
It doesn't for me :S You need to make sure you don't have the whole URL selected, as it is defautly when you select the URL bar.

"CTRL + BACKSPACE is supposed to delete the whole URL in an address bar, because there's no word break for it to jump to :)"
Punctuation breaks it. The . and /'s. They have slightly modified the behaviour however. Ctrl+Backspace on http:// deletes the whole lot, wheras normally it would just delete the :// Same in IE.

"My favorite keyboard shortcut by far (well, other than ctrl+z) is windows+m which minimizes all the open windows."
I prefer Windows+D. I use it to get to the desktop, which has all my junk/downloads/crap on it. Then I can press it again to get back to where I was.

I use the Ctrl navigation shortcuts all the time. Makes navigation alot easier, and garauntees you will end on a word, which is 80% of the time what you want. My only gripe with it is that navigating forward will take you to the begining of a word, but I would prefer navigating back to go to the end of the previous word. Never mind.

[ICR] on April 12, 2006 02:25 AM

Is there a way to select a current line without pressing HOME,SHIFT+END? Or at least to copy it (as someone said before, the only purpose of selecting/highlighting is to copy :)

Sometimes I'd like to copy the current line but without leaving the current cursor position.

Esad Hajdarevic on April 17, 2006 06:36 AM

Shift + Tab (Move to previous input area on form) does not work in GNOME. Instead it just inputs another tab. Sad to say. Anyone know what does??

foo on August 9, 2006 09:54 PM

One of my fav's is CTRL + 'plus on numeric keypad' to automatically size the width of columns to their contents.

Erator on March 27, 2007 02:25 PM

why is it always orange?

anyway, about Erator's comment, you can also use the round scrolling thingie on a mouse(don't know what it's called) while holding the CTRL key to zoom/unzoom the current window.
great post, but i'm late in posting... XD

Sosuke on March 27, 2007 06:57 PM

If you enjoy keyboard shortcuts, just give a try to VIM (http://www.vim.org). Awful in the begining (and I really mean it), it quickly gets an essential editing tool.
BTW, you've got a cool site.

PubBronx on March 27, 2007 11:41 PM

F2 to rename a file or folder.

Windows + D = Desktop
Windows + E = Explorer

Which i use very oftenm

Ganesh on March 28, 2007 05:23 AM

How about space and shift+space for scrolling in <most> browsers?

james on March 28, 2007 09:59 AM

I am a big fan of using the keyboard as much as possible. I have found that over the years I have formed "modes" in my brain for the different types of editors I use:

Mode # 1 - "Everyman" Editing: This is my brain mode for when I am in a standard windows text box, a notepad window, or editing something on someone else's editor and I want to have the best chance of things just "working". No fancy, feelin' cool editing tricks here. Just get the job done and use the experience to remind you of how much nicer the other mode's are.. (This message typed in Mode # 1).

Mode # 2 - "Faux Emacs" - Ah, old school emacs. This is my favorite, because if you are trained right you can keep both hands on the keyboard for just about everything. No lifting your hand up to search for arrow keys or the home/end. Just keep those palms flat on the keyboard ergo-bench and type away. Emacs uses the CTRL and ALT keys as modifiers for all the basic editing commands, and has no qualms about, say, using Control-F to mean "move cursor forward" and Control-d to mean "delete character". There are some interesting conflicts that arise when you bring the default emacs commands to windows. The one that really freaks people out is when I have Page-Down mapped to Control-V. Heaven help the poor soul who tries to use my Visual Studio while its emacs profile is still engaged. They go to paste a bit of text and the *entire screen changes!* Heh heh... if I had a dime for every time a coworker yelped in dismay... <grin>

I do have a somewhat hybrid set up for those apps that I can configure to use emacs key bindings - things like Shift + Control + F = Extend selection forward one char, Shift + Control + A = Extend selection to start of line, and Control + U = Page Up (took that from vi). I am actually more in tune with this "bastardized" hybrid than true emacs, but drop me in real emacs editor and I only start to choke when I have to remember those funky double-sequence commands like Control-X Control-S to save and the like. Or heaven help me if I need to remember how to manipulate kill regions or run a Meta-X search-for-string...

Mode # 3: "To The Pain" (g)VI(m) - Long ago I lived in worlds where sometimes emacs was not available. I bit the bullet and learned VI. It is just as powerful as emacs in its ability to let you keep those palms flat on the keyboard, but it does it in a different way. VI is a "mode-based" editor - meaning that you press a key ('i') and then everything you type until you hit the ESCAPE key is treated as text input. If you are not in 'insert' mode, then you're in 'command' mode, which is where you can move around ('ijkl') and enter "colon" commands like ':w ~/myfile.txt', ':wq' (write file then quit), or ':q!' (quit without saving, dammit).

After literally years, I eventually reached the point where I could effortlessly switch into "vi" mode and do quie well. These days, I am even able to do basic search and replace without having to look it up. Don't believe me? Check this out:

':1,$s/foobar/Snickers/g'

Looks like Sendmail control codes, or Perl gone right, eh? No sir, it is my version of "Replace every occurence of the word 'foobar' with 'Snickers' in the file. My mind tells me that this command is essentially broken down like this:

':1,$s/foobar' - this part tells vi to search for the string foobar anywhere from the 1st line of the file to the end of the file '$'.
'/Snickers/' - If you find a foobar, replace it with Snickers please...
'/g' - Oh, and do it globally for all matches you find. (Snickers really satisfies...).

It turns out that depending on which vi you are using you may not need the 'g' part at all.. and frankly if you use me as your canonical reference for how to break down the vi command above you should have your brain checked for lesions. <grin>

Well, anyway, that's my brain on editors after well over ten years of programming in Unix, Windows, and other seedy locales. Thank you for listening, and for the opportunity to expound at such great length. :)

-Michael (http://yevaud.blogspot.com)

Michael Moore on March 28, 2007 08:02 PM

Hi all,

Window key + L locks the computer

Raja on March 29, 2007 06:42 AM

Start button + m minimizes all the open windows into the taskbar.
Start button + shift + m puts them back.

John A. Davis on March 29, 2007 02:01 PM

Personally, I like to use the Ctrl-CVX keys for copying, cutting, and pasting. It's way easier to adapt to a laptop keyboard that way, and they don't require me to move my hand from the mouse.

I've also found AutoHotkey to be a rather indispensable tool. It allows you to remap hotkeys using a low-level keyboard hook. Right now I have WindowsKey+Q set to open query analyzer, WindowsKey+A set to open SQL profiler, WindowsKey+N set to open Notepad++, and various other combinations mapped to open my commonly-used folders with windows explorer.

Nick on March 30, 2007 01:06 PM

thanks for helping me learn and discovery the typing shotcuts
more power!!!!

venice on July 6, 2007 10:58 PM

>After literally years, I eventually reached the point where I could >effortlessly switch into "vi" mode and do quite well. These days, I am >even able to do basic search and replace without having to look it up. >Don't believe me? Check this out:
>
>':1,$s/foobar/Snickers/g'

What you neglected to mention is the value of that seemingly byzantine search expression. It is what is called a "regular expression", and it's used throughout unix-like operating sytems in lots of different applications. It's basically like the wimpy DOS * and ? "wildcards" (aka "globs") except on steriods. (Although the simple example you provided can be easily performed by any search/replace box.)

[g]vi[m] have some other powerful shortcuts too. Basically, you can combine any action key (e.g.: d=delete) with any number with any motion key (w=word, j=line up; k=line down) to quickly do things like "delete four words", "delete two lines up", and even "delete from here to "Smith". Without removing hands from keys - takes less than a second. Much faster than with mouse or even any emacs-style or wordstar-style ctrl+key or alt+key shortcut.

Howver, my favorite keyboard shortcut is in BASH: after typing the first few letters of a command you've entered into the shell, press Page Up and it will find the last command matching you entered that matches.

John on July 19, 2007 07:47 PM







(hear it spoken)


(no HTML)




Content (c) 2008 Jeff Atwood. Logo image used with permission of the author. (c) 1993 Steven C. McConnell. All Rights Reserved.