![]() You can copy a range of lines in vim using the operation, :M,Nyank. ![]() To copy line two and paste just below the current cursor position :2t. You can can copy specific line number and paste right below the cursor directly using the operation :Nt., where N is the line number you want to copy.įor example, to copy line two and paste just above the current cursor position :2t. You can can copy specific line number and paste right above the cursor directly using the operation :Nt-, where N is the line number you want to copy. You can show number lines in vim using, :set number.įor example, say you are at the end of the file being edited and you want to copy the second line of the vim, simply press ESC key and enter :2yank Copy Specific Line Number and Paste right above or below the cursor To copy specific line number in vim, use the :Nyank operation where N is the specific line number you want to copy. for example, to copy the fifth line just right above the cursor :-4yank Copy Specific Line Number in VIM To copy 5 lines above cursor (from the current cursor position) y4k It is also possible to copy specific number of lines above the cursor in VIM, of course beginning from the current location of the cursor using the operation yN-1k, where N-1 is the number of lines you want to copy.įor example, to copy two lines from the current position of the cursor, press (in normal mode, or escape mode), y2-1k which is equivalent to y1k. Copy Specific number of lines above the cursor in VIM Where the dot (.) means current line and plus (+) means plus one line below the cursor. You can also use the operation to copy two lines.,+yank Where N is the number of lines.įor example, to copy two lines under the cursor ( beginning from the current location of the cursor ), enter into normal mode by pressing ESC key, and press 2yy To copy specific number of lines under the cursor ( beginning from the current location of the cursor ) in vim, simply specify the number of lines followed by the yank operation ( N yy). Or Y Copy Specific number of lines under the cursor in VIM To copy the current line (line in which the cursor is placed), simply press double lower y ( yy) or single upper case y (Y). You can enter into normal mode by pressing ESC key. The above operations should be done in normal vim operation mode (this is the initial mode when you first open the file).
0 Comments
Leave a Reply. |