There are a number of other editor features that are worth knowing about:
Navigate quickly to a numbered source line with the Goto Line 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.
Line numbers can be shown in the editor with the Show Line Numbers item in the Edit menu.
Wing supports character, line, and block mode selection from the Selection Mode item in the Edit menu.
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-Down will select more code in logical units. Press Ctrl-Up 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.
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 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.
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``s 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.
For details see Code Snippets.
Lines of code can be commented out or un-commented quickly from the Source menu or, as noted earlier, 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.
Wing highlights brace matching as you type unless disabled from the 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 found from the current insertion point on the editor. Repeated invocations of the command will traverse outward or forward in the file.
Code can be re-wrapped to the configured Reformatting Wrap Column with the Justify Rewrap 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.
The 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.
|« 1.12. Tutorial: Indentation Features||Table of Contents||1.14. Tutorial: Unit Testing »|