Sunday, 10 September 2017

Terminal - Copy all the lines to clipboard

Copy  single line press      yy
To copy 5 lines                5yy

To paste one time              p
To past n times (5)            5p



To goto starting of file     gg
To goto the n th lline(9)   9 gg



Undo copy press             u

To delete                        dd
To delete all                   :%d




How do I move to end of line in Vim?

  • $ gets you to the end of the line

First press Escape
:$



How do I make the vi editor display or hide line numbers?



To make vi display line numbers, you need to set the number flag. To do so:
  1. Press the Esc key if you are currently in insert or append mode.
  2. Press : (the colon). The cursor should reappear at the lower left corner of the screen next to a : prompt.
  3. Enter the following command:
      set number
  4. A column of sequential line numbers will then appear at the left side of the screen. Each line number references the text located directly to the right.
To turn off line numbering, again follow the preceding instructions, except this time enter the following line at the: prompt:
  set nonumber
Normally, vi will forget the setting you've chosen once you've left the editor. You can, however, make either setting take effect automatically whenever you use vi on a particular account. To do this, place the appropriate setstatement as a line in a file in your home directory named .exrc .
For a list of all current settings, at the : prompt, enter:
  set all
For a list of everything that you have set, at the : prompt, enter:
  set


====================


->  open file with  Vi
             vi fileName
->   type       gg      to goto the first line

->
:%y a Yanks all the content into vim's buffer, Pressing p in command mode will paste the yanked content after the line that your cursor is currently standing at.







=====
up vote408down voteaccepted
You should yank the text to the * or + registers:
gg"*yG
Explanation:
  • gg
    • gets the cursor to the first character of the file
  • "*y
    • Starts a yank command to the register * from the first line, until...
  • G
    • go the end of the file

No comments:

Post a Comment