April 10, 2006
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.
(Note that on a Mac you may need to substitute Cmd for Ctrl.)
Moving the Cursor
Move cursor to next word
Move cursor to previous word
Scroll text area up (only works in some apps)
Scroll text area down (only works in some apps)
Move cursor to end of line
Move cursor to start of line
Move cursor to beginning of text
Move cursor to end 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
Undo last edit
Redo last edit
Delete forward to word break
Delete back to word break
Select all text
Extend selection one character to the right
Extend selection one character to the left
Extend selection down one line
Extend selection up one line
Extend selection to beginning of line
Extend selection to end of line
Extend selection to next word break
Extend selection to previous word break
Extend selection to below paragraph
Extend selection to above paragraph
Extend selection to top of text
Extend selection to bottom of text
Move to next input area on form
Move to previous input area on form
Add a manual line break
Submit form (if textarea is part of a form and has support)
All of these shortcuts work in any standard textbox, like the ones on every web page and in most apps for your operating system. Try them out!
Posted by Jeff Atwood
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?
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...
"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.
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:
Jeff, these shortcuts are all also correct when working in KDE, for the record. That includes Konqueror and Firefox as far as browsers go.
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?
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.
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.
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!
"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.
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.
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??
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.
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:
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. :)
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.
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:
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.