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.


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 Working with 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. Anything typed or pasted into the selected area is inserted at the same point on each line.

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.


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


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


  • 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.


  • 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, "abc" or 'abc').


    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.

As of Visual Studio 2010, you can type or paste text in column selection mode. Whatever is typed or pasted at the cursor point in the selection is repeated at the same horizontal position on every line of the selection. This creates many opportunities to eliminate repetitive typing.

For example, when declaring a series of variables with the same type and access modifier, you can select a column with one row for each variable, type the access modifier and type name once, then exit the selection and name the variables. You could then select a rectangle containing the variable names and paste that elsewhere when you want to set their values.

To add text to a column selection

  • Hold down the Alt key and use the mouse or arrow keys to create a rectangular selection area.


Setting the width of the selection to 0 characters allows insertion without overwriting existing text or white space.

  1. Type some text.

    This text will repeat in the same horizontal position on each line of the selection.


    Type Ctrl+V to paste text.

    If the source text was copied in stream mode, it will be inserted in the same position on each line of the selection.

    If the source text was copied from a column selection, each line of the source text will occupy one line of the destination area. If the destination area contains more rows than the source, the source text will not repeat. If the source text is larger than the destination area, the selection will expand to accommodate it.

    Note   Rectangular selections from tables and spreadsheets in other applications will be treated as stream selections. The selected block of text will repeat on each line of the destination area.

See Also


How to: Navigate Code and Text

How to: Move, Copy, or Store Text


Editor Convenience Commands and Features

Customizing the Editor

Other Resources

Editing Text, Code, and Markup