简体   繁体   English

Atom 编辑器 - 按行多选

[英]Atom editor - multiselect by line

I am moving from Sublime to Atom , and can't find a certain hotkey for the life of me.我正在从Sublime转移到Atom ,并且无法为我的生活找到某个热键。

Control+D will still do a multi-select - select the next instance your highlighted text, at which point you will get multiple cursors. Control+D仍然会进行多选 - 选择下一个突出显示的文本实例,此时您将获得多个光标。

In Sublime , if you selected multiple lines and pressed control+shift+l , it would then create a cursor on each line, so you could edit each line at once.Sublime ,如果您选择多行并按下control+shift+l ,它将在每一行上创建一个光标,因此您可以一次编辑每一行。

I looked through the hotkey lists for Atom , and can't find this.我查看了Atom的热键列表,但找不到它。 But then I probably don't know the right terminology.但是我可能不知道正确的术语。

我最近使用了这个包,但我不确定是否有热键: https ://atom.io/packages/sublime-style-column-selection

For Windows users,对于 Windows 用户,
the default keybindings ctrl + shift + up / down seems to work.默认的键绑定ctrl + shift + up / down似乎有效。

For Mac users,对于 Mac 用户,
add the following custom keybinding code to the将以下自定义键绑定代码添加到
/user/<yourName>/.atom/keymap.cson file /user/<yourName>/.atom/keymap.cson文件

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# change the keybinding for ADD SELECTION ABOVE / BELOW
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  'shift-alt-up': 'editor:add-selection-above'
#  'shift-alt-down': 'editor:add-selection`-below'
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Then place the cursor where you want to start and press and hold shift + alt and press up or down repeatedly to extend the cursor to as many lines as needed.然后将光标放在要开始的位置并按住shift + alt并反复按updown以将光标扩展到所需的行数。

The command in the menu Selection —> Split into Lines should do what you want.菜单“ Selection —> Split into Lines ”中的命令应该可以执行您想要的操作。 On the Mac the keyboard shortcut is cmd-shift-l .在 Mac 上,键盘快捷键是cmd-shift-l

Use the multi-cursor package .使用多光标包

Use CTRL/COMMAND to select multiple places.使用 CTRL/COMMAND 选择多个位置。

Adding Key-Binding to Selection --> Split into Lines将键绑定添加到Selection --> Split into Lines

To add the ctrl + shift + L Key-binding to this you need to edit your custom keymap file.要将ctrl + shift + L键绑定添加到此,您需要编辑自定义键盘映射文件。

  1. Edit --> Keymap... :opens keymap.cson file Edit --> Keymap Keymap... :opens keymap.cson 文件
  2. You can use ctrl + .您可以使用ctrl + to open a Key Binding Resolver to view currently assigned Key-Bindings to check if the desired key-binding is already occupied.打开 Key Binding Resolver 以查看当前分配的 Key-Bindings 以检查所需的 Key-binding 是否已被占用。
  3. To re -map a currently occupied binding simply redifine it in the custom keymap file.重新映射当前占用的绑定,只需在自定义键盘映射文件中重新定义它。
  • in my case grammar-selector:show needed remapping, (remapping to ctrl-shift-j in this case)在我的情况下,语法选择器:显示需要重新映射,(在这种情况下重新映射到 ctrl-shift-j)

Append to : keymap.cson附加到: keymap.cson

  ".platform-darwin atom-text-editor":
    "ctrl-shift-j": "grammar-selector:show"
  ".platform-win32 atom-text-editor":
    "ctrl-shift-j": "grammar-selector:show"
  ".platform-linux atom-text-editor":
    "ctrl-shift-j": "grammar-selector:show"
  1. Now we add the desired keybinding (as defined in the multi-cursor package description )现在我们添加所需的键绑定(如多光标包描述中所定义)

Append to : keymap.cson附加到: keymap.cson

  '.platform-darwin atom-text-editor:not([mini])':
    'ctrl-shift-l': 'editor:split-selections-into-lines'
  '.platform-win32 atom-text-editor:not([mini])': 
    'ctrl-shift-l': 'editor:split-selections-into-lines'
  '.platform-linux atom-text-editor:not([mini])':
    'ctrl-shift-l': 'editor:split-selections-into-lines'
  1. Save keymap.cson and Restart Atom.保存keymap.cson并重启 Atom。

Note: I have only tested this on linux.注意:我只在 linux 上测试过。 Note2: on mac , ie darwin this may not be needed注2:在mac上,即darwin这可能不需要

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM