Home > Articles

This chapter is from the book

This chapter is from the book

Using the Editor

The Visual Studio .NET environment includes a powerful text editor. This editor includes a number of features aimed at making your code-writing experience more productive and as flexible as possible. The following subsections describe some of the Visual Studio .NET code editor features.

Using IntelliSense to Enter Code

Programming in Visual Studio .NET, even at the very beginning, involves working with members (properties and methods) of objects. To make it easier for you, when you enter the name of any object, Visual Studio .NET provides a drop-down list of the members of that class of object. In addition, when you type the name of a method, Visual Studio .NET provides a description of the method signature, including a list of all the parameters you need to supply for the method and a list of all the various ways you can call the method. This technology is named IntelliSense. In addition, IntelliSense allows you to auto-complete any syntax by pressing the space bar or the Tab key once the command you wish to use is highlighted.

Splitting the Editing Window

At times, you may want to view locations within the same code window, as shown in Figure 3.18. You can select the Window, Split menu item to insert a horizontal splitter bar into the code window. You can scroll each pane of the window individually, allowing you to view two locations within the same file. You can also split the editing window by grabbing the divider bar in the upper-right corner of the editing window and dragging it downward. Double-clicking the same area acts as if you'd selected the Window, Split menu item.


If you need a full-height split of a document window, use the Window, New Window menu item to create a second window. Then position it however you like.

Finding Text

You can search for text anywhere in the current procedure, the current module, or within a highlighted block of code. From any code window, you can select the Edit, Find and Replace, Find menu item or press Ctrl+F to bring up the Find dialog box, as shown in Figure 3.19. If you highlight a piece of text in your code window and then select the Find window, the text will be automatically added to the Find What combo box.

Enter a piece of text in the Find What combo box and click the Find Next command button to find the next location in the code that matches the string. You can keep this dialog box open and keep clicking Find Next to find the next occurrence of the string. You can also close the Find dialog box and press F3 to repeat the search.

Figure 3.18 You can split the window to see two different areas of your code at the same time.

Figure 3.19 The Find dialog box will help you search for text in your project.

There are other options you can use to find a particular string in your source code. You can narrow your search to the current procedure or the current module, or you can search across all open documents. You can find a whole word that matches the string you input, you can perform a case-sensitive search, or you can enter wildcards, such as * and ?, to perform pattern matching.

Replacing Text

Replace text using the Replace dialog box. To bring up the Replace dialog box, select Edit, Find and Replace, Replace, press Ctrl+H from within a code window, or click the Replace command button in the Find window. Figure 3.20 shows an example of the Replace dialog box.

This dialog box is essentially the same as the Find dialog box, but it allows you to replace one piece of text at a time. You can also find the next occurrence of the Find What text by clicking Find Next. If you wish to replace all the values within the scope specified, you can click Replace All.

Figure 3.20 Find and Replace can come in handy for changing one variable name to another.

Finding Text in All Project Files

The Find dialog box is useful if you are searching open documents, but if you need to search for items in any file in your current project or in your whole solution, you will need to use the Find in Files dialog box shown in Figure 3.21. This dialog box allows you to search all files, regardless of whether they are open, across the current project, or even across the whole solution.

Figure 3.21 Find in Files allows you to look for text in all files, regardless of whether they are open.

Replacing Text in All Project Files

The Replace in Files dialog box, shown in Figure 3.22, allows you to perform a search-and-replace operation throughout the files in your project or within a folder. A nice feature of the Replace in Files dialog box is the Keep Modified Files Opened on Replace All option. If you choose to make a bulk change and click Replace All, this option (if checked) will open each modified file so that you can review the change and undo it if it's not what you intended.

Searching for Symbols

A symbol is a definition of a variable, such as you might find in your own classes or structures. Searching for symbols is different from searching for normal text in that searching for symbols only involves looking for definitions and references to those definitions based on the symbols you specify. The definitions and references are displayed in the Find Symbol Result window shown in Figure 3.23, which resembles the Search Results window you see in Windows Explorer.

Figure 3.22 Search-and-replace operations can be performed within files using this dialog box.

Figure 3.23 The Find Symbol dialog box allows you to find the definition of classes.

Incremental Searching

Under the Edit, Advanced menu is an item named Increment Search (Ctrl+Alt+I when using the VB keyboard scheme). You enter an incremental search mode in the code editor so you can press any of the alphanumeric keys and drill down to the selection in your file that matches what you have typed so far. The Incremental Search feature interacts with the main Find tool by sharing the last Find pattern. You can typically press the Shift key instead of the Alt key to initiate a reverse incremental search or to toggle between a forward search and a reverse search.


A regular Find operation searches for text in hidden regions when you've selected the Search Hidden Text option, but an incremental search does not.

Using Bookmarks to Locate Code

