Obeta

Pycharm与Idea使用SublimeText的快捷键

平时使用的是一些SublimeText的快捷键,后面写Python后转到了Pycharm就不太适应自带的快捷键,还好Pycharm与Idea支持快捷键定制.

从 sublime text 转到 vscode,直接有相关的 keymaps 可以使用,因此并没有任何转化成功,但是在写 python 的时候选择了 pycharm,官方并没有给出相关的 keymaps,因此搜罗了一些 sublime text 的 keymap:

<keymap version="1" name="Sublime Text" parent="Mac OS X 10.5+">
  <action id="$Copy">
    <keyboard-shortcut first-keystroke="meta c" />
  </action>
  <action id="$Cut">
    <keyboard-shortcut first-keystroke="ctrl x" />
    <keyboard-shortcut first-keystroke="shift delete" />
    <keyboard-shortcut first-keystroke="meta x" />
  </action>
  <action id="$Paste">
    <keyboard-shortcut first-keystroke="meta v" />
  </action>
  <action id="$Redo">
    <keyboard-shortcut first-keystroke="shift ctrl z" />
    <keyboard-shortcut first-keystroke="shift alt back_space" />
    <keyboard-shortcut first-keystroke="shift meta z" />
  </action>
  <action id="$SelectAll">
    <keyboard-shortcut first-keystroke="meta a" />
  </action>
  <action id="$Undo">
    <keyboard-shortcut first-keystroke="meta z" />
  </action>
  <action id="ActivateProjectToolWindow">
    <keyboard-shortcut first-keystroke="meta 1" />
    <keyboard-shortcut first-keystroke="meta k" second-keystroke="meta b" />
  </action>
  <action id="Back">
    <keyboard-shortcut first-keystroke="meta alt left" />
    <mouse-shortcut keystroke="button4" />
  </action>
  <action id="CheckinProject" />
  <action id="Console.TableResult.NavigateAction">
    <keyboard-shortcut first-keystroke="f4" />
  </action>
  <action id="Database.OpenDbStorageAction">
    <keyboard-shortcut first-keystroke="f4" />
  </action>
  <action id="DecrementWindowHeight" />
  <action id="DomCollectionControl.Edit">
    <keyboard-shortcut first-keystroke="f4" />
  </action>
  <action id="DomElementsTreeView.GotoDomElementDeclarationAction">
    <keyboard-shortcut first-keystroke="f4" />
  </action>
  <action id="EditSource">
    <keyboard-shortcut first-keystroke="f4" />
  </action>
  <action id="Editor Copy">
    <keyboard-shortcut first-keystroke="meta c" />
  </action>
  <action id="Editor Cut">
    <keyboard-shortcut first-keystroke="meta x" />
  </action>
  <action id="Editor Paste">
    <keyboard-shortcut first-keystroke="meta v" />
  </action>
  <action id="Editor Redo">
    <keyboard-shortcut first-keystroke="shift meta z" />
  </action>
  <action id="Editor SelectAll">
    <keyboard-shortcut first-keystroke="meta a" />
  </action>
  <action id="Editor Undo">
    <keyboard-shortcut first-keystroke="meta z" />
  </action>
  <action id="EditorDuplicate" />
  <action id="EditorIndentSelection">
    <keyboard-shortcut first-keystroke="tab" />
    <keyboard-shortcut first-keystroke="meta close_bracket" />
  </action>
  <action id="EditorPageDown">
    <keyboard-shortcut first-keystroke="page_down" />
    <keyboard-shortcut first-keystroke="meta down" />
  </action>
  <action id="EditorPageDownWithSelection">
    <keyboard-shortcut first-keystroke="shift page_down" />
    <keyboard-shortcut first-keystroke="shift meta down" />
  </action>
  <action id="EditorPageUp">
    <keyboard-shortcut first-keystroke="page_up" />
    <keyboard-shortcut first-keystroke="meta up" />
  </action>
  <action id="EditorPageUpWithSelection">
    <keyboard-shortcut first-keystroke="shift page_up" />
    <keyboard-shortcut first-keystroke="shift meta up" />
  </action>
  <action id="EditorUnindentSelection">
    <keyboard-shortcut first-keystroke="shift tab" />
    <keyboard-shortcut first-keystroke="meta open_bracket" />
  </action>
  <action id="ExpandAll">
    <keyboard-shortcut first-keystroke="ctrl add" />
  </action>
  <action id="ExpandAllRegions">
    <keyboard-shortcut first-keystroke="ctrl k" second-keystroke="ctrl j" />
  </action>
  <action id="ExpandRegion">
    <keyboard-shortcut first-keystroke="shift ctrl close_bracket" />
  </action>
  <action id="FileChooser.TogglePathShowing" />
  <action id="Forward">
    <keyboard-shortcut first-keystroke="meta alt right" />
    <mouse-shortcut keystroke="button5" />
  </action>
  <action id="GotoAction">
    <keyboard-shortcut first-keystroke="shift meta p" />
  </action>
  <action id="GotoFile">
    <keyboard-shortcut first-keystroke="meta t" />
  </action>
  <action id="GotoRelated" />
  <action id="GotoTest" />
  <action id="Images.ShowThumbnails" />
  <action id="IncrementWindowHeight" />
  <action id="IncrementalSearch">
    <keyboard-shortcut first-keystroke="meta i" />
  </action>
  <action id="Jdbc.OpenTableEditor">
    <keyboard-shortcut first-keystroke="f4" />
  </action>
  <action id="MoveStatementDown">
    <keyboard-shortcut first-keystroke="ctrl meta down" />
  </action>
  <action id="MoveStatementUp">
    <keyboard-shortcut first-keystroke="ctrl meta up" />
  </action>
  <action id="ParameterInfo" />
  <action id="PasteMultiple" />
  <action id="RemoteHostView.EditSource">
    <keyboard-shortcut first-keystroke="f4" />
  </action>
  <action id="ReopenClosedTab">
    <keyboard-shortcut first-keystroke="shift meta t" />
  </action>
  <action id="ReplaceInPath" />
  <action id="ResizeToolWindowDown" />
  <action id="ResizeToolWindowUp" />
  <action id="SearchEverywhere">
    <keyboard-shortcut first-keystroke="meta p" />
  </action>
  <action id="SelectNextOccurrence">
    <keyboard-shortcut first-keystroke="alt j" />
    <keyboard-shortcut first-keystroke="meta d" />
  </action>
  <action id="ShowNavBar">
    <keyboard-shortcut first-keystroke="alt home" />
  </action>
  <action id="SwitchApply">
    <keyboard-shortcut first-keystroke="ctrl alt enter" />
  </action>
  <action id="SwitchDown">
    <keyboard-shortcut first-keystroke="ctrl alt down" />
  </action>
  <action id="SwitchLeft">
    <keyboard-shortcut first-keystroke="ctrl alt left" />
  </action>
  <action id="SwitchRight">
    <keyboard-shortcut first-keystroke="ctrl alt right" />
  </action>
  <action id="SwitchUp">
    <keyboard-shortcut first-keystroke="ctrl alt up" />
  </action>
  <action id="Vcs.UpdateProject" />
</keymap>

Pycharm

使用方法就是将上面代码 copy:

# Mac 上边的xx需要根据你具体到安装文件名来决定
cd ~/Library/Preferences/PyCharm xx/keymaps/

Windows and *NIX systems: /PyCharm /config/keymaps\

我这边是cd ~/Library/Preferences/PyCharm2018.2/keymaps/,然后再:

vi sublime_keymaps.xml

再将上面的代码 copy 到这个文件里,重启 pycharm,preference -> Keymap -> 下拉框选择 -> Sublime Text, Apply 一下就好了.

Ieda

对于 Idea 也是可以这样的,只是需要找对路径,否则识别不出来.我在测试的时候发现 Idea 官方文档给的路径与真实路径并不一样:

# mac 官方给定路径
~/Library/Preferences/IntelliJIdea xx/keymaps/
# mac 实际能用的路径
~/Library/Preferences/IntelliJIdea xx/jba_config/mac.keymaps/

也许这个路径跟版本有具体关系,因此可以先在配置中增加一条新的配置,比如叫sublime,然后去~/Library/Preferences/IntelliJIdea xx/路径下全局搜sublime相关的文件,就能找到真实的路径.

个人随笔记录,内容不保证完全正确,若需要转载,请注明作者和出处.