2017年12月14日 星期四

[Linux 常見問題] Command vi - Cut/copy and paste using visual selection

Source From Here 
Preface 
Visual selection is a common feature in applications, but Vim's visual selection has several benefits. 

To cut-and-paste or copy-and-paste: 
1. Position the cursor at the beginning of the text you want to cut/copy.
2. Press v to begin character-based visual selection, or V to select whole lines, or Ctrl-v or Ctrl-q to select a block.
3. Move the cursor to the end of the text to be cut/copied. While selecting text, you can perform searches and other advanced movement.
4. Press d (delete) to cut, or y (yank) to copy.
5. Move the cursor to the desired paste location.
6. Press p to paste after the cursor, or P to paste before.

Visual selection (steps 1-3) can be performed using a mouse. 

If you want to change the selected text, press c instead of d or y in step 4. In a visual selection, pressing c performs a change by deleting the selected text and entering insert mode so you can type the new text. 

Pasting over a block of text 
You can copy a block of text by pressing Ctrl-v (or Ctrl-q if you use Ctrl-v for paste), then moving the cursor to select, and pressing y to yank. Now you can move elsewhere and press p to paste the text after the cursor (or P to paste before). The paste inserts a block (which might, for example, be 4 rows by 3 columns of text). 

Instead of inserting the block, it is also possible to replace (paste over) the destination. To do this, move to the target location then press 1vp (1v selects an area equal to the original, and p pastes over it). 

When a count is used before vV, or ^V (character, line or block selection), an area equal to the previous area, multiplied by the count, is selected. See the paragraph after :help

Note that this will only work if you actually did something to the previous visual selection, such as a yank, delete, or change operation. It will not work after visually selecting an area and leaving visual mode without taking any actions. 

Supplement 
Visual selection 
Copy, cut and paste

沒有留言:

張貼留言

[ Python 文章收集 ] SQLAlchemy quick start with PostgreSQL

Source From   Here   Preface   This is a quick tutorial for getting started with   SQLAlchemy Core API .   Prerequisites   In this quick st...