Issue dated - 9th August 2004

-


Previous Issues

CURRENT ISSUE
INDIA NEWS
SECURE SPACE
COLUMNS
TECH FORUM

THE C# COLUMN

BETWEEN THE BYTES
TECHNOLOGY
SPECIALS <NEW>
Symantec Report
Security Headquarters
JobsDB
MINDPRINTS
HMA BANKBIZ
EC SERVICES
ARCHIVES/SEARCH
IT APPOINTMENTS
Openings At Jobstreet.com
WRITE TO US
SUBSCRIBE/RENEW
CUSTOMER SERVICE
ADVERTISE
ABOUT US

 Network Sites
  IT People
  Network Magazine
  Business Traveller
  Exp. Hotelier & Caterer
  Exp. Travel & Tourism
  Exp. Pharma Pulse
  Exp. Healthcare Mgmt.
  Express Textile
 Group Sites
  ExpressIndia
  Indian Express
  Financial Express

 
Front Page > TechSpace > Story Print this Page|  Email this page

The Tech Forum

Tips and Tricks

Creating custom keyboard shortcuts in VS.NET

Any VS.NET user knows that it is a very rich IDE. Lot of functionality is available in all the windows, editing areas and so on.

Many of these options have pre-defined keyboard shortcuts. Many of them don’t. Keyboard shortcuts are extremely useful when you use a particular option repeatedly. Often you keep selecting menus or toolbars manually. Sometimes, the default shortcut is cryptic and you cannot remember it. Otherwise, the shortcuts do not exist at all.

Here is how you can assign your own custom shortcuts to the actions you use very often.

1. Start Visual Studio.

2. Choose Tools – Customize.

3. Click on the button “Keyboard…”.

4. Now a complex looking dialog will appear.

5. On the left section, there are various items which are customisable. Keyboard will be selected in this case.

6. All the settings you change may interfere with settings of other users who may share your machine. To avoid this, you can save your settings as a collection of named settings. Therefore, before you customise anything, click on Save As… and choose a different name for your collection of settings. Ideally give your name here so that it is easy to understand.

7. Now, look at the dialog. Understand that the entire functionality of VS.NET IDE is internally implemented as a set of Commands. These commands are listed here. Each command starts with a name of the menu, followed by a dot(.) and then the name of the command itself. There are so many commands that it would be cumbersome to search these blindly.

8. You have opened this dialog because you want to assign a shortcut key to a toolbar button or menu item (pull-down menu or right-click context menu). You will therefore, know the name of the menu or the tooltip. Try to type part of the menu name in the textbox “Show Commands Containing”. This will quickly conduct a substring search on all the commands and give you a filtered list. This way, you have to browse through a smaller set of commands to locate the one you want.

9. If the command already has a key assigned, view it. It is possible that there is a shortcut key but it is not shown in the menus. If this is the case, you just have to memorise the shortcut and exit this dialog. No customisation is required.

10. If you find that there is no shortcut or you don’t like the default shortcut, you will need to customise it. Once you have located the command, move to the “Press shortcut key(s)” textbox. Here you don’t type the shortcut key. You simply press the required combination. VS will understand which keys you pressed and put their names there. Please note that you can specify multiple shortcuts for a single command.

11. It is possible that the keyboard shortcut that you are trying to use is already used by VS.NET for some existing command. If so, this command will be listed below. You can, of course, override this shortcut and map it to the command selected by you. If you don’t want to disturb the current assignment, you will have to type a new keyboard shortcut. Remember to delete the existing shortcut before you type the new one.

12. Now click on Assign.

13. Do this for all the commonly used menus / toolbars you use often.

14. This way, you can dramatically increase your productivity and efficiency while working on VS.NET.

15. It is possible that you need different types of shortcuts depending upon the type of project (winform / webform) or the type of file being edited. For such custom requirements, save your shortcut settings under different names and load the appropriate collection as per your needs.

Spend a little time on this customisation and see the difference for yourself.

Does this customisation end here? No. Anytime you notice yourself choosing some command, toolbar, menu repeatedly, remember to create a keyboard shortcut for it.

By the way, this entire functionality is added in VS.NET. Earlier versions of Visual Studio did not have this functionality. Is this new? Unfortunately not. All this functionality is picked up from MS Word. It existed in Word since Office 97! What to learn from this? How to use existing features in one product to enrich another product! This is called ‘reuse’.

Of course, there is much more to VS.NET customisation. You can write your own VBA code, write add-ins, record macros which combines multiple, repetitive actions and so on. But more on that some other time.

Appropriate page numbering in MS Word

I know this is a technical column. So why this topic? The reason is simple. Most of us create documents but do not understand this simple concept.

How is a typical document written? First page is the title page. Next page may contain revision history. Next one contains a table of contents. Then the actual document starts.

