Tutorial: Other Editor Features

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

Goto-Line

Navigate quickly to a numbered source line with the GotoLine item in the
Edit menu, or with the key binding displayed there. In some keyboard
personalities, the
line number is typed into the data entry area that appears at the bottom of
the window. Press Enter to complete the action.

In Wing Pro and Wing Personal, line numbers can be shown in the editor with the ShowLineNumbers item
in the Edit menu.

Selecting Code

Wing supports character, line, and block mode selection from the SelectionMode item in the Edit menu.

In Wing Pro and Wing Personal, multiple selections can be made at the same time with the Edit>MultipleSelections menu item, multiple selections toolbar item, and by pressing
Ctrl+Alt (or Command+Alt on the Mac) while making a selection with the mouse.
Once there are multiple selections, edits made will be applied in the same
way to all the selections concurrently.

In Python code, the Select sub-menu in the Edit menu can be used to
easily select and traverse logical blocks of code. The SelectMore and
SelectLess 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. If you
plan to use these and your selected User Interface > Keyboard > Keyboard Personality preference does not support
them, then you will want to define key bindings for them using the User Interface >
Keyboard > Custom
Key Bindings
preference. The command names are select-x, next-x, and
previous-x where x is either statement, block, or scope.

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 LineEditing sub-menu of the Source
menu. If your keyboard personality does not support them, then you can define
key bindings for those you are interested in using. 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.

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-EnterInvocationArg``sauto-editingoperationisenabled.Typeanytextyouwantineachfieldwithinthesnippetandpress``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.

Lines of code can be commented out or un-commented quickly from the
Source menu
or, in Wing Pro, by pressing the # key while several
lines of Python code are selected
. In Python code, the Block Commenting
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 matching as you type unless disabled from the Auto
Brace Match preference. The MatchBraces item in the Source menu
causes Wing to select all the code that is contained in the nearest matching
braces 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 configured Reformatting Wrap Column with the
JustifyRewrap item in the Source menu. This will limit wrapping to a
single logical line of code, so it can be used to reformat an argument list
or long list or tuple without altering surrounding code.

Bookmarks

Wing Pro's Bookmarks tool in the Tools menu,
and the bookmarking commands in the Source menu and editor context menu,
can be used to define and jump to marked locations in the editor. 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. See Bookmarks for
details.