Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I will answer this question myself.</p> <p>I could not figure out an "orthodoxy" way to solve the problem and I came up with a hack.</p> <p>The function that is bound to in viper insert mode (viper-del-backward-char-in-insert) is adviced to check whether cursor is currently in a matched pair, if so, the character after the cursor is deleted before the actual function is called. This also takes into account possible problem caused by prefix character (backslash).</p> <p>Just copy the code below into your .emacs file after viper-mode or vimpulse is loaded.</p> <pre><code>(defun not-escaped (escape-char) "Character immediately before cursor is not prefixed by escape-char" (let ((count 0)) (save-excursion (if (char-before) (backward-char)) (while (and (char-before) (= (char-before) escape-char)) (setq count (+ count 1)) (backward-char)) (if (= 0 (% count 2)) t nil)))) (defun in-matched-empty-pair (pair-list) "tell if cursor is in an empty pair in pair-list" (let ((next-char (char-after)) (prev-char (char-before)) (matched nil) (pair) (pair-left) (pair-right)) (if (and next-char prev-char) (while (and (setq pair (pop pair-list)) (not matched)) (setq pair-left (pop pair) pair-right (pop pair)) (if (= next-char pair-right) (if (and (= prev-char pair-left) (not-escaped ?\\)) (setq matched t))))) (if matched t nil))) (defvar viper-workaround-pairs '( (?\" ?\") (?\' ?\') (?\` ?\`) (?\( ?\)) (?\[ ?\]) (?\{ ?\}) )) ;; Workaround for integration problem with autopair (defadvice viper-del-backward-char-in-insert (before viper-auto-delete-pair-backward()) (if (in-matched-empty-pair viper-workaround-pairs) (delete-char 1))) ;; Activate advice (ad-activate 'viper-del-backward-char-in-insert) </code></pre> <p>This is a hack but it is probably the best I could do now.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload