Saturday, 28 April, 2007

Keyboarding [Part 1] - The Very Basics

Hi, my name is Dave, I'm certifiably … a mouser. As a matter of a fact, I've intentionally ignored keyboard short-cuts since I upgraded from DOS to [it’s only a passing fad] Windows 3.0 and I just can’t justify having made that decision - at all. Yea, I know, what a horribly inefficient way to get anything done -but- I’m on the road to recovery and plan on dragging you with me, if you’re interested. Sadly, the inspiration didn’t actually come from any self realization of inefficiency or a burning need to become more productive. I read an article Going Commando - Put Down The Mouse on Coding Horror by Jeff Attwood which included digging down into and reading the links found in the article, and it came to me … gosh, you’re unbelievably inefficient with that mouse in your hand. The real kicker was … I was on the laptop which has one built right into the machine, conveniently located right under my thumbs and I’m using one that’s plugged into a USB port. Truth be told, I’m so addicted to it, I’ve been known to pick up the mouse to select a word that is currently right next to the cursor, right clicking on the selection and scrolling to cut/copy or delete on the selection menu! Have I mentioned how dumb I feel about all this? If you’re anything like me, this problem is so ingrained that finally getting around to dropping the mouse, specifically when you’re already working at the keyboard [in the code window], is going to take some effort. Having said that, once you get started down the right path, it seems to get easier and easier. Part of the solution is to make using the mouse -more- of an effort than using the keyboard. Unplug it or hang it over the back of the desk. Digging down into the Going Commando - Put Down The Mouse article I found another written by Jeff called (Very) Basic Textbox Keyboard Shortcuts. This article, which if you’re a newbie like me at this, is a great place to start. You will quickly find that some of the key combinations take a bit of a different path in the code editor than what you get from them in other text editors. We’re going to look at the Delphi key mapping. On to the learning portion of our program … (Very) Basic Textbox Keyboard Shortcuts for the Delphi IDE Code Window. Basic Navigation We all know the basic navigation keys … the Left, Right, Up and Down arrow keys along with Home, End, Page Up and Page Down.
  • Left and Right will move the cursor one character in the chosen direction.
  • Up and Down will move the cursor one line in the chosen direction.
  • Home and End move the cursor to either the beginning or end of the current line.
  • PgUp and PgDn will move to the previous or next text block that will fit in the viewable text area and it will try to keep the cursor in the same [row-column] position.
All these keys work exactly as advertised in the IDE. There is one trick that you really need to know about … Home-Home. The first time you push it, it will do exactly as advertised jumping to the very beginning of the line – the next time you press it, it will jump your code indent and end up just before the first character in whatever code you have on that line. Cool. Accelerated Navigation Want to move that cursor along a wee bit faster? Meet the Ctrl key.
  • Ctrl and either Left or Right will move the cursor to the beginning of the previous or next word.
  • Ctrl and either Up or Down will scroll the code window contents up or down leaving the cursor in it’s current position … unless you try and scroll the cursor off the code window.
  • Ctrl and either Home or End will move the cursor to the beginning or end of the current module.
  • Ctrl and either PgUp or PgDn will move the cursor to the beginning or end of the visible code.
Selecting Text Need to select some text? Meet the Shift key. In a nut shell, adding Shift to any of the Basic or Accelerated key combinations that we’ve already discussed, will select everything between the current position of the cursor, and it’s destination. Yes, there is an “exception” … well, sort of, it isn’t an exception if you really think about it. Ctrl-Shift with Up/Dn won’t select any text primarily because Ctrl Up/Dn doesn’t move the relative cursor position. As the Ctrl-Shift Up/Dn shortcuts aren’t useful in selecting text, this combination has been assigned to move the cursor in a very different, but extremely useful manner. This is a key combination that just has to be in your “use it all the time” collection, read what I’ve already had to say about Ctrl-Shift-Up and Ctrl-Shift-Down. Coming up next ... Keyboarding [Part 2] – Power of the Alt Key Thanks for stopping by, -- Dave

3 comments:

  1. I'm a keyboard addict, but I also use an external USB mouse, especially of the optical and scroll-wheel type: I can't get used to the built-in laptop mouse! But, when coding or simply typing, I tend to use all available keyboard shortcuts. When browsing the net, I can't do without the back button on the mouse or the scroll wheel...

    ReplyDelete
  2. I am always amazed when I see a user ignoring all the shortcuts. Even simple things like Ctrl-X & C & V for cutting, copying and pasting. I have been programming for a long time and I am convinced that the main reason I don't have hand problems is because I've always used the keyboard for most editing actions. The mouse is a useful addition to the keyboard but not a replacement.

    ReplyDelete
  3. You know ... up until recently the only real keyboard combination I used consistently was Ctrl-Z. All the others are starting to become second nature but it's still taking a conscientious effort with some.

    I wasn't expecting the time between parts to take this long but not long after posting part 1 things went absolutely nuts at work ... maybe next week things will calm down a bit.

    Thanks for the comments guys.
    --
    Dave

    ReplyDelete