|
Grex > Agora56 > #122: How to edit another file without save the current file in vi? | |
|
| Author |
Message |
lyun
|
|
How to edit another file without save the current file in vi?
|
Feb 23 09:57 UTC 2006 |
when editing a file using vi editer, i wanna open another file without
saving the current one. How can i do it? please tell me.
|
| 59 responses total. |
tod
|
|
response 1 of 59:
|
Feb 23 11:51 UTC 2006 |
ctrl-z
vi
|
lyun
|
|
response 2 of 59:
|
Feb 23 11:54 UTC 2006 |
i mean is there any command that can open another file while editing a
file
|
kingjon
|
|
response 3 of 59:
|
Feb 23 11:57 UTC 2006 |
:e
Of course, that will discard your changes to the original.
|
lyun
|
|
response 4 of 59:
|
Feb 23 12:02 UTC 2006 |
i also donot wanna discard my changes, i will be back to this file
soon and resume my edit of this file
|
kingjon
|
|
response 5 of 59:
|
Feb 23 12:05 UTC 2006 |
I don't think it's possible, then. In vim you can open a new window (splitting
your screen), but if you change files you have to either save or discard
changes.
|
lyun
|
|
response 6 of 59:
|
Feb 23 12:15 UTC 2006 |
think of this case, you have numerous C source files, and you have
perform the following command to them: ctags *.c
then you place your cursor on a variable, press ^] to jump to the
definition(in another file) of it, vi does it, but not closing the
foregoing file
|
remmers
|
|
response 7 of 59:
|
Feb 23 13:53 UTC 2006 |
My thought is that vi is not the best editor for doing what you want to
do. Suggestion: Use emacs, which has an excellent ctags interface and
allows you to jump back and forth between open files without saving.
Emacs also has a very good vi emulation mode if you're more comfortable
with vi's editing commands.
"Always use the right tool for the job." -Mr. Natural
|
jep
|
|
response 8 of 59:
|
Feb 23 14:04 UTC 2006 |
In vi, you can specify two files on the command line with a command
like:
vi file1 file2
This command will load file1. If you type
:n
it will load file2
At this point, you can switch between the two files with the command:
CTRL-^
(that is, your CONTROL key and the caret or shift-6 character)
If you run the command:
vi file*
and then use :n to edit the various files, the most recent two which
were accessed will be accessible using CTRL-^.
You can also load a 2nd file with the command:
:e
and then move between your original file and the 2nd file using CTRL-^.
|
fudge
|
|
response 9 of 59:
|
Feb 23 14:04 UTC 2006 |
you just have to study it for 3 years before you learn how to cut, paste and
save...
|
remmers
|
|
response 10 of 59:
|
Feb 23 14:20 UTC 2006 |
Re #8: That method also appears to make you save the file before
editing the next one, which is what lyun said he doesn't want to do.
|
fudge
|
|
response 11 of 59:
|
Feb 23 14:22 UTC 2006 |
re#9 [emacs that is]
|
lyun
|
|
response 12 of 59:
|
Feb 23 14:45 UTC 2006 |
Re #8: Will using command :e to open another file close my current
file?
|
remmers
|
|
response 13 of 59:
|
Feb 23 14:48 UTC 2006 |
I actually find it easier to remember how to cut, paste, and save in
emacs than in vi. X Window versions of emacs will actually let you do
all that with the mouse in the standard ways.
|