1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-05 16:18:01 +00:00

Add Reverse A Group Of Lines as a vim til.

This commit is contained in:
jbranchaud
2015-11-11 20:15:51 -06:00
parent a6098b2d64
commit 43ccfb4732
2 changed files with 21 additions and 0 deletions

View File

@@ -286,6 +286,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
- [Repeat The Previous Change](vim/repeat-the-previous-change.md) - [Repeat The Previous Change](vim/repeat-the-previous-change.md)
- [Repeating Characters](vim/repeating-characters.md) - [Repeating Characters](vim/repeating-characters.md)
- [Replace A Character](vim/replace-a-character.md) - [Replace A Character](vim/replace-a-character.md)
- [Reverse A Group Of Lines](vim/reverse-a-group-of-lines.md)
- [Scrolling Relative to the Window](vim/scrolling-relative-to-the-window.md) - [Scrolling Relative to the Window](vim/scrolling-relative-to-the-window.md)
- [Searching For Hex Digits](vim/searching-for-hex-digits.md) - [Searching For Hex Digits](vim/searching-for-hex-digits.md)
- [Set End Of Line Markers](vim/set-end-of-line-markers.md) - [Set End Of Line Markers](vim/set-end-of-line-markers.md)

View File

@@ -0,0 +1,20 @@
# Reverse A Group Of Lines
The following command can be used to reverse the order of all lines in a
file by doing a global move on all lines that match the beginning of line
character starting at the theoretically 0th character:
```
:g/^/m 0
```
Reversing a range of lines is a little more work. Just as the previous
example needs to be anchored against the 0th character, a specific range of
lines needs to be anchored at the line just before the range. Thus reversing
the lines 5 to 10 requires being anchored at line 4, like so:
```
:4,10g/^/m 4
```
[source](http://superuser.com/questions/189947/how-reverse-selected-lines-order-in-vim#)