One of the features I miss in Visual Studio is the ability to hop over closing parenthesis, brackets, single-quotes and double-quotes with tab
Does anyone know of a script to do such a thing?

Pseudo Code:

If character to the right of cursor == ')' or '}' or '\'' or '"'
    Move cursor over one space.

1 Answer 1


This answer depends on the bind-key.el file in Wiegley's use-package.

Probably a cleaner way to do this, but this should work for your purposes. You say you want the cursor to "hop" over the delimiters, but also say the cursor should move over one space. I assumed you meant 2 spaces. Remove the first (forward-char 1).

(defun special-tab ()
 "Wrapper for tab key invocation. 

  If point is just before a close delimiter, skip forward until 
  there is no closed delimiter in front of point. Otherwise, invoke 
  normal tab command for current mode.

  Must be bound to <tab> using bind-key* macro from bind-key package.

  Note, this function will not be called if `override-global-mode' is
  turned off."
  (defun next-char-delims (delims)
    (let ((char (and (not (equal (point) (point-max)))
                     (string (char-after (point))))))
      (when char (member char delims))))
  (let ((open '("'" "\"" ")" "]")))
    (if (next-char-delims open)
        (progn (forward-char 1)
               (while (next-char-delims open)
                 (forward-char 1)))
      (call-interactively (key-binding (kbd "TAB"))))))

(if (macrop 'bind-key*)        
    (bind-key* (kbd "<tab>") 'special-tab)
  (user-error "Must have bind-key from use-package.el to use special-tab function."))
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Dan
    Commented Jan 31, 2018 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.