This file may be freely distributed, providing it includes this notice. This file may be edited, however if you do so, please send me a copy of your changes, as they may be able to be incorporated into this document.
All comments/suggestions are welcome.
Trevor Ian Peacock


Having started programming on MS-DOS, without a mouse, and on programs written before Ctrl+X/C/V were created, i used Ctrl+Shift+arrows and ins/home/PgUp-Del/end/PgDn to do most of my navigating and manipulating of text.
Many of these combinations are still available today in modern editors, and in my opinion are much more efficient to use for the modern programmer.
This is a document i have been wanting to write for a few years, being frustrated with watching other people stumble around with the mouse, taking 20 seconds select, cut and paste a few lines of text, then clear up blank lines, etc. Something which, using these methods, can be done quickly and cleanly in a few seconds.


Programming keyboard shortcuts.

Version 0.1 Pre-First Draft

Some modern keyboards have an altered keyboard arrangement, the traditional layout has an arrangement like this:

|          |          |           |
|  Insert  |   Home   |   Page    |
|          |          |    Up     |
|          |          |           |
|  Delete  |    End   |   Page    |
|          |          |   Down    |

           |  ^       |
           |  |       |
           |  |       |
|          |  |       |           |
|  <---    |  |       |     --->  |
|          |  v       |           |

For much of the time my right hand will hover over these keys, either with fingertips over the arrows, or above the delete/home/PgDn keys.

The left hand operates these keys on the far left of the keyboard:

|                  |
|  ^  Shift        |
|                  |
|         |
| Ctrl    |
|         |

with the little finger over Ctrl, and the next finger over the Shift key, leaving your first two fingers and thumb free.

First i will list and explain some of the navigation shortcuts. Most of these are valid in modern text editors, especially those designed for programmers. many of these are generic across windows programs.


* Up/Down/Left/Right
obvious and straight forward. some editors don't allow you to go past the end of the line (that is, past any character, there may be white space characters), continuing to press right will result on reaching the next line after the end of the first. some editors will allow you to continue pressing right endlessly. when the file is saved, any white space to the right of the line will not be saved. this behaviour allows you to insert (for example, comments) in a line down the right hand side of the text, in a vertical line, without having to add spaces from the end of the line to the start of the comment. some editors will also recognise the fact you have comments in line down the right hand side, and will adjust the spaces automatically if you add/delete characters from the text in that line, keeping all the comments in a vertical line.

* Ctrl+Left/Right
rather than moving a single character, this combination will move a "symbol". Symbols vary from editor to editor, but you can often think of them as "words". Using this combination improves speed, as you don't have to continuously press the arrows, or wait for the cursor to move character by character as you hold it down.

* Ctrl+Up/Down
Will scroll the page up/down, without changing the cursor position relative to the file. usually a file will scroll when you attempt to arrow the cursor outside the current view of the file (what you can see on screen). this combination allows you to scroll without requiring you to move your current editing position. This may be useful if you need to refer to a line above or below the view of the screen. it saves you moving the cursor up/down, then back again to where you were, or reaching for the mouse. Most editors will allow you to move the cursor out of view, some however will not.

* Home
Usually moves the cursor to the start of the current line. Some editors will move the cursor to the end of the file.

* End
Usually moves the cursor after the last (non-white-space for infinite line length editors) character of the current line. Some editors will move the cursor to the end of the file.

* Insert
Toggles insert/overwrite mode. in normal insert mode, any characters typed in the middle of an existing line, will be inserted at the current position of the cursor, moving existing text to the right. In overwrite mode, the character originally to the right of the cursor will disappear, being replaced by the character typed, thus leaving the length of the line unchanged. Behaviour at the end of a line with overwrite mode on varies from editor to editor.

* Delete
The delete key removes the character to the right hand side of the cursor. This behaviour is different from the Backspace key, which removes characters from the left of the cursor, resulting in the cursor moving left. Both result in the line length being shortened. they are both close together on a standard keyboard, both in easy reach by the right hand in the position described above.

* Page Up
Moves the view down the height of the current view (moving the first line in the view to the bottom of the view, or more commonly, just below the bottom of the view). This in effect allows you to see the "page" above that which you were seeing. Generally the cursor position relative to the view wont change.

* Page Down
Reverse effect to Page Up. In effect allows you to see the "page" below the one you are currently viewing.

* Ctrl+Home
Moves the cursor to the beginning of the file, adjusting the view so as you can see the cursor.

* Ctrl+End
Moves the cursor to the end of the file, adjusting the view so as you can see the cursor.

* Ctrl+Delete
Deletes the "symbol" to the right of the cursor. see Ctrl+Left/Right above. Sometimes Ctrl+Backspace may have a similar effect.

* Ctrl+Page Up/Down
In tabbed editors, this will switch back(or left)(Page Up)/forward(or right)(Page Down) through the tabs. Tabs are usually cyclic. that is, attempting to move left at the left-most tab, will select the right most tab, and vice-versa.

* Shift+(Up/Down/Left/Right-Ctrl+Left/Right-Home-End-Insert-Delete-Page Up-Page Down-Ctrl+Home-Ctrl+End-Ctrl+Delete)
Holding down Shift with any of these combinations will select the text, starting at the current cursor, and extending to the destination of the cursor. If you have already selected text with this method (or any other), this will modify the selection, however, you can only modify the end at which the cursor is, and the cursor can not otherwise be moved, without deselecting the selected text. That is to say, pressing any of the listed keys, without the Shift key, will cause the editor to forget your selection (the selection itself, not the selected text).
Ctrl+Up/Down can usually be safely used while text is selected. it will move the view, without moving the cursor.


