跳转到 emacs 中的第一个非空白字符

Ale*_*ird 62 emacs whitespace

我正在寻找相当于 vi 的 emacs ^

如何将光标移动到一行中的第一个非空白字符?

Sea*_*ean 99

命令是back-to-indentation,默认绑定到M-m


小智 14

这是我从之前的 Stack Overflow 问题中学到的

(defun smart-beginning-of-line ()
  "Move point to first non-whitespace character or beginning-of-line.

Move point to the first non-whitespace character on this line.
If point was already at that position, move point to beginning of line."
  (interactive)
  (let ((oldpos (point)))
    (back-to-indentation)
    (and (= oldpos (point))
         (beginning-of-line))))
(global-set-key [home] 'smart-beginning-of-line)
(global-set-key "\C-a" 'smart-beginning-of-line)
Run Code Online (Sandbox Code Playgroud)