Skip to content

casouri/find-char

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Find-char

A taste of the f operator of vim in Emacs.

./screenshot.png

Usage

  • Bind find-char to some key, say M-j.
  • Hit M-j and the character that you want to move to.
  • Press “ ’ ” to move forward, ; to move back.
  • Press any other key to finish

Extra:

  • You can combine numerical arguments with find-char, e.g., C-3 find-char, C-- C-4 find-char.
  • Press the character you are searching for to move forward, Press the reversed case of it to move backward. E.g,
    • M-j f, f forward, F backward
    • M-j F, F forward, f backward.
  • Case-sensitivity is controlled by case-fold-search.

Note: find-char doesn’t search the whole buffer since it’s just for short distance jumping.

Convenient commands

keyCommand
C-dQuick delete region (like df)
C-wQuick copy region
C-vToggle highlight of region

The mark is set to where you began jumping, you can do whatever you want with that.

Customization

VariableDescription
find-char-search-rangefind-char doesn’t search the whole buffer, but only a portion around point
find-char-stop-atwhere does find-char stop, can be 'beginning or 'end
case-fold-searchcontrols case-sensitivity when searching

You can customize find-char-transient-map, the map that activates during jumping. Default value is:

(defvar find-char-transient-map (let ((map (make-sparse-keymap)))
                                  (define-key map (kbd "'") #'find-char-forward)
                                  (define-key map (kbd ";") #'find-char-backward)
                                  (define-key map (kbd "C-'") #'find-char-forward)
                                  (define-key map (kbd "C-;") #'find-char-backward)
                                  (define-key map (kbd "C-d") #'find-char-quick-delete)
                                  (define-key map (kbd "C-v") #'find-char-toggle-region-highlight)
                                  (define-key map (kbd "C-w") #'find-char-copy-region)
                                  map)
  "Transient map for find-char.")

Plus the dynamically binded search char and reverse case of search char mentioned in “usage” section above.

Comparison with jump-char

I’ve been using jump-char for quite a while and it is great. Here is the differences between jump-char and find-char:

  • jump-char uses isearch, which brings advantages and disadvantages. It is more like searching than a jumping. E.g., there is no trivial way to jump with region activated AFAIK .
  • jump-char integrates ace-jump while find-char doesn’t.

About

A taste of the `f` operator of vim in Emacs.

Resources

Stars

Watchers

Forks

Packages

No packages published