LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   vim (https://www.linuxquestions.org/questions/programming-9/vim-524289/)

culin 01-31-2007 02:43 AM

vim
 
Hi all,
can anyone tell me is there any command in vi editor to "select all" other than typing number of lines and yy

Mega Man X 01-31-2007 03:08 AM

Try pressing V on your first line, then G to mark all text. Remember it is "V" and "G" not "v" or "g" ^_^;;

Mega Man X 01-31-2007 03:10 AM

Oops sorry... that will not work on vi, because vi does not have visual mode. Now, if you are using vim (which is far better - pun indented), it should work.

Regards!

jschiwal 01-31-2007 03:11 AM

If you want to do something like a search & replace over the entire document for example, use '%' for the range:
:%s/ thier/ their/g

culin 01-31-2007 03:27 AM

oh.. wow..:) its working....Thanks Mega Man X :)
and after marking with G i have to yank right ?? "yy"

Mega Man X 01-31-2007 03:42 AM

Np. Always a pleasure to help another Linux and Vim enthusiast :D

Regards!

EDIT: oops. Yup, yank after. I can't test it now, but I think that if you yank, you will automatically leave visual mode. If you want to paste it, you will need to enter visual mode again (press v). i could be wrong though :)

EDIT2: tested. You don't need to be on Visual mode to paste, once you've "yanked"

bigearsbilly 01-31-2007 06:06 AM

to yank a whole file

yG

edit
sorry assuming you are at line 1.

otherwise:

1GyG

culin 01-31-2007 06:36 AM

Thanks for all replies....:):)

eddiebaby1023 01-31-2007 11:12 AM

Quote:

Originally Posted by Mega Man X
... that will not work on vi, because vi does not have visual mode.

vi doesn't have visual mode? What do think "vi" is short for? Hint: "visual editor". Use the ex variant to disable visual mode.

Mega Man X 02-01-2007 02:01 AM

Quote:

Originally Posted by eddiebaby1023
vi doesn't have visual mode? What do think "vi" is short for? Hint: "visual editor". Use the ex variant to disable visual mode.

Did you actually understand what I was trying to say or did you just feel like explaining what "vi" means? Vi does not have a Visual Mode. Vim does. You enter Visual Mode when pressing the "v" key, when not on Command Mode, Insert or Append mode. This feature was added in VIM. You may have your vi editor symlinked to vim, as most distros do, so when you type "vi", you are actually using "vim".

I just started vi in my machine and pressed "v" and I get: "v isn't a vi command".


All times are GMT -5. The time now is 06:04 PM.