macOS 具有类似 Emacs 的文本编辑快捷方式,但略有一些区别。以下是一些常用的快捷键组合。苹果官方文档提供了更详细的描述,可以作为本文的拓展。

👉 在 playground 中尝试快捷键

系统版本: macOS 11.6.1

Key Name Symbol
Command (or Cmd)
Option (or Alt)
Shift
Control (or Ctrl)

移动光标

  • ⌃ + F: Move forward 1 character.
  • ⌃ + B: Move backward 1 character.
  • ⌃ + P: Move to previous line(upward).
  • ⌃ + N: Move to next line(downward).

  • ⌃ + A: Move to the beginning of paragraph.
  • ⌃ + E: Move to the end of paragraph.

  • ⌘ + Left: Move to the beginning of line.
  • ⌘ + Right: Move to the end of line.
  • ⌘ + Up: Move to the beginning of document.
  • ⌘ + Down: Move to the end of document.

  • ⌥ + Left: Move to previous word.
  • ⌥ + Right: Move to next word.

删除或粘贴

  • ⌃ + D: Delete forward.
  • ⌃ + H: Delete backward.

  • ⌥ + Delete: Delete 1 word left of cursor.

  • ⌃ + K: Delete text from right of cursor to the line end.
  • ⌘ + Delete: Delete text from left of cursor to the line beginning.
  • ⌃ + Y: Paste text which deleted by ⌃ + K or ⌘ + Delete.

选择与交换

  • ⇧ + ⌘ + Left: Select text from cursor to the beginning of the line.
  • ⇧ + ⌘ + Right: Select text from cursor to the end of the line.
  • ⇧ + ⌥ + Left: Select 1 word left of cursor, this shortcuts can use more than 1 time.
  • ⇧ + ⌥ + Right: Select 1 word right of cursor, this shortcuts can use more than 1 time.
  • ⇧ + Left: Select 1 character left of cursor, this shortcuts can use more than 1 time.
  • ⇧ + Right: Select 1 character right of cursor, this shortcuts can use more than 1 time.

  • ⌃ + T: Swap 1 character between cursor, e.g. ie -> ei.

Playground

你可以在下面的文本框尝试这些快捷键组合,所有的改动可以在刷新页面后还原。