21

Without IdeaVim in PhpStorm, the tab key can be used to indent a selected block of text. However, I'm interested to know if there's a shortcut key that does the same thing with the IdeaVim plugin installed (without losing any functionality that the tab key otherwise has).

Highly Irregular
  • 38,000
  • 12
  • 52
  • 70

2 Answers2

43

See Indent multiple lines quickly in vi

You must be in normal mode, i.e. go Esc before indenting.

You can select a block of lines with Shift+V, then up/down arrows, then > to indent (< reverses indent).

Community
  • 1
  • 1
Niloct
  • 9,491
  • 3
  • 44
  • 57
  • 4
    Great, that looks pretty good. I notice though that once I've done one indent on a selected block, it becomes deselected. If you know a way to keep it selected, please let me know! Thanks again. – Highly Irregular Oct 20 '14 at 23:11
  • 8
    You can specify the number of indents before the `<` or `>` command. Like, `2>` indents 2 times. You're welcome. – Niloct Oct 21 '14 at 00:02
  • 15
    There is the `.` command in vim, which repeats last command, that would be a lot better than calculating (even with the vertical lines in phpstorm which helps you to do that). It seems IdeaVim is broken in this matter: a dot command after a block indent only indents one line... – Niloct Oct 21 '14 at 01:36
  • 1
    Yes, I agree with this feature requets. I program in python and when I refactor I tend to move function bodies around and changing indentation quite a bit. Right now I can change indentation 1 level by doing a block visualization and indenting that part. But when I enter the . command (like it works in normal vim) it only applies to the last row and not the whole selection. I haven't found a way to easily change indentation levels on multiple rows more than one step on the current version (0.37). Thanks for a great plugin btw :) – monostop Nov 07 '14 at 13:31
  • 1
    The license is GPL, the IdeaVim source is in Github, it's just a matter of dedication, knowledge and a pull request. – Niloct Nov 07 '14 at 16:09
  • 5
    As I stumbled upon this in 2019, I want to note that the `.` command now works properly in IntelliJ IDEs – alex_java_kotlin Sep 04 '19 at 16:55
18

I think following settings are what you want! :)

Put the followings to ~/.ideavimrc

nnoremap <Tab> >>_
nnoremap <S-Tab> <<_
inoremap <S-Tab> <C-D>
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv

ideavim support vimrc with .ideavimrc

also see: Is there a way to get IdeaVIM to honor the mappings from my .vimrc file?

Community
  • 1
  • 1
doortts
  • 181
  • 1
  • 2