Table Of Contents

Previous topic

WriteError

Next topic

EditraCommander

This Page

phoenix_title ed_vim

Vim emulation class and helper methods to implement vim emulation in Editra’s text buffer.


class_hierarchy Inheritance Diagram

Inheritance diagram for module ed_vim

Inheritance diagram of ed_vim


function_summary Functions Summary

Arrows Basic arrow movement in vim.
Change Implementations for c/d/y commands. Also for <> (indentation) commands.
Column Goto specified column, with 1 being the default.
Delete Simple delete/change commands that are implemented in terms of more
DoHandle Call handler for command
Dot Repeat last insert command
Ex Command for opening the command bar.
FindChar Find character on current line and move the caret to it (if found).
FindIdent Find the next/previous occurance of identifier under caret
GetHandler Finds the function that handles command cmd
GetMotion Move cursor of editor to a new location according to motion
InsertMode Handler for basic commands that put vim in INSERT mode
Join Join lines command.
Jump Jump to a bookmark specified by a character label.
Line Motions to beginning/end of a line.
Mark Create a bookmark and associate it with a character label.
minmax  
NavExtra Commands for navigating visible lines or scrolling.
Para Paragraph motions.
Parse Parses a command and (if applicable) executes it on an editor
Put Paste commands.
Reg Switch register (clipboard) command
RegexSearch Incremental search commands.
RepeatFindChar Repeat the last FindChar motion.
ReplaceChar Replace character under caret with another one.
ReplaceMode Enter into Replace Mode.
SplitRepeat Split the command strings into a pair (repeat, rest)
Tilde Invert case of character(s) under caret. Also operates on selection.
Undo Undo/Redo commands.
vim_parser Decorator for function that handle vim commands
VisualMode Enter visual mode
Words Word motions.

class_summary Classes Summary

EditraCommander Proxy object that sends commands to the editor

Functions



Arrows(editor, repeat, cmd)

Basic arrow movement in vim.

See also

vim_parser



Change(editor, repeat, cmd)

Implementations for c/d/y commands. Also for <> (indentation) commands.

Todo

This method is quite larger than other methods in this module, needs to be simplified.

See also

vim_parser



Column(editor, repeat, cmd)

Goto specified column, with 1 being the default.

See also

vim_parser



Delete(editor, repeat, cmd)

Simple delete/change commands that are implemented in terms of more advanced c/d commands.

See also

vim_parser



DoHandle(handler, cmd, editor)

Call handler for command It’s necessary to use this function instead of calling the handler directly.



Dot(editor, repeat, cmd)

Repeat last insert command

See also

vim_parser



Ex(editor, repeat, cmd)

Command for opening the command bar.

See also

vim_parser



FindChar(editor, repeat, cmd)

Find character on current line and move the caret to it (if found).

See also

vim_parser



FindIdent(editor, repeat, cmd)

Find the next/previous occurance of identifier under caret

Note

There’s a sublte difference from vim: if some text is already selected, it’s used as the search term instead of the identifier under the caret

See also

vim_parser



GetHandler(cmd, h_list=None)

Finds the function that handles command cmd

Parameters:
  • cmd – the command string
  • h_list – alternative list of handler functions


GetMotion(editor, cmd)

Move cursor of editor to a new location according to motion Returns a method that handles this motion, or None



InsertMode(editor, repeat, cmd)

Handler for basic commands that put vim in INSERT mode



Join(editor, repeat, cmd)

Join lines command.

See also

vim_parser



Jump(editor, repeat, cmd)

Jump to a bookmark specified by a character label.

See also

vim_parser



Line(editor, repeat, cmd)

Motions to beginning/end of a line.

See also

vim_parser



Mark(editor, repeat, cmd)

Create a bookmark and associate it with a character label.

See also

vim_parser



minmax(a, b)


NavExtra(editor, repeat, cmd)

Commands for navigating visible lines or scrolling.

See also

vim_parser



Para(editor, repeat, cmd)

Paragraph motions.

See also

vim_parser



Parse(cmd, editor)

Parses a command and (if applicable) executes it on an editor

Parameters:
  • cmd – the command string
  • editor – a proxy object used to issue commands to the editor
Returns:

boolean as a signal to the caller as to whether it should clear its command buffer. i.e. True if command is handled or invalid False if we need more input before we can execute the command



Put(editor, repeat, cmd)

Paste commands.

See also

vim_parser



Reg(editor, repeat, cmd)

Switch register (clipboard) command

Note

This command is stand-alone, not prefix to other commands.

See also

vim_parser



RegexSearch(editor, repeat, cmd)

Incremental search commands.

Note

Uses the find bar in editra.

See also

vim_parser



RepeatFindChar(editor, repeat, cmd)

Repeat the last FindChar motion.

See also

vim_parser



ReplaceChar(editor, repeat, cmd)

Replace character under caret with another one.

Note

Does not enter into Insert mode.

See also

vim_parser



ReplaceMode(editor, repeat, cmd)

Enter into Replace Mode.

See also

vim_parser



SplitRepeat(cmd)

Split the command strings into a pair (repeat, rest)

>>>SplitRepeat( ‘3ab’ ) (3, ‘ab’) >>>SplitRepeat( ‘13ab’ ) (13, ‘ab’) >>>SplitRepeat( ‘abc’ ) (None, ‘abc’) >>>SplitRepeat( ‘ab2’ ) (None, ‘ab2’) >>>SplitRepeat( ‘0’ ) (None, ‘0’) >>>SplitRepeat( ‘0ab’ ) (None, ‘0ab’) >>>SplitRepeat(‘8’) (8, ‘’)



Tilde(editor, repeat, cmd)

Invert case of character(s) under caret. Also operates on selection.

See also

vim_parser



Undo(editor, repeat, cmd)

Undo/Redo commands.

Note

unlike vim, U is used for redo.

See also

vim_parser



vim_parser(start_chars, generic_repeat=True, is_motion=False)

Decorator for function that handle vim commands

Command Handling functions must follow the signature:

function( editor, repeat, cmd )

These functions should never be called directly, but instead be called through the GetHandler and DoHandle functions.

The handler functions should always decorate themselves with this decorator.

The purpose of this decorator is to indicate:
  • What is the first char of commands that the handler can handle
    • So that GetHandler can find the correct handler for a vim command
  • Whether it’s a motion
    • Some commands operate on motions
  • How to handle the repeat parameter
    • For most command, no repeat is the same as 1 repeat, but for some commands, this is not the case


VisualMode(editor, repeat, cmd)

Enter visual mode

See also

vim_parser



Words(editor, repeat, cmd)

Word motions.

Note

[] is based on what scintilla calls “word parts”, these motions are not in vim

See also

vim_parser