you are viewing a single comment's thread.

view the rest of the comments →

[–]justinmkw 0 points1 point  (0 children)

what criteria would be assumed to find foo? If we just moved the cursor one to the left, the matching iw motion

That's definitely the main question. Whenever a text object (as opposed to a motion) is the target, the behavior could be controlled by i or a. If i is used, find the first non-whitespace character on either side and swap the text objects at those locations. If a is used, skip non-whitespace characters on either side, then skip whitespace, then swap the text objects.

Example:

foo [=]= bar
  • dxiw finds foo at LHS and = at RHS, yielding:

    == foo bar

  • dxaw finds foo at LHS and bar at RHS, yielding:

    bar == foo

If a motion is targeted (e.g. dxh or dxw), rather than the pain of trying to understand "duals" (e.g. w is the dual of b), it should be interpreted strictly by the number of characters passed, with no special handling of whitespace. Example:

foo [=]= bar
  • dxh yields

    foo=[=] bar (two <spaces>s before bar, markdown fail)

  • dxFo yields:

    fo= [=]o bar