Frank Fischer avatar Frank Fischer committed 84a6e51

fix cw and cW not including following whitespace, addresses #28

Comments (0)

Files changed (1)

     (t
      ;; deal with cw and cW
      (when (and vim:current-motion
-                (not (member (char-after) '(?  ?\r ?\n ?\t)))
-		(eobp))
-       (cond
-        ((eq vim:current-motion 'vim:motion-fwd-word)
-         (let* ((cnt (* (or vim:current-cmd-count 1)
-                        (or vim:current-motion-count 1)))
-                (pos
-                (save-excursion
-                  (dotimes (i cnt)
-                    (while
-                        (not
-                         (or (and (looking-at (concat "[^ \t\r\n]"
-                                                      "[ \t\r\n]")))
-                             (and (looking-at (concat "[" vim:word "]"
-                                                      "[^ \t\r\n" vim:word "]")))
-                             (and (looking-at (concat "[^ \t\r\n" vim:word "]"
-                                                      "[" vim:word "]")))))
-                      (forward-char))
-                    (when (< i (1- cnt))
-                      (forward-char)))
-                  (point))))
-           (setq motion (vim:make-motion :begin (point) :end pos :type 'inclusive))))
-        
-        ((eq vim:current-motion 'vim:motion-fwd-WORD)
-         (let* ((cnt (* (or vim:current-cmd-count 1)
-                        (or vim:current-motion-count 1)))
-                (pos
-                 (save-excursion
-                   (dotimes (i cnt)
-                     (while
-                         (not (looking-at (concat "[^ \t\r\n]"
-                                                  "[ \t\r\n]")))
-                       (forward-char))
-                     (when (< i (1- cnt))
-                       (forward-char)))
-                   (point))))
-           (setq motion (vim:make-motion :begin (point) :end pos :type 'inclusive))))))
+                (not (member (char-after) '(?  ?\r ?\n ?\t))))
+       (let ((cnt (* (or vim:current-cmd-count 1)
+		     (or vim:current-motion-count 1))))
+	 (case vim:current-motion
+	   (vim:motion-fwd-word
+	    (setq motion (vim:motion-fwd-word-end :count cnt)))
+	   (vim:motion-fwd-WORD
+	    (setq motion (vim:motion-fwd-WORD-end :count cnt))))))
         
      (vim:cmd-delete :motion motion :register register)
      (if (eolp)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.