1. Frank Fischer
  2. evil
Issue #204 resolved

Repeating an edit in which tab-completion was used

Anonymous created an issue

Here's an example text

  ... the measure is aggregated across subjects.  ... the effect of the manipulation is expected to be the same in all subjects. 

I wanted to replace "subjects" by "participants". I moved to cursor to the beginning of the first "subjects" and did cw an typed part<tab> which completed to "participants". Then I moved the cursor to the second "subjects" and pressen . to repeat the edit. This time "part" was expanded to "particular" because the expansion mechanism that I'm using is context-sensitive. My expectation was of course that . would result in the exact same substitution as before. I'm not 100% sure if this should be considered a bug or a feature but my impression is that it breaks the semantics of . but you may disagree.

Comments (4)

  1. Frank Fischer repo owner

    The default behavior for recording commands for repetetion is logging and repeating the keystrokes. Unfortunately this is usually not what you want with tab-completion. Fortunately evil can be configured to repeat by recording buffer changes, but depending on the completion package you use further work may be required (e.g., the "auto-complete" package can be used with evil and works correctly).

    In order to use the change-based repeat recording you must find out which function is being called for completion (usually C-h k TAB should do the job). If you're lucky all you have to do is then

    (evil-declare-change-repeat 'your-function-name)
    

    This marks the function to be recorded by change, not by keystroke. Evil already marks dabbrev-expand and hippie-expand this way (see evil-integration.el).

    I hope this helps.

  2. Titus von der Malsburg

    Great! I'm using hippie-expand but with a wrapper that triggers hippie-expand only in some circumstances and inserts a \t otherwise. When I marked my wrapper as change-repeat it worked as expected. Thank you, Frank!

  3. Log in to comment