Emacs Evil mode: how to create a new text object to select words with any non-space characters?

后端 未结 3 721
小蘑菇
小蘑菇 2021-02-08 18:58

I am trying to create a new text object in Evil. For example, the text object iw will only select subsets of strings containing hyphens. I want the new text object to m

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-08 19:24

    The correct regexp is " \|.?$". The following code implements a new text object matching any nonspace character.

    (evil-define-text-object evil-inner-space (count &optional beg end type)
      "Select inner space."
      :extend-selection nil
      (evil-regexp-range count beg end type "[ \n]" " \\|.?$" t))
    

提交回复
热议问题