On 17/04/11 01:50, AK wrote:
Hi, I needed to make a mapping that would insert a bullet if '*' is
typed at the beginning of line and insert literal '*' if typed somewhere
else. I came up with something that works for me, but I
was wondering if there's a shorter / better way to do this.. Here's
what I have:

inoremap * x<bs><c-o>:Bul<CR>
command! Bul call Potl("bullet") | normal 3l

Where Potl("bullet") is a python vim function that checks current
line and where the cursor is, and either inserts '*' or '•' character.
I'm not including it because the question is whether there's a way
to do this with a single mapping, without a command, or with a mapping
and a one-line command, without a function?

Thanks! -Rainyday


(untested)

        :inoremap <expr> * col('.') < 2 ? "\u25CF" : "*"

see
        :help map-expression
        :help expr1
        :help col()

For the first _nonblank_ you can of course use a more complex condition before the question mark. Also use a different bullet if ● doesn't suit you.


Best regards,
Tony.
--
According to the obituary notices, a mean and unimportant person never
dies.

--
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

Reply via email to