A bookmark allows you to mark a certain line of code and then find it quickly later. When you close a document, bookmarks in that document are discarded. If you want pointers to code that are persistent, use the Edit, Bookmarks, Add Task List Shortcut menu item. The Task List shortcuts will be saved with your solution, regardless of whether the documents are open. Task List shortcuts also display as items in the Task List, making navigation to those locations even easier.

Commenting/Uncommenting Blocks of Code

This handy tool allows you to highlight a block of text and then comment or uncomment it using the Edit, Advanced, Comment Selection or Uncomment Selection menu item. This tool becomes even more handy when you realize that lines of code that contain line continuation (that is, logical lines of code broken into multiple physical lines using the " _" characters) don't "comment out" as well as they did in Visual Basic 6 (where commenting out the first line of the block commented out the whole block). Now, you must add an apostrophe to comment out each line, in turn. Using these menu items (or their corresponding toolbar buttons) makes it easy to comment and uncomment blocks of code.

Dragging and Dropping Text

Highlight the text you want to move, click and hold your mouse, and then drag the text to the new location. To copy the text, press and hold down the Ctrl key while you are dragging the text.

Word Wrapping

Word Wrap is a feature that removes the horizontal scroll bar and ensures that all text is visible in the document window by wrapping long lines at word boundaries. You can enter this mode by selecting the Edit, Advanced, Word Wrap menu item. No carriage returns or line feeds are inserted into your document—Word Wrap is a visual display effect only.


To be honest, we find Word Wrap to be a feature of limited value. Turning this feature on makes it difficult to decipher Visual Basic .NET code, because Visual Basic relies on line breaks to delimit code. Word Wrap would be more useful in a language such as C#, where semicolons delimit logical lines of code, not line breaks.

Toggling Full Screen Mode

Your Visual Studio .NET design environment can sometimes get cluttered with the multitude of open windows and toolbars. This clutter can cause a problem when you wish to see more than a few lines of your source code at the same time. You can use the Full Screen mode provided by Visual Studio .NET to see more of your source code. To enter this mode, open a code editor window and select the View, Full Screen menu item. To return to normal mode, you can select the View, Full Screen menu item again.

Tabbing Between Windows

To move quickly among the various open windows in your Visual Studio .NET session, press Ctrl+Tab to iterate forward and Shift+Ctrl+Tab to iterate backward. This keeps your hands on the keyboard instead of having to use the mouse to select a specific window.

Managing the Clipboard Using the Clipboard Ring

Although the Windows Clipboard can hold only a single piece of text at a time, Visual Studio provides the Clipboard Ring, in which you can store up to 20 items at a time. If you add another item, the Clipboard Ring will remove the first item you added so that it maintains at most 20 items. To view the items in the Clipboard Ring, place your cursor somewhere in a code window and use the Edit, Cycle Clipboard Ring menu item. You can also look at the hotkey combination next to this menu item to determine the keystrokes you should use. Whichever keystrokes you use, do not release these keys but keep pressing the final key in your sequence. This allows you to cycle through all the items in the Clipboard Ring. When you find the one you want, release the keys, and the selected item will stay in your code window.

You may also view the Clipboard Ring by selecting the Clipboard Ring tab in the Toolbox window. You can then view each of the items and even drag and drop from the Toolbox into the code editor.

Going Back

Most Visual Basic 6.0 users are familiar with using the Shift+F2 key to take them to the definition of the procedure whose name is under the mouse cursor. In Visual Basic 6.0, you can also use the Ctrl+Shift+F2 key to return to the location where the procedure was called. (These keystrokes also work in Visual Studio .NET, if you've selected the Visual Basic 6.0 keyboard layout. If you've selected another keyboard layout, you can right-click a procedure name and select Go To Definition on the context menu that appears.)

Visual Studio .NET enhances this capability by creating a stack of "Go Back" locations. Each time you perform a command that takes you away from where you currently are located in a document, that previous location is placed into this Go Back stack. Some of the commands that mark these locations are Incremental Find, Opening a New Document, GoTo Definition, and others. This means that at any time you may use the Ctrl+Shift+F2 key to return to any of these Go Back locations. You may continue to hit these keystrokes to cycle through the complete stack of Go Back locations.


We could not find any documentation on the Go Back feature for any of the keyboard schemes. It works fine for the Visual Basic scheme, but if you are using any of the others, you may just have to experiment.

Creating Macros

If you find yourself performing the same functions over and over again within the Visual Studio .NET IDE, you can take advantage of the environment's capability of recording these steps into a macro. Using this feature is much like recording a macro in the Microsoft Office products. Use the Tools, Macros, Record Temporary Macro menu item to turn on the Macro recorder, perform the steps, and then save the macro either temporarily for this session or permanently within a macro project that you can then add to any solution you work with. Although this is a handy feature, digging deeper here is beyond the scope of this book. Consult the online help facility in Visual Studio .NET for more information on using the Macro Recorder.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020