Giter VIP home page Giter VIP logo

vimword's Introduction

VimWord

Word VBA add-in permitting you to use a subset of normal-mode editing commands in Word.

Installation

  • Exit Word
  • Run Install VimWord.bat
    • Alternatively put VimWord.dotm in ...\Word\Startup or load through Add-Ins | Manage: Word Add-ins.
  • Map a key to VimDoCommand (I use Ctrl+; because it's easy to type on my keyboard.)

Mapping a key

  • Right-click the Ribbon and select Customize the Ribbon....
  • At the bottom of the Word Options dialog that appears, you should see a Keyboard Shortcuts: Customize button. Press it.
  • In the dialog box that appears, under Categories, select Macros.
  • Under Macros, select VimDoCommand.
  • Click in the box under Press new shortcut key:.
  • Press the key you want to map
  • In the bottom-left, click Assign.
  • In the bottom-right, click Close.
  • Back in the Word Options dialog, press OK.

Usage

  • Hit the key you mapped, then enter a normal-mode command (e.g., diw). Currently, the supported operators are d (delete), y (copy), and v (select). c (change) is also supported but doesn't do anything other than select the text.

License

Copyright (c) 2018--2020 Christopher White. Portions Copyright (c) 2020 D3 Engineering, LLC.

Licensed CC-BY-NC-SA 4.0 or, at your option, any later version. For the avoidance of doubt, merely using VimWord at work does not automatically make the use commercial.

vimword's People

Contributors

cxw42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vimword's Issues

If a motion doesn't move the cursor, move and retry

E.g.:

  • At the end of a word, e is a no-op
  • Right before a :, t: is a no-op (and likewise for any single character)

In those cases, move the cursor one space in the correct direction and try the motion again. This is a symptom of the fact that Vi positions the cursor on characters, and Word positions the cursor between characters.

W grabs fields after the word

E.g., a paragraph of word<NBSP><FIELD>^p: vW at the start of the paragraph selects the field, even though it should have stopped after the NBSP. This is because the line

proczone.MoveEndWhile CSET_WS, wdForward

grabs the field even though it shouldn't. I believe this is a Word bug/quirk --- I've seen similar things before.

Support mode transitions and dialog re-opening

The dialog opens on a hotkey, similar to Esc entering normal mode. Add support for staying in normal mode where appropriate, i.e., reopening the dialog ready to accept a new command after the previous command has finished. Similarly, consider the dialog-closed state to be a hybrid of insert, replace, and visual modes. That way you will be able to use Word almost as Vim - i c r &c. to close the dialog and insert text, and <hotkey> to re-enter normal mode.

Range.Move{Start,End} lock in the presence of comments when not in Normal view

Repro (Word 2013):

  • Open VimWord.dotm. (Note: the file begins with VimWord.dotm).
  • View | Print Layout
  • Stick the cursor in the middle of VimWord and add a comment. Type a few chars in the comment.
  • With the cursor still in the middle of VimWord, run VimDoCommand and enter viw.

Screenshot of the setup:
image

Expected: The text VimWord is selected

Observed: Word locks hard.

Analysis: The vmIWord case in mVimWord says:

proczone.Expand wdWord
coll = False
If count > 1 Then proczone.MoveEnd wdWord, count - 1
proczone.MoveEndWhile CSET_WS, wdBackward

When in Print Layout mode, the proczone.Expand grabs the comment marker but doesn't realize it. Then, the MoveEndWhile locks. I think Word is trying to move backwards past the comment marker, but can't because the comment marker is invisible.

The same code works fine in Draft (Normal) mode. MoveEnd wdWord stops before the comment marker, and MoveEndWhile is a no-op.

Additional text objects

  • ()-delimited text
  • [] "
  • {} "

Plus:

  • Table
  • Revision
  • Comment scope
  • Whole comment, minus the trailing marker (if StoryType = wdCommentsStory)
  • Field
  • Section delimited by blank lines (empty Word paragraphs) (in 9e9b3aa without count support)
  • Section delimited by outline level (e.g., ao<n> to select everything between adjacent headers of level <n>)
  • Section delimited on each end by the nearest of a blank line or a paragraph with an outline level <> Body Text.

(Not in Vim ;) )

In tTfF, map ASCII to extended set

Currently, tf" doesn't jump to a smart quote. Expand that and similar definitions.

  • ": also include curly open/close double quotes (and maybe other quotation marks, for internationalization?
  • ': ditto, but single quotes
  • -: all Unicode dashes and hyphens

Mac installer

  • Write one!
  • Double-check that there are no Windows path assumptions in the code

When selecting sentences, skip over common abbreviations such as e.g.

Currently vas stops at the first period, which is not the end of the English sentence if that is a period in e.g.. Keep a table of common abbreviations and expand the as and is text objects past those abbreviations to a period that is not in an abbreviation or to the end of the paragraph.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.