[spacemacs] EMACS里有类似C-a自增的功能么?

有:Org mode 里有个 org-increase-number-at-point 命令有这样的功能,Org 又是 Emacs 内置的。

也可以尝试按需要自己实现一个,各种细节(数字范围的判断、指定增加的量的方式、自增之后光标的位置)完全由自己控制

(defun increase-number-at-point (prefix)
  "增加光标下数字以 prefix argument (默认为 1)."
  (interactive "p")
  (when (thing-at-point-looking-at "[0-9]+")
    (let* ((beg (match-beginning 0))
           (end (match-end 0))
           (number (string-to-number (buffer-substring beg end)))
           (pos (point)))
      (delete-region beg end)
      (goto-char beg)
      (insert (number-to-string (+ number prefix)))
      (goto-char pos))))

多谢山人,最近还在看你的视频呢,org-mode的

刚用emacs几天,短期内不想写elisp,先熟悉功能,再研究elisp,我怕我碰到语言就上瘾,反而对emacs本身的功能不太上心了。

也可以参考这个: Increment and Decrement Integer at Point | Emacs Redux

你要的 c-a 自增的功能, Emacs wiki 里面就有: EmacsWiki: Increment Number

不好意思,我没注意到,可能是我wiki读得太不仔细了

我的 + 号键绑定的是 evil-numbers/inc-at-pt 下面是使用宏来自增的方式:

一共是 13 个 key stroke:

使用 multiple-cursors: mc/insert-numbers 我的 mc/insert-numbers 绑定的快捷键是 C-x m i

操作方式: C-2 C-0 C-1 C-5 C-x m i 一共是 8 个 key stroke:

Use tiny package: Only one Key stroke!!!

http://oremacs.com/2014/12/26/the-little-package-that-could/

2 个赞

最后一个很给力的样子,我试一下!!!

自带可以实现自增功能,按照 register number 给出的几个按键就可以用在录宏操作中,大致是录宏前C-u 2016 C-x r n r设置初值,然后录宏时先C-u 1 C-x r + r 设置增量为1,后C-x r i r插入寄存器r的值。楼上已经给出了好几种优雅的方式,而宏操作按键复杂不得已才会用下。

歪一下楼 :smile:

⋊> seq -f 'wow, %g is a new year!' 2015 2020 # 正序
wow, 2015 is a new year!
wow, 2016 is a new year!
wow, 2017 is a new year!
wow, 2018 is a new year!
wow, 2019 is a new year!
wow, 2020 is a new year!

⋊> seq -f 'wow, %g is a new year!' 2020 2015 # 倒序
wow, 2020 is a new year!
wow, 2019 is a new year!
wow, 2018 is a new year!
wow, 2017 is a new year!
wow, 2016 is a new year!
wow, 2015 is a new year!
~ $ for i in {2015..2020}; do echo "wow, $i is a new year\!"; done
wow, 2015 is a new year!
wow, 2016 is a new year!
wow, 2017 is a new year!
wow, 2018 is a new year!
wow, 2019 is a new year!
wow, 2020 is a new year!
~ $ for i in {2020..2015}; do echo "wow, $i is a new year\!"; done
wow, 2020 is a new year!
wow, 2019 is a new year!
wow, 2018 is a new year!
wow, 2017 is a new year!
wow, 2016 is a new year!
wow, 2015 is a new year!

山人,你的录屏gif软件是什么,看着挺好用的。还有编程类视频里会出现的按键顺序提示,那个软件是什么?求分享。

gif 软件是 LICEcap Cockos Incorporated | LICEcap

键盘录制是: GitHub - zilongshanren/keycastr: KeyCastr, an open-source keystroke visualizer

记得用我 fork 的仓库的分支: https://github.com/zilongshanren/keycastr/tree/my-hack

自己从源码构建即可。

注: 这两个工具,我都是在 Mac 上面使用的。

1 个赞

歪一下楼。 能推荐一下linux下gif录制方法吗:yum:


请移步这里继续讨论, 原因参考楼下。

请开一个新的主题来讨论不相干的、新的话题。参考: 常见问题解答 - Emacs China

  • 不要在中途改变主题。

emacs 自带此功能 C-x r N 使用方法 选中 2015所在区域然后 C-u2015 C-x r N