Tuesday, June 25, 2013

Re: compatibility with Sun's original vi for command :su

On 25/06/13 10:01, Matteo Cavalleri wrote:
> Il giorno lunedì 24 giugno 2013 23:54:43 UTC+2, Paul Maier ha scritto:
>
>> the original vi on Sun took :su as :suspend,
>>
>> whereas vim takes :su as :substitute.
>
> what does ":su" do? it's the same as pressing CTRL-z or typing ":sh"?
>
Matteo: see :help :suspend

Paul: Either use Salman's cabbrev trick (more later) or use :st instead
(for :stop which in Vim is a synonym for :suspend).

A more involved cabbrev trick for your vimrc:

if version < 700
cnoreabbrev su suspend
else
cnoreabbrev <expr> su
\ ((getcmdtype() == ':' && getcmdpos() <= 3)? 'suspend' : 'su')
endif


The above assumes 'nocompatible' (otherwise, you can still use it, but
the long cnoreabbrev <expr> line must be typed all on one line with no
line continuation) and determines at run-time whether the "finer"
version of the mapping (with getcmdtype() and getcmdpos()) can be used
or not.

I intentionally use "version" rather than "v:version" because it is more
backward-compatible.


Best regards,
Tony.
--
Without ice cream life and fame are meaningless.

--
--
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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: