mirror of
https://github.com/jbranchaud/til
synced 2026-01-07 09:08:01 +00:00
Add Re-indenting Your Code as a vim til.
This commit is contained in:
33
vim/reindenting-your-code.md
Normal file
33
vim/reindenting-your-code.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# Re-indenting Your Code
|
||||
|
||||
If you have pasted some poorly formatted code or you've written a portion
|
||||
of code in a way that mangled the indentation, you can quickly re-indent
|
||||
that code for you. Or at least do its best to try and indent it correctly.
|
||||
|
||||
Make a visual selection of the code that you want to re-indent and then
|
||||
hit `=`.
|
||||
|
||||
For instance, this ruby code
|
||||
|
||||
```ruby
|
||||
if this_thing
|
||||
p something
|
||||
else
|
||||
p nothing
|
||||
end
|
||||
```
|
||||
|
||||
will be indented by Vim as
|
||||
|
||||
```ruby
|
||||
if this_thing
|
||||
p something
|
||||
else
|
||||
p nothing
|
||||
end
|
||||
```
|
||||
|
||||
See `:h =` for more details on how vim decides what formatting and
|
||||
indenting it will do.
|
||||
|
||||
h/t [Chris Erin](https://twitter.com/MCNormalMode)
|
||||
Reference in New Issue
Block a user