edit several files

26 views
Skip to first unread message

Mathieu Roux

unread,
Jul 6, 2019, 4:08:59 AM7/6/19
to vim...@googlegroups.com
Good morning,
I can read in help file usr_07.txt, that



"So far you had to start Vim for every file you wanted to edit. There
is a
simpler way. To start editing another file, use this command:

:edit foo.txt

You can use any file name instead of "foo.txt". Vim will close the
current
file and open the new one. If the current file has unsaved changes,
however,
Vim displays an error message and does not open the new file:

E37: No write since last change (use ! to override)"



On my laptop, it is not the same behaviour. The first file remains
open, and vim does not ask me anything to open the second file...

Can you help me?
Best regards,
Mathieu





Paul

unread,
Jul 6, 2019, 4:28:42 AM7/6/19
to vim...@googlegroups.com
On Sat, Jul 06, 2019 at 10:08:51AM +0200, Mathieu Roux wrote:
>On my laptop, it is not the same behaviour. The first file remains
>open, and vim does not ask me anything to open the second file...

Your laptop has 'hidden' set. See ":help 'hidden'".
signature.asc

Mathieu Roux

unread,
Jul 6, 2019, 4:44:32 AM7/6/19
to vim...@googlegroups.com
Ah yes, that is right.
Thank you very much.

In fact, i want to edit several files with vim, say titi and toto.
And then, i want to close titi and not toto, so that i can open titi in
another terminal. In fact, if i try to work with titi in another
terminal (with vi), it is said:


"E325: ATTENTION
Trouvé un fichier d'échange nommé ".titi.swp"
propriété de : m daté : Sat Jul 6 10:43:30 2019"

because it is already open...
> --

meine

unread,
Jul 6, 2019, 5:18:55 AM7/6/19
to vim...@googlegroups.com
On Sat, Jul 06, 2019 at 10:44:26AM +0200, Mathieu Roux wrote:
> Ah yes, that is right.
> Thank you very much.
>
> In fact, i want to edit several files with vim, say titi and toto.
> And then, i want to close titi and not toto, so that i can open titi in
> another terminal. In fact, if i try to work with titi in another
> terminal (with vi), it is said:
>
>
> "E325: ATTENTION
> Trouvé un fichier d'échange nommé ".titi.swp"
> propriété de : m daté : Sat Jul 6 10:43:30 2019"
>
> because it is already open...

when you open a second file with `e: <filename>', vim opens a new buffer
with the file in it.

you can list te opened files with `:ls', the file marked with % is de
one that is visible. to switch between files you can hit `:bnext' or
<ctrl>-^ to toggle between files. if `<leader> b' is set in your vimrc
(don't know, maybe it is default) you can see the list and switch by
choosing the other file.

when you want to open a file for a second time in another terminal
window, it warns you that the file is already opened -- the .swp
swap-file. editing a file that is already being edited can corrupt your
content. with `:bd' you can close a buffer the right way and the .swp
file belonging to it will be destroyed automatically.

basically there is no really a need to open a second terminal window
with a new instance of vim. keeping all together and switching buffers
permits copy-paste etc between files in a much easier way.

seeing two different files in one terminal window can be done with the
`:split' command

//meine

Mathieu Roux

unread,
Jul 6, 2019, 6:04:28 AM7/6/19
to vim...@googlegroups.com
Thank you very much.
Indeed, i don't know how i can do : <ctrl>-^
I use a french keyword. Is ^ the "hat" caractère which can be top of
letters: âêî???
> --

meine

unread,
Jul 6, 2019, 6:48:54 AM7/6/19
to vim...@googlegroups.com
On Sat, Jul 06, 2019 at 12:04:20PM +0200, Mathieu Roux wrote:
> Thank you very much.

:-)

> Indeed, i don't know how i can do : <ctrl>-^
> I use a french keyword. Is ^ the "hat" caractère which can be top of
> letters: âêî???

yes, it is the `caret'

`<right-Alt> 9' should give a ^ on an azerty keyboard

on querty keyboards it is `<shift> 6'

//meine

Mathieu Roux

unread,
Jul 7, 2019, 1:46:22 PM7/7/19
to vim...@googlegroups.com
Perfect!

thank you again!
> --

Reply all
Reply to author
Forward
0 new messages