Chapter 05 · Editing and files编辑与文件編輯與檔案
Editing basics编辑基础編輯基礎
Line operations
| Action | Default shortcut |
|---|---|
| Duplicate current line | ⌘⇧D |
| Delete current line | ⌘⇧K |
| Move line up / down | ⌥↑ / ⌥↓ |
| Indent / unindent | ⌘] / ⌘[ |
| Toggle comment | ⌘/ |
| Uppercase / lowercase | ⌘⇧U / ⌘⇧L |
Toggle comment chooses the correct syntax for the current language — line comments where the language has them, block comments otherwise. With a selection, the operation applies to every touched line.
Indentation
The Tab key inserts spaces; the width is configurable. Indent and unindent operate on a block selection and keep the caret column stable.
Brackets and quotes
Typing an opening bracket or quote inserts the pair; typing the closing character over an existing one moves the caret instead of duplicating. Matching brackets are highlighted when the caret is adjacent to one.
Whitespace and wrapping
- Show whitespace renders spaces as
·and tabs as→. - Word wrap is a per-window toggle; during a comparison it applies to both panes to keep alignment.
Folding
Indentation-based blocks can be folded and unfolded from the editor gutter or with the fold commands. Folding is available on both rendering paths.
Navigation
- Go to line:
⌘L, then type the line number. - Zoom in / out:
⌘+/⌘-. - Full screen:
⌃⌘F. - Previous / next tab: from the window menu, or by clicking the tab bar.
Trailing whitespace
A command removes trailing whitespace across the selection or the whole document. There is no automatic “trim on save”; the operation is explicit.
行操作
| 操作 | 默认快捷键 |
|---|---|
| 复制当前行 | ⌘⇧D |
| 删除当前行 | ⌘⇧K |
| 上移 / 下移行 | ⌥↑ / ⌥↓ |
| 缩进 / 反缩进 | ⌘] / ⌘[ |
| 注释 / 取消注释 | ⌘/ |
| 转大写 / 转小写 | ⌘⇧U / ⌘⇧L |
注释切换会按当前语言选择正确语法:有行注释用行注释,否则用块注释。有选区时作用于涉及的每一行。
缩进
Tab 插入空格,宽度可配置。缩进与反缩进作用于块选区,并保持光标列位置稳定。
括号与引号
输入左括号或引号会自动补全;在已有右括号上输入右括号会移动光标而不是重复插入。光标紧邻括号时高亮匹配项。
空白与换行
- 显示空白字符:空格显示为
·,制表符显示为→。 - 自动换行是窗口级开关;比较状态下会同时作用于两栏以保持对齐。
折叠
基于缩进的代码块可从行号区或折叠命令折叠/展开,两条渲染路径均支持。
跳转
- 跳转行:
⌘L后输入行号。 - 放大 / 缩小:
⌘+/⌘-。 - 全屏:
⌃⌘F。 - 上一个 / 下一个标签:窗口菜单,或直接点击标签栏。
行尾空白
提供「去除行首尾空白」命令,作用于选区或整篇。没有「保存时自动清理」,这项操作始终由你显式触发。
行操作
| 操作 | 預設快速鍵 |
|---|---|
| 複製當前行 | ⌘⇧D |
| 刪除當前行 | ⌘⇧K |
| 上移 / 下移行 | ⌥↑ / ⌥↓ |
| 縮排 / 反縮排 | ⌘] / ⌘[ |
| 注釋 / 取消注釋 | ⌘/ |
| 轉大寫 / 轉小寫 | ⌘⇧U / ⌘⇧L |
注釋切換會按當前語言選擇正確語法:有行注釋用行注釋,否則用塊注釋。有選取範圍時作用於涉及的每一行。
縮排
Tab 插入空格,寬度可配置。縮排與反縮排作用於塊選取範圍,並保持游標列位置穩定。
括號與引號
輸入左括號或引號會自動補全;在已有右括號上輸入右括號會移動游標而不是重復插入。游標緊鄰括號時高亮匹配項。
空白與換行
- 顯示空白字元:空格顯示為
·,制表符顯示為→。 - 自動換行是視窗級開關;比較狀態下會同時作用於兩欄以保持對齊。
摺疊
基於縮排的程式碼塊可從行號區或摺疊命令摺疊/展開,兩條渲染路徑均支援。
跳轉
- 跳轉行:
⌘L後輸入行號。 - 放大 / 縮小:
⌘+/⌘-。 - 全屏:
⌃⌘F。 - 上一個 / 下一個標籤:視窗選單,或直接點擊標籤欄。
行尾空白
提供「去除行首尾空白」命令,作用於選取範圍或整篇。沒有「儲存時自動清理」,這項操作始終由你顯式觸發。