Stefan 的回答略有改进:
(defun jump-to-same-indent (direction)
(interactive "P")
(let ((start-indent (current-indentation)))
(while
(and (not (bobp))
(zerop (forward-line (or direction 1)))
(or (= (current-indentation) 0)
(> (current-indentation) start-indent)))))
(back-to-indentation))
Run Code Online (Sandbox Code Playgroud)
此函数采用前缀参数(例如,+1/-1)指定在搜索具有相同缩进的行时要移动的行数。它还跳过空行。最后一个可以使用类似的绑定键绑定向前和向后搜索M-{和M-}段落:
(global-set-key [?\C-{] #'(lambda () (interactive) (jump-to-same-indent -1)))
(global-set-key [?\C-}] 'jump-to-same-indent)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
528 次 |
| 最近记录: |