<type>documentation</type>
<domain>edit</domain>
<id>selecting</id>
<title>Selecting Text</title>
<date>$Date$</date>
<version>$Revision$</version>
<product>all</product>

Wing can select text by characters, whole lines, or in rectangular blocks, and provides a
number of commands for quickly making selections based on the structure of code.
This makes it very easy to select code to delete, comment out, or move around.  

`Multiple selections <ref:edit/multiple-selections>`__ are also supported, as a way to
select and edit multiple parts of code simultaneously.

**Selection Mode**

When Wing is in selection mode, the current selection is automatically extended as the
caret is moved around the editor. The ``Selection Mode`` sub-menu of the ``Edit`` menu 
specifies the type of selection to make as the caret moves:

  **Characters** selects individual characters.
  
  **Line** selects whole lines.
  
  **Block** selects a rectangular block.
  
  **Cancel** exits selecton mode so that moving the caret will not extend the selection.
  This also unselects the current selection.
  
The current selection mode is shown in the status area in the lower left of the
editor window with one of ``[Char Select]``, ``[Line Select]``, and ``[Block Select]``.
When selection mode is canceled, no selection status is displayed.
  
Selection modes are also supported through the native key bindings emulated by `keyboard
personalities <ref:custom/keyboard-personalities>`__ such as ``Emacs`` and ``VI/Vim``. 

If your selected `User Interface > Keyboard > Personality
<script:show_preferences_gui#prefname="edit.personality">`__ preference does not support
them, then you will need to define key bindings for them using the `User Interface >
Keyboard > Custom Key Bindings
<script:show_preferences_gui#prefname="gui.keymap-override">`__ preference. The command
names are ``select-x``, ``next-x``, and ``previous-x`` where ``x`` is either
``statement``, ``block``, or ``scope``.

**Quick Selections**

The ``Select`` sub-menu of the ``Edit`` menu contains the following commands for quickly
selecting sections of code:

  **Select All** selects all of the current file.
  
  **Select More** adds to the current selection incrementally in logical units.  For
  example, if there is no selection then a word is selected, and if a word is selected
  then a dotted name or expression will be selected.  Eventually, a whole statement is
  selected, then a whole block, a whole scope, enclosing scopes, and finally the whole file.
  
  **Select Less** removes from the current selection incrementally in logical units,
  in opposite order of ``Select More``.
  
  **Select Statement** selects the whole statement at the current position.  This may be
  one line or several lines of code.
  
  **Select Next Statement** selects the statement after the current one.
  
  **Select Previous Statement** selects the statement before the current one.
  
  **Select Block** selects all of the current indented block of code.  A block of code
  is a contiguous range lines delimited by blank lines.
  
  **Select Next Block** selects the block after the current one.
  
  **Select Previous Block** selects the block before the current one.
  
  **Select Scope** selects all of the current indented scope.  A scope is a whole ``def``,
  ``class`` or module.
  
  **Select Next Scope** selects the scope after the current one.
  
  **Select Previous Scope** selects the scope before the current one.

