崇高文本2窗口中的多个游标

我已经在窗口中安装了升华文本2,我正在尝试使用多光标功能。

首先,我突出显示我正在寻找的选择(三行)。

然后我可以按 CTRL + D选择每个重复出现,或者按 ALT + F3选择所有。我的情况有四次重复。

现在我想移动三行中间的光标并添加一些信息,以添加到所有出现的地方。

一旦我点击选区,多个选区就消失了?是不是我做错了什么,我肯定是错的,但是由于文档非常薄弱,我无法找出原因?

145602 次浏览

Try using Ctrl-click on the multiple places you want the cursors. Ctrl-D is for multiple incremental finds.

In Sublime Text, after you select multiple regions of text, a click is considered a way to exit the multi-select mode. Move the cursor with the keyboard keys (arrows, Ctrl+arrows, etc.) instead, and you'll be fine

It's usually just easier to skip the mouse altogether--or it would be if Sublime didn't mess up multiselect when word wrapping. Here's the official documentation on using the keyboard and mouse for multiple selection. Since it's a bit spread out, I'll summarize it:

Where shortcuts are different in Sublime Text 3, I've made a note. For v3, I always test using the latest dev build; if you're using the beta build, your experience may be different.

If you lose your selection when switching tabs or windows (particularly on Linux), try using Ctrl + U to restore it.

Mouse

Windows/Linux

Building blocks:

  • Positive/negative:
    • Add to selection: Ctrl
    • Subtract from selection: Alt In early builds of v3, this didn't work for linear selection.
  • Selection type:
    • Linear selection: Left Click
    • Block selection: Middle Click or Shift + Right Click On Linux, middle click pastes instead by default.

Combine as you see fit. For example:

  • Add to selection: Ctrl + Left Click (and optionally drag)
  • Subtract from selection: Alt + Left Click This didn't work in early builds of v3.
  • Add block selection: Ctrl + Shift + Right Click (and drag)
  • Subtract block selection: Alt + Shift + Right Click (and drag)

Mac OS X

Building blocks:

  • Positive/negative:
    • Add to selection:
    • Subtract from selection: ⇧⌘ (only works with block selection in v3; presumably bug)
  • Selection type:
    • Linear selection: Left Click
    • Block selection: Middle Click or + Left Click

Combine as you see fit. For example:

  • Add to selection: + Left Click (and optionally drag)
  • Subtract from selection: ⇧⌘ + Left Click (and drag--this combination doesn't work in Sublime Text 3, but supposedly it works in 2)
  • Add block selection: ⌥⌘ + Left Click (and drag)
  • Subtract block selection: ⌥⇧⌘ + Left Click (and drag)

Keyboard

Windows

  • Return to single selection mode: Esc
  • Extend selection upward/downward at all carets: Ctrl + Alt + Up/Down
  • Extend selection leftward/rightward at all carets: Shift + Left/Right
  • Move all carets up/down/left/right, and clear selection: Up/Down/Left/Right
  • Undo the last selection motion: Ctrl + U
  • Add next occurrence of selected text to selection: Ctrl + D
  • Add all occurrences of the selected text to the selection: Alt + F3
  • Rotate between occurrences of selected text (single selection): Ctrl + F3 (reverse: Ctrl + Shift + F3)
  • Turn a single linear selection into a block selection, with a caret at the end of the selected text in each line: Ctrl + Shift + L

Linux

  • Return to single selection mode: Esc
  • Extend selection upward/downward at all carets: Alt + Up/Down Note that you may be able to hold Ctrl as well to get the same shortcuts as Windows, but Linux tends to use Ctrl + Alt combinations for global shortcuts.
  • Extend selection leftward/rightward at all carets: Shift + Left/Right
  • Move all carets up/down/left/right, and clear selection: Up/Down/Left/Right
  • Undo the last selection motion: Ctrl + U
  • Add next occurrence of selected text to selection: Ctrl + D
  • Add all occurrences of the selected text to the selection: Alt + F3
  • Rotate between occurrences of selected text (single selection): Ctrl + F3 (reverse: Ctrl + Shift + F3)
  • Turn a single linear selection into a block selection, with a caret at the end of the selected text in each line: Ctrl + Shift + L

Mac OS X

  • Return to single selection mode: (that's the Mac symbol for Escape)
  • Extend selection upward/downward at all carets: ⌃⇧⇡, ⌃⇧⇣ (See note)
  • Extend selection leftward/rightward at all carets: ⇧⇠/⇧⇢
  • Move all carets up/down/left/right and clear selection: , , ,
  • Undo the last selection motion: ⌘U
  • Add next occurrence of selected text to selection: ⌘D
  • Add all occurrences of the selected text to the selection: ⌃⌘G
  • Rotate between occurrences of selected text (single selection): ⌥⌘G (reverse: ⌥⇧⌘G)
  • Turn a single linear selection into a block selection, with a caret at the end of the selected text in each line: ⇧⌘L

Notes for Mac users

On Yosemite and El Capitan, ⌃⇧⇡ and ⌃⇧⇣ are system keyboard shortcuts by default. If you want them to work in Sublime Text, you will need to change them:

  1. Open System Preferences.
  2. Select the Shortcuts tab.
  3. Select Mission Control in the left listbox.
  4. Change the keyboard shortcuts for Mission Control and Application windows (or disable them). I use ⌃⌥⇡ and ⌃⌥⇣. They defaults are ⌃⇡ and ⌃⇣; adding to those shortcuts triggers the same actions, but slows the animations.

In case you're not familiar with Mac's keyboard symbols:

  • is the escape key
  • is the control key
  • is the option key
  • is the shift key
  • is the command key
  • et al are the arrow keys, as depicted

I find using vintage mode works really well with sublime multiselect.

My most used keys would be "w" for jumping a word, "^" and "$" to move to first/last character of the line. Combinations like "2dw" (delete the next two words after the cursor) make using multiselect really powerful.

This sounds obvious but has really sped up my workflow, especially when editing HTML.

Mac Users, let me save you the time:

  • Cmd+a: select the lines you want a cursor
  • Cmd+Shift+l: to create the cursor