Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving between underscore separated words with Alt + ←/→ in PyCharm

In PyCharm when I move between words with the Alt + ←/→ shortcut it moves the cursor between whitespace separated words. How can I make it move the cursor between underscore_seperated_words?

like image 721
Inti Avatar asked Dec 12 '13 20:12

Inti


People also ask

How do I use Shift Codes in PyCharm?

To move a line up or down, press Alt+Shift+Up or Alt+Shift+Down respectively. To move (swap) a code element to the left or to the right, place the caret at it, or select it and press Ctrl+Alt+Shift+Left for left or Ctrl+Alt+Shift+Right for right.

How do I select a word using the keyboard in PyCharm?

You can use your mouse to make your selection. Or, use the keyboard. For example, use Move Caret to Previous Word with Selection ( Shift-Ctrl-Left/Right Win/Linux, Alt-Shift-Left/Right macOS) to (a) move the cursor forward or backward a word, while (b) expanding the selection along the way.

How do you jump to the end of line in PyCharm?

If you hit the End key on your keyboard in PyCharm, the caret moves to the end of the line.


2 Answers

The option is not obvious but if I tick Editor -> General -> Smart Keys -> Use "CamelHumps" words then when moving between words with Alt + ←/→ I can step between underscore separated words rather than just space separated "words". The same works for camelCase words obviously.

like image 170
Inti Avatar answered Sep 20 '22 19:09

Inti


If you want both capabilities for whitespace separated and camelCase separated curser movement and selection, there are options in the keymap under Editor Actions called:

  • Move Caret to Next Word
  • Move Caret to Next Word in Different "CamelHumps" Mode
  • Move Caret to Next Word with Selection in Different "CamelHumps" Mode
  • Move Caret to Pervious Word
  • Move Caret to Previous Word in Different "CamelHumps" Mode
  • Move Caret to Previous Word with Selection in Different "CamelHumps" Mode

As I mainly use the regular cursor movement with Ctrl + ←/→ I added Alt + ←/→ for the "CamelHumps" mode. As mentioned, the CamelCase works for underline separated as well.

like image 41
Eric Blum Avatar answered Sep 16 '22 19:09

Eric Blum