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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to