Add q text-object for all quotes

This commit is contained in:
Henrik Lissner 2020-10-27 23:18:06 -04:00
parent f33b141650
commit 164b997cb0
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
3 changed files with 23 additions and 0 deletions

View file

@ -106,6 +106,8 @@ And these are text objects added by this module:
+ =g= The entire buffer
+ =i j k= by indentation (=k= includes one line above; =j= includes one line
above and below) (provided by ~evil-indent-plus~)
+ =q= For quotes (any kind)
+ =u= For URLs
+ =x= XML attributes (provided by ~exato~)
** Custom Ex Commands

View file

@ -42,3 +42,23 @@ This excludes the protocol and querystring."
(evil-range
beg (- end (if (evil-visual-state-p) 1 0))
type)))
;;;###autoload (autoload '+evil:inner-any-quote "editor/evil/autoload/textobjects" nil nil)
(evil-define-text-object +evil:inner-any-quote (count &optional beg end type)
"Select the closest inner quote."
(let ((evil-textobj-anyblock-blocks
'(("'" . "'")
("\"" . "\"")
("`" . "`")
("" . ""))))
(evil-textobj-anyblock-inner-block count beg end type)))
;;;###autoload (autoload '+evil:outer-any-quote "editor/evil/autoload/textobjects" nil nil)
(evil-define-text-object +evil:outer-any-quote (count &optional beg end type)
"Select the closest outer quote."
(let ((evil-textobj-anyblock-blocks
'(("'" . "'")
("\"" . "\"")
("`" . "`")
("" . ""))))
(evil-textobj-anyblock-a-block count beg end type)))

View file

@ -541,6 +541,7 @@ directives. By default, this only recognizes C directives.")
:textobj "i" #'evil-indent-plus-i-indent #'evil-indent-plus-a-indent
:textobj "j" #'evil-indent-plus-i-indent-up-down #'evil-indent-plus-a-indent-up-down
:textobj "k" #'evil-indent-plus-i-indent-up #'evil-indent-plus-a-indent-up
:textobj "q" #'+evil:inner-any-quote #'+evil:outer-any-quote
:textobj "u" #'+evil:inner-url-txtobj #'+evil:outer-url-txtobj
:textobj "x" #'evil-inner-xml-attr #'evil-outer-xml-attr