Ctrl+F2 (5 star tip) - moves focus to the "Object" combo-box above the Code window. ...from here you can select the procedure you're editing by using DownArrow to drop-down the combo-box's list of objects. Press the first letterof the object name, or UpArrow/DownArrow/Home/End to navigate through the list. Home is good for selecting the (General) section, where non-event-code procedures live. Then, press Tab to toggle between the "Object" and "Procedure" combo-boxes and navigate similarly. Press Return to selectone, and you'll be back in the Code window at the correct position.
Ctrl+Shift+F2 - I mentioned this one before. Greg adds that it works without first pressing Shift+F2, as it cycles through the last 8 positions visited, not just where you were before you viewed the definition of a variable.
F3 - find the next occurrence of text last searched for
Shift+F3 - find the previous occurrence of text last searched for
Ctrl+F3 - find the next occurrence of selected text, or the word under the cursor
Ctrl+Shift+F3 - find the previous occurrence of selected text, or the word under the cursor
The general rule-of-thumb for the previous four is as follows: "Press shift to search backwards; press ctrl to start searching for something different".
F6 - (when the Code window is split into two panes) - toggles between the panes. To split the panes first (or indeed un-split afterwards), press alt+W, P.
Ctrl+Shift+F9 - clear all breakpoints
Tab (when a block is selected) - indent the whole block
Shift+Tab (when a block is selected) - un-indent the whole block
Ctrl+Z - undo the last change. The last 20 changes can be backed out of.
Ctrl+I - show the quick-info tooltip. Tells you the type of variable,or value of a constant, at the cursor.
Ctrl+Shift+I - show the parameter-info tooltip. Tells you the parameters required in a function or sub call, without having to insert a spurious comma and delete it! (which you can't do anyway in modules that are marked as read-only).
Ctrl+G - show the Immediate window.
Ctrl+F - show the Find dialog
Ctrl+H - show the Replace dialog
...within Find and Replace dialogs, the highlighted text (or the word underthe cursor is automatically placed in the Find What field). Press Return to Find Next, Esc to close the dialog, or alt+letter to focus and/or toggle onthe other controls [duh...?]
Ctrl+Y - remove the current line without having to select it. This one was contributed by Joacim Andersson.
Object window shortcuts (i.e. the forms)
Shift+F4 - show the custom property pages for the selected object
Arrow keys - UpArrow/DownArrow/LeftArrow/RightArrow
Select a different control on the container.
With Shift pressed, enlarge/shrink the selected control(s).
With Ctrl pressed, move the selected control(s) around the container.
Tab or Shift-Tab - select the next/previous control in the tab order
Project Explorer window
Tab - switch between projects in a group
Down Arrow - move down the tree
Up Arrow - move up the tree
Right Arrow - expand a folder, or go to the first child node
Left Arrow - collapse (if a folder) and go to the parent node
Numeric Plus - expand the folder
Numeric Minus - collapse the folder
Property window
Tab or Shift+Tab - cycle forwards/backwards through the control drop-down, the tabs, the property name, and the property value. This method can be useful for changing (or just reviewing) several control's properties, eg the TabIndexes (TabIndices? :-). Useful if certain controls are on hidden areas of the form (eg on different tabs of your form) andyou don't want to hunt them down and click (ugh!) on them.
The "Categorized" tab in Properties is dead useful for hiding the other properties if you're reviewing the sizes of your controls. Just click on all the minus signs except for the one next to the "Position" category. Did I say click?! I meant Tab to a property category, press LeftArrow to collapse it, then press DownArrow to move down to the next property category.
Break Mode
Shift+F5 - re-run from the start (surely not that useful?)
F8 - step into the current statement
Shift+F8 - step over the current statement
Ctrl+F8 - run upto the statement under the flashing cursor
Ctrl+Shift+F8 - run the rest of the current procedure and break againwhen exiting back to the calling statement
F8 based shortcuts can also be used from design mode, to start the project and immediately single-step through the code, but I can imagine that stepping through the start-up code of a big project would be very tedious. In fact I bet you'd get a misleading impression of the program flow, because break mode tends to suppress certain events from firing.
Ctrl+F9 - set the statement under the flashing cursor as the next one to execute.
Ctrl+L - view (and navigate) the call stack
Miscallaneous
Ctrl+F4 - close the current child window (as per bog-standard Windows)
Ctrl+F6 or Ctrl+Tab (or with Shift) - cycle forwards/backwards through the Code windows and Object windows
Shift+F7 - go to the Object window. This is the complement of F7 whichyou mentioned.
You want to make more space for the Code window while programming? Hiding the Project Explorer, Properties and Immediate windows is easy:- Ctrl+R, menu, H to hide the Project Explorer window, F4, menu, H to hide the Properties window, Ctrl+G, menu, H to hide the Immediate window.
Here are 2 really shortcuts courtesy of Dean Hutchings:
Assuming you have "Break On All Errors" selected, you can do the following:
Alt+F5 - continue past error dialog
Alt+F8 - step past error dialog
These are great if you want to be sure to see all errors but don't want to mess around with toggling the error trapping settings.
Not necessarily a keyboard shortcut for VB so much as Windows in general; any ListView (Explorer folders included) which is in report (ie, details) view can have its column widths auto-resized by pressing Ctrl+NumericPlus.
All I can say is: Thank you, Greg. These are surely to improve coding speed. In addition, Greg provided some stupid mouse tricks as well, which will be included in an upcoming article.
There are many more simple keyboard shortcuts that for some reason are seldom used by programmers. Below are some of them:
Place the cursor on a function name, then press Shift-F2 combination and it will take you to that function.
Press Ctrl-Shift-F2 and it will take you back. These two combos have been there since the dawn of VB.
Have you ever lost the Project Explorer window? Press Ctrl-R to bring it to life.
Do a quick save before running. Press Ctrl-S.
Never select Start button. Always do a Start With Full Compile. Either press Ctrl-F5 or hold down the Ctrl key while pressing the Start button. (Or as some of my less than competent co-workers call it: The 'Play' button).
Want to do a quick comment/uncomment of your code? See this tip.
Do you want to quickly see the value of a variable? Place a cursor on the variable and press Shift-F9.
To toggle a breakpoint, use F9.
Ctrl-A will select all the code in the Code Window. BTW, if you didn't know this one, please pack up your copy of VB and return it to the store for a full refund. You don't deserve to be a programmer.
Are you sick and tired of going to the Project menu and selecting Components? Simply press Ctrl-T.
To bring up properties for any object in VB, press F4. To bring up code, press F7 on any obj
No comments:
Post a Comment