-
-
Save Johnytran/675f3016e049612ab80e to your computer and use it in GitHub Desktop.
duplicate line in vim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:t. will duplicate the line, | |
:t 7 will copy it after line 7, | |
:,+t0 will copy current and next line at the beginning of the file (,+ is a synonym for the range .,.+1), | |
:1,t$ will copy lines from beginning till cursor position to the end (1, is a synonym for the range 1,.). | |
If you need to move instead of copying, use :m instead of :t. | |
This can be really powerful if you combine it with :g or :v: | |
:v/foo/m$ will move all lines not matching the pattern “foo” to the end of the file. | |
:+,$g/^\s*class\s\+\i\+/t. will copy all subsequent lines of the form class xxx right after the cursor. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment