Home > Unix > UNIX – Lesson 012 – vi editor – Copy, Paste and Change Text

UNIX – Lesson 012 – vi editor – Copy, Paste and Change Text


Copy Text: yw, yy

  • yw yank the current word
  • yy yank the current line
  • [n]yy yank [n] lines
  • y^ yank to the beginning of the line
  • y$ yank to the end of the line
  • yG yank through the last line

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

Paste Text: P, p

  • P paste contents of the buffer into the text before the cursor
  • p paste contents of the buffer back into the text after the cursor

The combination of delete and paste operation allows you to easily move blocks of text.
==================================================================================

Change Text: r, R, cw, .

  • rcharacter replaces the character at the current cursor position with the named character
  • R replaces all characters (goes into overstrike mode) until ESC is pressed
  • cw changes the current word
  • [n]cw changes next [n] words
  • cc changes the current line entirely
  • c^ changes to the beginning of the line
  • c$ changes from the cursor to the end of the line
  • cG changes through the last line of the file
  • ~ changes case of character

The dot (.) command is probably one of the handiest commands available in vi.

This allows you to repeat last change operation (this includes deletes too)

Categories: Unix
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: