Is there a way in JetBrains IDE's to set a keyboard shortcut to move the caret/cursor to the center?

102 Views Asked by At

I am looking for a command in JetBrains IDE's (specifically WebStorm and Rider) to set a keyboard shortcut that will center the caret in the center of the editor page.

Is this possible with a shortcut or extension?

Just to be clear, I don't want to move the page to center the caret (which already exists with s shortcut), I want to move the caret to the center of the page, without moving the editor page view.

1

There are 1 best solutions below

3
Fraser On

Sure, you can just use Ctrl + M to move the caret to centre of the screen.

If you don't want to have to hit Ctrl + M all the time, you can also achieve what you want by using the IdeaVim plugin

  1. Open the Settings dialog (Ctrl+Alt+S)
  2. Select Plugins.
  3. Find the IdeaVim plugin and install.

ideavim

  1. Create $HOME/.ideavimrc
  2. Add set scrolloff=XX where XX is at least half the total lines you would usually see. Setting 'scrolloff' to a large value causes the cursor to stay in the middle line when possible. e.g. set scrolloff=999
  3. Restart your IDE.

Tested and working in PHPStorm and PyCharm