<type>documentation</type>
<domain>intro</domain>
<id>tutorial-editor-details</id>
<title>Tutorial: Other Editor Features</title>
<date>$Date$</date>
<product>all</product>

There are a number of other editor features that are worth knowing about:

**Goto-Line**

You can navigate quickly to a numbered source line with ``Goto Line`` in the ``Edit``
menu, or with the key binding displayed there.  Type the line number and then press
``Enter`` to complete the action.

~~~if not WING101:
In Wing Pro and Wing Personal, line numbers can be shown in the editor with the ``Show
Line Numbers`` item in the ``Edit`` menu.

**Multiple Selections**

In Wing Pro and Wing Personal, multiple selections can be made on the editor with the
``Edit > Multiple Selections`` menu items and |multi-select| ``Multiple Selections`` in
the toolbar.  

.. |multi-select| image:: multi-select.png
  :class: inline_image

This provides a quick way to select several identical occurrences of text either
sequentially, or within a particular file, class, function, or block:

.. image:: multiple-selections.png
  :width: 503
  :height: 244
  
Once there are multiple selections, edits made will be applied to all the selections
concurrently.

Multiple selections may also be made by pressing ``Ctrl+Alt`` (or ``Command+Option`` on
the Mac) while making a selection with the mouse.
~~~

**Selection Mode and Structural Code Selection**

Wing supports character, line, and block mode selection from ``Selection Mode`` in the
``Edit`` menu, and the key bindings shown there.

In Python code, the ``Select`` sub-menu in the ``Edit`` menu can be used to easily select
and traverse logical blocks of code. The ``Select More`` and ``Select Less`` operations
are particularly useful when preparing to type over or copy/paste ranges of text. 

Try these out now on ``urllib`` in ``ReadPythonNews`` in ``example1.py``. Each repeated
press of ``Ctrl-Up`` will select more code in logical units. Press ``Ctrl-Down`` to select
less code.

The other operations in the ``Select`` sub-menu can be used for selecting and
moving forward or backward over whole statements, blocks, or scopes.

See `Selecting Text <ref:edit/selecting>`__ for details.

~~~if WINGPER or WING101:
**Code Warnings**

As you probably noticed while working through the tutorial, Wing flags some types of
incorrect code by underlining it. This is done for syntax errors, indentation errors, code
that can't be reached, and other types of errors. Hovering the mouse cursor over an
indicator on the editor displays details for that warning or error in a tooltip.

Note that Wing Pro implements a much richer code warnings capability that 
supports more error types and can display warnings fromg external checkers
like mypy, Pylint, and pep8.
~~~

~~~if not WING101:
**Line Editing**

In Wing Pro and Wing Personal, lines can quickly be inserted, deleted, duplicated,
swapped, or moved up or down with the operations in the ``Line Editing`` sub-menu of the
``Source`` menu.

If your keyboard personality does not support them, then you can add your own key bindings
with the `User Interface > Keyboard > Custom Key Bindings
<script:show_preferences_gui#prefname="gui.keymap-override">`__ preference. The command
names are: ``new-line-before``, ``new-line-after``, ``duplicate-line-above``,
``duplicate-line``, ``move-line-up``, ``move-line-down``, ``delete-line``, and
``swap-lines``. 
~~~

~~~if WINGPRO:
**Code Snippets**

In Wing Pro, the ``Snippets`` tool in the ``Tools`` menu can be used to define and use
code snippets for commonly repeated motifs, such as ``class`` or ``def`` skeletons or
documentation templates.

You may already have noticed that these appear in Wing's auto-completer. Try this now by
typing ``def`` into the top level of a file in the editor. Then select the ``def
(snippet)`` completion choice. Wing will place the snippet into the editor and enter into
a data entry mode similar to the mode used for entering arguments when the ``Auto-Enter
Invocation Arg`` auto-editing operation is enabled. Type any text you want in each field
within the snippet and press ``Tab`` to move between the fields. Data-entry mode will end
at the last tab stop or if you move out of the snippet body.

Now try it again with ``class`` and then inside the scope of the class use the ``def``
snippet again. Notice that the form of snippet in this context differs from the one used
at the top level; it includes ``self``. Like-named snippets can be defined in this way for
the following contexts: ``module``, ``class``, ``function``, ``method``, ``attribute``
(after a period), ``comment``, and ``string``.

See `Code Snippets <ref:edit/snippets>`__ for details.
~~~

**Block Commenting**

Lines of code can be commented out or un-commented quickly from the ``Source`` menu
~~~if WINGPRO:
or, in Wing Pro, by pressing the ``#`` key while several lines of Python code are selected
~~~
. In Python code, the `Editor > Block Commenting Style
<script:show_preferences_gui#prefname="gui.block-comment-style">`__ preference controls
the type of commenting that is used. The default is to use indented single ``#``
characters since this works better with some of Wing's other features.

**Brace Matching**

Wing highlights brace matches as you type, unless this is disabled from the `Editor >
Brace Matching > Brace Highlighting
<script:show_preferences_gui#prefname="edit.auto-brace-match">`__ preference. The ``Match
Braces`` item in the ``Source`` menu causes Wing to select all the code that is contained
in the nearest matching braces, as found from the current insertion point on the editor.
Repeated invocations of the command will traverse outward or forward in the file.

**Text Reformatting**

Code can be re-wrapped to the column configured in the preference `Editor > Line Wrapping
> Reformatting Wrap Column
<script:show_preferences_gui#prefname="edit.text-wrap-column">`__ with the ``Rewrap Text``
item in the ``Source`` menu. This will limit wrapping to a single logical line of code, so
it can be used to reformat function or method arguments or long list or tuple without
altering surrounding code.

~~~if WINGPRO:
**Bookmarks**

In Wing Pro, you can define and jump to marked locations in the editor with the
bookmarking commands in the ``Source`` menu, the editor's right-click context menu, and
the bookmark toolbar group.

In Python files, these bookmarks are defined relative to the named scope in the file so
they move around with the scope as the file is edited outside of Wing. Bookmarks can be
categorized and managed in the `Bookmarks <script:show-panel-bookmarks>`__ tool in the
``Tools`` menu.

See `Bookmarks <ref:edit/bookmarks>`__ for details.
~~~

