vi
hey everyone,
i m just wondering if there is any way i can select text in vi same as gedit,notepad,etc(shift + arrowkeys) or as we can do in nano > alt + a to set marker and then select text using arrow keys ? thanks |
Hmm.. prehaps no! But to select a single word, just double click on any of it's character, and it will be selected, then if quick edit mode is activated on the tool (i.e. if you're using putty or terminal, it's already on) selected text will already get copied after selection.
However, if selected text has not got copy, then after selection (using double click on it), use SHIFT+INSERT to copy it and to paste it, use CTRL+INSERT key combination. === Adding info. ==== In vi editor, copy is done using yy (stands for yank), but it has certain limitation. For instance:- yy - Copies current line yw - Copies 1 word forward And few more... But problem with yy is that, you'll need to use "p" (below the current record) and "P" (above the current record) keystrock to paste copied content, which is not convenient and aprropriate. |
Hi,
it depends on what you want to do with the selected text. In vi the commands are always a combination "how many of" + "what" + "do this". Example 3dw delete up to the third word, 3dd delete three lines. Please explain what exactly you want to do. Markus |
Cursor Movement
h move left (backspace) j move down k move up l move right (spacebar) [return] move to the beginning of the next line $ last column on the current line 0 move cursor to the first column on the current line ^ move cursor to first nonblank column on the current line w move to the beginning of the next word or punctuation mark W move past the next space b move to the beginning of the previous word or punctuation mark B move to the beginning of the previous word, ignores punctuation e end of next word or punctuation mark E end of next word, ignoring punctuation H move cursor to the top of the screen M move cursor to the middle of the screen L move cursor to the bottom of the screen Screen Movement G move to the last line in the file xG move to line x z+ move current line to top of screen z move current line to the middle of screen z- move current line to the bottom of screen ^F move forward one screen ^B move backward one line ^D move forward one half screen ^U move backward one half screen ^R redraw screen ( does not work with VT100 type terminals ) ^L redraw screen ( does not work with Televideo terminals ) Inserting r replace character under cursor with next character typed R keep replacing character until [esc] is hit i insert before cursor a append after cursor A append at end of line O open line above cursor and enter append mode Deleting x delete character under cursor dd delete line under cursor dw delete word under cursor db delete word before cursor Copying Code yy (yank)'copies' line which may then be put by the p(put) command. Precede with a count for multiple lines. Put Command brings back previous deletion or yank of lines, words, or characters P bring back before cursor p bring back after cursor |
Quote:
|
Quote:
i found the way, actually two: 1) press ctrl+v select text yank, cut or whatever. 2) place cursor press ma to set marker move cursor to the end of block press :'a,.y. but i have a problem with this one it does not work the way i intended to, i mean i can select whole line from start of marker to current line but what if i want to copy it from a character in one to the a specific character in say 10th line? any ideas? |
Quote:
|
Quote:
|
Quote:
|
Quote:
CTRL-v : blockwise-visual v: character wise-visual V: linewise-visual now i was wondering if i can achieve same through markers. |
You should post the text and tell us which part has to be deleted or copied, then we can tell you the command. The visualmode is only in vim, but you asked for vi. If you really want to learn vi, you should avoid vim-specific commands.
Markus |
Quote:
Code:
You should post the text and tell us which part has to be deleted or copied, then we can tell you the command. The visualmode is only in vim, but you asked for vi. If you really want to learn vi, you should avoid vim-specific commands. Code:
The visualmode is only in vim, but you asked for vi |
Well, if the cursor is anywhere left from this text, simply )d) which means go to the next sentence, delete the next sentence.
The deleted text is then stored in the buffer and can be pasted with p anywhere. Markus |
Quote:
Code:
The visualmode is only in vim, but you asked for vi. If you really want to learn vi, you should avoid |
Without a GUI surrounding vi,
(1) yw or yy to yank a word of line. (2) Position the cursor where you need to insert it. "p" to place. OK |
All times are GMT -5. The time now is 02:49 AM. |