For ease of referencing each page, we put page numbers. Does the page number of the first content page show ‘Page 1’? Most probably not. This is because, the page numbering starts numbering from the title page itself. By the time the actual content starts it is ‘Page 3’ or more.

Now, you want a different numbering for initial pages as I, II, III and so on. For the actual content, you want the numbering to be in numerals 1, 2, 3, etc.

Further, you don’t want the first page to have page number. Is this important? Yes. Any professional document is expected to have this bare minimum functionality. Whether it is a SRS document or Object design or a sales proposal, it does not matter.

I was amazed to see that this simple functionality is not known to most people. Further, to achieve this result, there is no single menu or toolbar available. You need to understand simple concepts of Word usage to arrive at this result.

Hence I thought it is a good idea to mention this. Here is how to make this happen.

  • Understanding sections

A word document contains pages, paragraphs, sentences and words. Beyond that, it contains another type of demarcation called ‘sections’. You may never have encountered this term because Word automatically makes the default section — Section 1 — for you when you create a new document.

You can see the current section in the status bar.

How can you insert a new section? Simple.

From the Insert menu select Break and then choose Next page from the Section break types.

So what is this section break for? It is to have a different set of page layout options within the document. For example, your document has simple descriptive content. Within this content, you have chosen the portrait layout. In a particular page, you want to insert a table which contains lots of columns. These don’t fit properly in the portrait layout. You want to change it to landscape because it offers more page width. If you change it directly (by choosing File – Page Setup – Layout – Landscape, the entire document changes to the landscape layout. But this is not what you wanted.

Another example is that you want separate headers, footers, page numbering schemes for initial pages (title, table of contents, index and so on) and a different scheme for actual content.

This is where you create a new section. A new section can have independent formatting settings within a single document.

So let us say, you want the first page with portrait layout, second with landscape and third page onwards with portrait layout again.

Here is how you do it.

1. Finish the first page content.

2. Choose Insert – Break – Next Page

3. Create your table with the additional width available

4. Choose Insert – Break – Next page again

5. Thus you created two new Section breaks.

6. This means, there are three sections in the document.

7. Now position your cursor in the second section and choose File – Page Setup – Layout. Now choose Landscape. Notice that there is a combo box which allows you to specify whether this layout change is to be applied to current section or the whole document. Do not alter this setting (default is “This section”)

8. Now write the third page content.

9. Check out the Print Preview with multiple pages. You will see the result.

10. Of course, within Section 2 you can write multiple pages or your table can span multiple pages. That does not matter. Whatever is there is section 2 will have landscape. Section 1 and section 3 content will continue with Portrait layout.

  • Page numbering

Page numbering understands sections. By default it starts at 1 from the physical first page in Section 1 and continues counting across sections.

If you want, you can reset it to 1 for ‘each’ section.

That is what we are going to do to achieve the result we wanted.

1. Start the blank document.

2. Press Ctrl + Enter to create a manual page break where you will write the title and related information.

3. If you want Table of contents, press Ctrl + Enter again and create your table of contents in this page.

4. Now insert a section break by choosing Insert – Break – Next page.

5. Now you have two sections. Second section for actual content and first section for the title pages.

6. Now move to the second section.

7. Choose View – Header and footer.

8. Now, header and footer will be visible and demarcated by dashed border. The actual content will be disabled (not editable).

9. A new toolbar will appear. This toolbar has many options which are specific to headers and footers.

10. There is a button called “Link to previous”. This is enabled by default. This means, any section automatically copies the contents of headers and footers from the previous section. We want these to be separate. So click on this button to disable it.

11. We disabled it only for Header. Now, click on the “Switch between Header and Footer” toolbar button to move to the footer. Disable the “Link to previous” button for footer also.

12. Now the first and second section can have entirely separate headers and footers.

13. There is also a button which allows you to go to the next and previous sections.

14. Make sure that you are currently in Section 2. Now choose Insert – Page numbers. From the dialog choose whether you want it in header or footer and whether on right or left side. Also disable the check box “Show number on first page”.

15. Now click the Format… button on the dialog.

16. Notice that there is an option called ‘Start at …’. Choose 1 from this option. This indicates that it should not continue counting actual pages from the previous section but restart numbering for this section from number 1.

17. Choose Ok.

18. Now we have the required functionality!

19. In this case, the title and table of contents pages (section 1) do not have page numbers.

If you want, you can move to the first section and repeat the relevant steps. It would be a good idea to choose another type of numbering scheme (roman numbers for example) to differentiate the two sections.

<Back to top>


© Copyright 2003: Indian Express Group (Mumbai, India). All rights reserved throughout the world. This entire site is compiled in
Mumbai by The Business Publications Division of the Indian Express Group of Newspapers.
Please contact our Webmaster for any queries on this site.