user1543863
user1543863

Reputation:

Vim format source code from Visual mode

watching a screencast (can't link it since you need to have a peepcode pro subscription) I've seen a developer indenting his source code (a ruby file) graphically using the visual mode inside vim. He did the following steps: press "v" selecting lines and then pressing something else I didn't get (because there is no representation of what's being pressed on the keyboard), then he got the whole source perfectly indented, without the need to write something on the command line.

Is there a plugin you know to do it that way from visual mode?

Upvotes: 1

Views: 405

Answers (3)

the blizz
the blizz

Reputation: 330

This plugin does exactly what you want: https://github.com/Chiel92/vim-autoformat.

Upvotes: 1

guini
guini

Reputation: 760

You can press = in visual mode to automatically indent your code.

Or you can use > and < in visual mode to change the indentation level of the selected code.

Upvotes: 1

romainl
romainl

Reputation: 196476

That would be V(motion)=.

See :help = for details.

Upvotes: 0

Related Questions