Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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 ?
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.
Last edited by shivaa; 12-15-2012 at 06:21 AM.
Reason: Adding info.
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
Last edited by markush; 12-15-2012 at 05:43 AM.
Reason: typo
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.
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
thankz 1300, i know about these but thanks anyway.
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?
You can do copy (using yy keystroke) and paste (using p or P), but as far as I know there's no shortcut for cut operation. You'll first need to copy and paste and then go back to the previous record i.e. line, and delete it using dd.
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?
You can do copy (using yy keystroke) and paste (using p or P), but as far as I know there's no shortcut for cut operation. You'll first need to copy and paste and then go back to the previous record i.e. line, and delete it using dd.
no need to copy just delete, the deleted text is stored temporarily in a buffer. This buffer can be pasted into the document by using the p command.
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.
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
thanks, take this text as an example:
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.
and say i want to copy :
Code:
The visualmode is only in vim, but you asked for vi
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.