Bagikan melalui


How to: Select and Change Text

Whether you are editing code, HTML or XML markup, or plain text, the Code Editor provides the customary functionality of a text editor or word processor. The procedures to select, copy and paste text and code are familiar and consistent.

For Visual Studio projects, the Code Editor also provides automatic statement completion in the programming language of the project, syntax checking, keyword colorization, and other services. For more information, see How to: Navigate Code and Text.

You can format your code manually, or let the integrated development environment (IDE) do it for you. For more information, see Customizing the Editor. Drag and drop procedures are covered in How to: Move, Copy, or Store Text.

Note

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

Selecting Text and Code

The Code Editor has two text selection modes:

  • Continuous Stream Mode   Selection proceeds in a continuous, linear stream from the start of the file to the end, as in the standard Microsoft® Windows® multi-line edit control. Entire lines are selected when you move to the next or a previous line.

  • Column (Box) Mode   Only a rectangular portion of text is selected instead of the whole line. The selection includes all of the characters captured within the rectangle defined by the first (anchor) character and the last character in the selection.

To select a continuous stream of text

  • Press down on the left-click button of your mouse, and then drag the cursor over the text to select.

    —or—

  • Hold down the SHIFT key and press any Arrow key.

    —or—

  • Click in the Selection Margin, located at the far left of the Editor window, to select a whole line.

    —or—

  • Hold down the SHIFT key and click in the Selection Margin to extend your selection line by line.

To select a rectangle of text

  • Hold down the ALT key, press down on the left-click button of your mouse, and then drag the cursor over the text to select.

    —or—

  • Hold down the SHIFT+ALT keys and press any Arrow key.

Manipulating Text and Code

The Code Editor supports many of the same text manipulation features found in word processing applications such as Microsoft Word. For example, you can:

  • Copy and Paste text or code

  • Put the Code Editor into Overstrike mode using the INSERT key

  • Use the DELETE and BACKSPACE keys to remove text or code

You can also Copy and Paste text or code from other text editors into the Code Editor. In addition, you can insert ready-made blocks of code into a file. For more information, see Code Snippet Picker.

To paste text or code from Microsoft Word into the Code Editor

  1. Before copying text or code from a Microsoft Word document, make sure that all quotation marks are straight, not slanted, and that quotes around strings occur in matched pairs (for example, "test" or 'rest').

    Tip

    In Word, expand the Tools menu and select AutoCorrect Options. On the AutoFormat As You Type tab under the heading "Replace as you type," clear the check box for the "Straight Quotes with Smart Quotes" option.

  2. Select text or code in the source document, and press CTRL+C to copy it.

  3. Move the insertion point to the desired location in the code editor, or select text or code to replace.

  4. Press CTRL+V to paste in the copied text.

    The copied text is inserted. If previous text or code was selected, it is replaced.

See Also

Tasks

How to: Navigate Code and Text

How to: Move, Copy, or Store Text

Concepts

Editor Convenience Commands and Features

Customizing the Editor

Other Resources

Editing Text, Code, and Markup

Change History

Date

History

Reason

September 2009

Changed example text.

Content bug fix.