diff --git a/VimWord.dotm b/VimWord.dotm index 31a8766..accdb80 100755 Binary files a/VimWord.dotm and b/VimWord.dotm differ diff --git a/frmGrabKeys.frm b/frmGrabKeys.frm index ae58556..7752551 100755 --- a/frmGrabKeys.frm +++ b/frmGrabKeys.frm @@ -17,6 +17,7 @@ Attribute VB_Exposed = False ' Copyright (c) 2018 Chris White. All rights reserved. ' 2018-04-06 chrisw Initial version ' 2018-04-20 chrisw Major expansion/rewrite +' 2018-04-24 chrisw Change "s" to "v" (visual selection) Option Explicit Option Base 0 @@ -121,6 +122,8 @@ Public Enum VimOperator voChange ' c voDelete ' d voYank ' y + voSelect ' v Select . + 'voSwitchCase ' ~/g~ unimpl ' TODO Maybe a custom titlecase on g~? 'voLowercase ' gu unimpl @@ -136,8 +139,6 @@ Public Enum VimOperator 'voDefineFold ' zf No plans to implement this. 'voCallFunc ' g@ No plans to implement this. - ' Custom (not in Vim) - voSelect ' s Select . Mostly for use as a debugging aid. End Enum 'VimOperator 'Public Enum VimForce ' adverb - No plans to implement this @@ -286,7 +287,7 @@ Private Sub UserForm_Initialize() PC_INTRANS = 2 PAT_TRANS = _ - "([cdys])?([1-9][0-9]*)?([ai]([wWsp])|[fFtT](.)|[hjklGwebWEB\)\(\}\{])" + "([cdyv])?([1-9][0-9]*)?([ai]([wWsp])|[fFtT](.)|[hjklGwebWEB\)\(\}\{])" ' | | | | | RESM_TVERB = 0 '-^ | | | | RESM_COUNT2 = 1 ' --------' | | | @@ -379,7 +380,7 @@ Private Function ProcessHit_(hit As VBScript_RegExp_55.Match) As Boolean Case "c": VOperator = voChange Case "d": VOperator = voDelete Case "y": VOperator = voYank - Case "s": VOperator = voSelect + Case "v": VOperator = voSelect ' V, i.e., visual selection - just like in Vim. Case Else: Exit Function End Select diff --git a/frmGrabKeys.frx b/frmGrabKeys.frx index 62666a1..512e655 100755 Binary files a/frmGrabKeys.frx and b/frmGrabKeys.frx differ diff --git a/mVimWord.bas b/mVimWord.bas index 5127893..53f859d 100755 --- a/mVimWord.bas +++ b/mVimWord.bas @@ -5,12 +5,13 @@ Attribute VB_Name = "mVimWord" ' Thanks to https://glts.github.io/2013/04/28/vim-normal-mode-grammar.html ' 2018-04-06 chrisw Initial version ' 2018-04-20 chrisw Split vimRunCommand off VimDoCommand +' 2018-04-24 chrisw Added counts to tTfF Option Explicit Option Base 0 Public Sub VimDoCommand_About() - MsgBox "VimWord version 0.2.1, 2018-04-20. Copyright (c) 2018 Christopher White. " & _ + MsgBox "VimWord version 0.2.2, 2018-04-24. Copyright (c) 2018 Christopher White. " & _ "All Rights Reserved. Licensed CC-BY-NC-SA 4.0 (or later).", _ vbOKOnly + vbInformation, "About VimWord" End Sub 'VimDoCommand_About @@ -94,7 +95,7 @@ Public Sub vimRunCommand( _ Dim colldir As WdCollapseDirection colldir = wdCollapseEnd ' by default - Dim idx As Long + Dim idx As Long, result As Long Select Case motion Case vmLeft: proczone.MoveStart wdCharacter, -count: colldir = wdCollapseStart @@ -119,26 +120,48 @@ Public Sub vimRunCommand( _ Case vmCharForward: colldir = wdCollapseEnd - If proczone.MoveEndUntil(arg, wdForward) <> 0 Then + For idx = 1 To count + If proczone.MoveEndUntil(arg, wdForward) = 0 Then Exit For proczone.MoveEnd wdCharacter, 1 ' f => to and including - End If + Next idx Case vmCharBackward: colldir = wdCollapseStart - If proczone.MoveEndUntil(arg, wdBackward) <> 0 Then - proczone.MoveStart wdCharacter, -1 ' F => to and including - End If - - Case vmTilForward: proczone.MoveEndUntil arg, wdForward: colldir = wdCollapseEnd - Case vmTilBackward: proczone.MoveStartUntil arg, wdBackward: colldir = wdCollapseStart + For idx = 1 To count + If proczone.MoveStartUntil(arg, wdBackward) = 0 Then Exit For + proczone.MoveStart wdCharacter, -1 ' F => to and including + Next idx + + Case vmTilForward: + colldir = wdCollapseEnd + result = proczone.MoveEndUntil(arg, wdForward) + For idx = 2 To count + If result = 0 Then Exit For + proczone.MoveEnd wdCharacter, 1 + result = proczone.MoveEndUntil(arg, wdForward) + Next idx + + Case vmTilBackward: + colldir = wdCollapseStart + result = proczone.MoveStartUntil(arg, wdBackward) + For idx = 2 To count + If result = 0 Then Exit For + proczone.MoveStart wdCharacter, -1 + result = proczone.MoveStartUntil(arg, wdBackward) + Next idx - Case vmWordForward: proczone.MoveEnd wdWord, count: colldir = wdCollapseEnd + Case vmWordForward: + colldir = wdCollapseEnd + proczone.MoveEnd wdWord, count + Case vmEOWordForward: colldir = wdCollapseEnd proczone.MoveEnd wdWord, count proczone.MoveEndWhile CSET_WS, wdBackward - Case vmWordBackward: proczone.MoveStart wdWord, -count: colldir = wdCollapseStart + Case vmWordBackward: + colldir = wdCollapseStart + proczone.MoveStart wdWord, -count Case vmNonblankForward: colldir = wdCollapseEnd