On 22/04/11 22:03, sc wrote:
On Friday, April 22, 2011 13:55:07 andy richer wrote:
Hi vim guru,
I want to use vim build in "sort" command, and I want to use
sort i every time.
Please advise me how to set an alias that I type sort and
vim treats it as sort i
unix command has: alias sort " sort i", but not work in vim.
in vim we call them abbreviations, and we have several classes
of them -- the one you are looking for is the commandline
abbreviation, since that is where you will be using it
if you put
cabbrev sort sort i
in your ~/.vimrc i believe it will do as you wish
sc
It will... until you decide to search on "sort", type
/sort
and then find out that it has become
/sort i
Similarly,
:echo 'This will not sort correctly'
might become
:echo 'This will not sort i correctly'
The idea is to test for the kind of command line and for the abscissa
within it:
cnoreabbrev <expr> sort
\ ((getcmdtype() == ':' && getcmdpos() <= 5)? 'sort i' : 'sort')
(I have a similar abbrev to replace :h by :bot h )
Best regards,
Tony.
--
"I found out why my car was humming. It had forgotten the words."
--
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