Which editors out of Emacs, Vim and JEdit support multiple simultaneous text insertion points?

后端 未结 10 2150
心在旅途
心在旅途 2021-02-12 12:06

Background: JEdit (and some other text editors as well) support a feature called Multiple simultaneous text insertion points. (at least that\'s what I\'m callin

10条回答
  •  执笔经年
    2021-02-12 12:49

    It seemed simple to do a basic version of this in Emacs lisp. This is for when you just want two places to insert text in parallel:

    (defun cjw-multi-insert (text)
      "insert text at both point and mark"
      (interactive "sText:")
      (insert-before-markers text)
      (save-excursion
        (exchange-point-and-mark)
        (insert-before-markers text)))
    

    When you run it, it prompts for text and inserts it at both point (current position) and mark. You can set the mark with C-SPC. This could be easily extended for N different positions. A function like set-insert-point would record current position (stored as an Emacs marker) into a list and then when you run the multi-insert command, it just iterates through the list adding text at each.

    I'm not sure about what would a simple way to handle a more general "multi-editing" feature.

提交回复
热议问题