'ed' and 'split' with read-only enabled

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

'ed' and 'split' with read-only enabled

Woody Wu
Hi, List

How can I open a file in current buffer using 'ed' and 'split' but with
read-only enabled in the same time?  One reason why I want this is,
sometimes when I've already open a file in another vim instance and
don't want to close it, then I need to temparaly open the same file in
current vim instance to copy something from the file.  Then when I do
the 'split myfile' in the current buffer, I will alwasy got a warning
and prompt me to open it in read-only mode. So I want to directly open
it in read-only mode to git rid of the boring red warning message.


Thanks in advance.

--
I can't go back to yesterday - because I was a different person then

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: 'ed' and 'split' with read-only enabled

Étienne Faure
On Mon, Jul 15, 2013 at 3:33 PM, Woody Wu <[hidden email]> wrote:
Hi, List

How can I open a file in current buffer using 'ed' and 'split' but with
read-only enabled in the same time?

You can invoke vim as "view" instead of "vim" on the command line: "view" is vim in readonly mode.
 

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
 
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: 'ed' and 'split' with read-only enabled

Woody Wu
On Mon, Jul 15, 2013 at 03:57:54PM +0200, ?tienne Faure wrote:

> On Mon, Jul 15, 2013 at 3:33 PM, Woody Wu <[hidden email]> wrote:
>
> > Hi, List
> >
> > How can I open a file in current buffer using 'ed' and 'split' but with
> > read-only enabled in the same time?
>
>
> You can invoke vim as "view" instead of "vim" on the command line: "view"
> is vim in readonly mode.

I was editing a file, then want to view another file. If using 'view' I
have to firstly exit the current vim.

--
I can't go back to yesterday - because I was a different person then

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: 'ed' and 'split' with read-only enabled

Étienne Faure
On Mon, Jul 15, 2013 at 4:06 PM, Woody Wu <[hidden email]> wrote:
On Mon, Jul 15, 2013 at 03:57:54PM +0200, ?tienne Faure wrote:
> On Mon, Jul 15, 2013 at 3:33 PM, Woody Wu <[hidden email]> wrote:
>
> > Hi, List
> >
> > How can I open a file in current buffer using 'ed' and 'split' but with
> > read-only enabled in the same time?
>
>
> You can invoke vim as "view" instead of "vim" on the command line: "view"
> is vim in readonly mode.

I was editing a file, then want to view another file. If using 'view' I
have to firstly exit the current vim.

Then you can use :view instead of :ed

he :view 

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
 
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: 'ed' and 'split' with read-only enabled

Karthick Gururaj
In reply to this post by Woody Wu
On Mon, Jul 15, 2013 at 7:03 PM, Woody Wu <[hidden email]> wrote:

> sometimes when I've already open a file in another vim instance and
> don't want to close it, then I need to temparaly open the same file in
> current vim instance to copy something from the file.  Then when I do
> the 'split myfile' in the current buffer, I will alwasy got a warning
> and prompt me to open it in read-only mode. So I want to directly open
> it in read-only mode to git rid of the boring red warning message.

http://vim.wikia.com/wiki/Open_same_file_read-only_in_second_Vim

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: 'ed' and 'split' with read-only enabled

Gary Johnson-4
In reply to this post by Woody Wu
On 2013-07-15, Woody Wu wrote:

> Hi, List
>
> How can I open a file in current buffer using 'ed' and 'split' but with
> read-only enabled in the same time?  One reason why I want this is,
> sometimes when I've already open a file in another vim instance and
> don't want to close it, then I need to temparaly open the same file in
> current vim instance to copy something from the file.  Then when I do
> the 'split myfile' in the current buffer, I will alwasy got a warning
> and prompt me to open it in read-only mode. So I want to directly open
> it in read-only mode to git rid of the boring red warning message.

If you want to continue to use the :split command, the swapExists
autocommand event can be used to detect the warning condition and
the v:swapchoice variable set to specify the desired action, e.g.,

    autocmd SwapExists * let v:swapchoice='o'

Or you could just open the file using the :sview command which is
the same as using :split but also sets 'readonly' in the new buffer.
See

    :help SwapExists
    :help v:swapchoice
    :help :sview

Regards,
Gary

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: 'ed' and 'split' with read-only enabled

Woody Wu
On Mon, Jul 15, 2013 at 07:41:30AM -0700, Gary Johnson wrote:

> On 2013-07-15, Woody Wu wrote:
> > Hi, List
> >
> > How can I open a file in current buffer using 'ed' and 'split' but with
> > read-only enabled in the same time?  One reason why I want this is,
> > sometimes when I've already open a file in another vim instance and
> > don't want to close it, then I need to temparaly open the same file in
> > current vim instance to copy something from the file.  Then when I do
> > the 'split myfile' in the current buffer, I will alwasy got a warning
> > and prompt me to open it in read-only mode. So I want to directly open
> > it in read-only mode to git rid of the boring red warning message.
>
> If you want to continue to use the :split command, the swapExists
> autocommand event can be used to detect the warning condition and
> the v:swapchoice variable set to specify the desired action, e.g.,
>
>     autocmd SwapExists * let v:swapchoice='o'
>
> Or you could just open the file using the :sview command which is
> the same as using :split but also sets 'readonly' in the new buffer.
> See
>
>     :help SwapExists
>     :help v:swapchoice
>     :help :sview
>

Many thanks Gary, these are really tips I am looking for!

> Regards,
> Gary
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/groups/opt_out.
>

--
I can't go back to yesterday - because I was a different person then

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: 'ed' and 'split' with read-only enabled

Woody Wu
In reply to this post by Karthick Gururaj
On Mon, Jul 15, 2013 at 07:52:59PM +0530, Karthick Gururaj wrote:

> On Mon, Jul 15, 2013 at 7:03 PM, Woody Wu <[hidden email]> wrote:
>
> > sometimes when I've already open a file in another vim instance and
> > don't want to close it, then I need to temparaly open the same file in
> > current vim instance to copy something from the file.  Then when I do
> > the 'split myfile' in the current buffer, I will alwasy got a warning
> > and prompt me to open it in read-only mode. So I want to directly open
> > it in read-only mode to git rid of the boring red warning message.
>
> http://vim.wikia.com/wiki/Open_same_file_read-only_in_second_Vim
>

Many thanks.  At this moment, my google network looks has a problem so
that I cannot open the vim wikia page. I will try later. The name looks
very close to what I want.

> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/groups/opt_out.
>

--
I can't go back to yesterday - because I was a different person then

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.