The "clipboard" is a temporary storage space, generally accessible by all programs running on a computer. There are 3 basic operations, "cut", "copy" and "paste". cut will place data in the clipboard, and remove it from the document being edited. "copy" will also place data in the clipboard, but will leave it in the original document also. Paste will copy the contents of the clipboard into the document After a paste the data will remain on the clipboard, allowing it to be pasted again and again. Whenever data is cut/copied, the previous contents of the clipboard will be erased. The following shortcuts perform the cut/copy/paste operations.

* Shift+Delete
Equivalent to "Cut" (Ctrl+X). It will place the selected text in the clipboard, and delete the text from the file. I will often (i suppose due to habit rather than efficiency) use cut-paste in quick succession, rather than a simple single copy (see next two key combos). This has the disadvantage that if the file has not yet been edited, the editor may mark the file as edited, which may prompt a confirmation to save when the editor/file is closed. This is probably just due to habit, or left hand laziness. Let me know what you find. See the email address at the end of this document.

* Shift+Insert
Equivalent to "Paste" (Ctrl+V). It will insert the contents of the clipboard at the current cursor position, moving the cursor to the end of the pasted text.

* Ctrl+Insert
Equivalent to "Copy" (Ctrl+C). It will copy the selected text to the clipboard, without editing the file, and without removing the selection.


The above sections detail single key combinations accessible easily and quickly, with minimal hand movement. This section explains how these combinations can be used quickly and effectively to perform tasks.

One of the most common operations is to move or remove a line (or lines) of text. Many people will do this with the mouse, inaccurately selecting from the start of the line to the end of the line, often missing white space at the start of the line, then removing it with backspace, accidentally backspacing too far, and then re-typing the characters they removed. A much more efficient method is to leave the mouse alone, and select the line using the keyboard. Use the Up/Down arrows to position the cursor on the line you wish to move/remove, then press the Home key to position the cursor at the start of the line. Now, holding down the Shift key, press Down to select the line (or press down repeatedly to select multiple lines). In selecting lines like this, you are selecting from the start of one line, to the start of the next, the selection including the carriage return (or newline) character at the end of each selected line. This means when you remove the line, the line itself will also be removed, moving all lines below up to fill its place. Having selected the desired lines, press Shift+Del, or just Del if you wish to simply remove the lines. Ctrl+Ins can also be used to copy the lines without removing them (or my Shift+Del, Shift+Ins combination), so the lines may be cleanly copied. If your intention was to move or copy the lines, rather than delete them, position the cursor on the line you wish to past them at. The cursor should already be at the home position, if it isn't, press Home to make it so. Press the Shift+Ins combination to insert the text. The text will appear starting on the line where the cursor was, moving the original line down below the pasted text. Again, because you originally selected the lines and their carriage return characters (which were also placed on the clipboard), the pasted text will insert cleanly, leaving each line of text to itself (instead of one line ending at the end of another, as often happens when selecting with the mouse).
The usefulness of my Shift+Del, Shift+Ins may be seen here, if you wish to duplicate a line, directly underneath the original, press Shift+Del, then Shift+Ins twice to create two copies. Although this can still be done using the Ctrl+Ins combination, without removing the selection, the first insert will overwrite the existing text. I find it easy to ignore the Ctrl key, and just keep my finger on the Shift key, press Del, and then insert as many times as is required.
When performing these operations, i usually find my right hand with the little finger on the down key, next finger on the up key, and Ins-Del being operated by my middle finger. This allows you to move up and down, cutting and pasting as needed thought the document.

Often it is useful to perform operations to multiple lines. Sometimes it is easier than setting up some sort of script to do it, to just do it yourself. Say for example you had some C code that didn't work because somebody forgot to put semicolons at the end of each line. You could fix this quickly by placing the cursor on the first line, pressing End, then semicolon to add the semicolon. Then press Down, End, Semicolon again for the second line. Repeat the Down, End, Semicolon as many times as required. I would normally do this by placing my left hand to press the semicolon, using my right thumb for the down button, and my right middle finger for the End key. With a little practice you can press this combination quite quickly and do at at least a line or two a second. Musicians who play piano may find combinations like this easier, with a little more co-ordination in their fingers for sequences such as this. It may also be useful to note, that in most instances, you do not actually need to release one key before you press the next, so your keystrokes can overlap a little, as long as they are still depressed in the correct order.
Another common one is to insert a space (or two) at the beginning of each line (to indent code for example in an editor that does not do it automatically for you). For this you might use Down, Home, Space, Space. To do the double space is where the music practice really pays off, to press the space bar twice in quick succession. A similar task may be to remove white space, in which case the delete key may be used instead of space. This has the added bonus that delete does not move the cursor, and so there is no need to use the Home key.

  Other shortcuts

These shorts may not be so universal, but are available in many programming editors. Look up your manual/on-line help, or simply browse through the menus to see what is available (keyboard shortcuts are usually noted on the right hand side of drop down menus)

* Ctrl+S
Save the current document

* Ctrl+Shift+S
Save All Documents

* Ctrl+Shift+F
Format the document (code formatting)

* Ctrl+F
Open find (or find/replace) dialogue

* Ctrl+Space
Activate code completion drop down box.

* F9, F5
  Run program, insert Breakpoint. These keys may be in either order. Visual basic originally used the F5 key for run. Many other companies writing similar GUIs wanted to use similar shortcuts, without simply copying Microsoft's, so they adopted these two keys, but reversed the order.

* Ctrl+Shift+Number / Ctrl+Number
Some editors allow you to create a type of ?bookmark? within a file, by pressing Ctrl+Shift+Number where number is 1-9 above the alpha keys. It will place a marker on the line the cursor is currently on. Pressing Ctrl+Number will jump the cursor to the position you saved with the Ctrl+Shift+Number shortcut.

Trevor Ian Peacock
All comments/suggestions are welcome.

8/10/2022 16:19:43 (+00:00)