On Thursday, July 31, 2014 6:21:25 AM UTC-5, Edward K. Ream wrote:

> So this is good.  Getting these points exactly right right at the start 
is a good strategy for the following reasons:

> 1. They are crucial to a good user experience.
> 2. They will make working on the vim commands much less confusing.
> 3. They will demonstrate that the vim code can be integrated seamlessly 
into Leo's core, especially into the very complex code in > leoKeys.py 
(k.masterKeyHandler, k.masterCommandHandler and their allies).
> 4. They will strongly affect the design of helper methods within 
leoKeys.py and corresponding methods within leoVim.py.

This strategy has been a spectacular success.  As of rev d9cca94...

- Vim mode code is now simply and correctly connected to code in leoKeys.py.
- The proper vim state is properly shown at all time.
- The parsing code now handles constructs such as:  dd, 2dd, d2j, 3d2j and 
many others.

Much work remains:

- Parsing is likely to be revised further.
- d2j and 3d2j don't work exactly as in vim.  Soon it will.
- The i,o,O,a and A commands do not support a leading repeat count.
- No support for dot yet.  It should be straightforward.
- The h and l motions can move past newlines, unlike in vim.  This will be 
corrected.
- Vim mode must show (probably in the status line) the command keys as the 
user types them.
  For example, it should show 2d2 while the user types the 3d2j command.

I believe I have grokked a very important principle underlying the real 
vim, one that I will emulation in Leo's vim mode.  The idea is that in a 
command like 3d2j, the code for d will remember the leading repeat count 
*and* the insertion point before parsing the last part of the command, in 
this case "2j".  For the dd command, only the leading repeat count matter, 
but for movement commands like "2j", the strategy is as follows:  The 
parser for "2j" **actually moves the cursor**.  When the command completes, 
a "callback" to the d command compares the saved insertion point I1 with 
the present insertion point, I2 and then does the following:

- If I2 is on the same line as I1, don't change I2, othewise:
- If I1 < I2, we move I2 to the end of the line (if it isn't already there).
- If I1 > I2, we move I2 to the beginning of the line (if it isn't already 
there).
-   Exception: the d command will not extend the selection if I2 is on the 
same line os 

This will make dj work *exactly* as in vim: it deletes *two* lines, not 
one.  Similarly for all other movements, like d0 or d$ or dgg etc.

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to leo-editor+unsubscr...@googlegroups.com.
To post to this group, send email to leo-editor@googlegroups.com.
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/d/optout.

Reply via email to