Monday, September 29, 2014

Re: command-line commands instead of abbreviations?

On Mon, 29 Sep 2014 08:17:44 -0700 (PDT)
Ben Fritz <fritzophrenic@gmail.com> wrote:

> On Monday, September 29, 2014 1:21:57 AM UTC-5, gevisz wrote:
> >
> > So, Vim does not fully support utf-8 and thus using commands
> > instead of abbreviations is not an option for me.
>
> But abbreviations don't work in normal mode anyway
> which is where you wanted to use your command.

Yes, I would prefer them to work from the insert mode but
I do not mind pressing one more button before starting
my mappings/abbreviations/commands.

For example, I could map <F9> to <Esc>: and use execute with
the normal command and startinsert command at the end.

That way the command could be working just as mapping with only
one extra stroke. Even better!

But not in case if I type in cyrillic. :(

In that case I should switch the keyboard two times, not
counting the inconvenience of transliterating my abbreviation
in roman letters.

So, it is really not the option.

> > > You could use a mapping instead of a command pretty easily.
> >
> > Not so easy as one can think as
> >
> > 1. I just cannot type mapping quick enough for it to work if
> > 1) the mapping is more than 4 characters long,
> > 2) I use it not very often and thus stop in the middle
> > of it to recall the next character.
>
> You could set your 'timeoutlen' to be longer if you like.

The problem is that I do not like to wait too long when I use
shorter mappings...

But, well, I may try to experiment with this...

> > 2. I cannot use for mappings such combination of letters
> > that can be encountered in usual text. That results in
> > a longer and harder to remember mappings and the latter
> > magnifies the reason 1 above.
>
> In normal mode, where you wanted to create your command,
> you will never be inserting text. So this reason doesn't
> apply.

As I have already explained it, I would prefer to do it
in insert mode but do not mind doing one extra stroke...

But if you mean that in the normal mode I am not constrained
with the situation described under item 2, it is not true
as I use set langmap in my .vimrc that, for example, maps
cyrillic letter "В" to "D", and so, any mapping starting
with cyrillic letter "В" could be very dangerous.

> > As to abbreviations, they have their own limitations.
> >
> > First of all, they cannot contain cyrillic letter "р"
> > at least in utf-8 encoding and at least for now. (Well,
> > actually they can but in this case they just do not
> > expand.)
>
> That is a bug. It will be fixed.

I hope so, but nobody have promised that. :(

And even if it will be done, it will take about half
a year to go to my Linux distribution, I think.

Well, I know that I can compile it myself.
Actually, I do. :) But only from the sources
tested and provided by my Linux distribution.

> > Second, they do not expand if typed just after other
> > letter characters.
>
> By this, do you mean that your abbreviation must have
> whitespace preceding? Or something else?

Not only mine but all. And not exactly whitespace but
any word-separating symbol. And even that is not exactly
true.

The true statement is like this: the last stroke before the
start of the abbreviation should not be insertion of any other
letter or number because otherwise the abbreviation will not
expand. (And that is their difference comparing to mappings.)

> > > Does it need to be a command?
> >
> > Yes, this alternative to mappings and abbreviations
> > would be very attractive (if they can work with
> > cyrillic command names, of course) as in addition
> > they could use arguments, for example, to insert
> > some changeable numbers in the middle of a
> > non-changeable text.
>
> That could also be accomplished with a mapping, using getchar() or
> input() or something within the mapping.

Thank you for the hint. I will look into it.

> Especially if you use an <expr> mapping.

I do not know/understand what you mean but will try to find out.
Thank you.

> But all in all...it sounds like maybe you need a snippet plugin
> of some sort. Do a web search, there are several.

I do not believe that somebody had the same needs but, yes, I may try.

> As a different approach, maybe you can look into using insert-mode
> completion instead of mappings or abbreviations. If you're only
> completing single words (separated by "non-keyword" characters) then
> you could potentially use dictionary completion (:help
> 'dictionary', :help compl-dictionary). If you have phrases also to
> complete, then you can define a user-completion (:help
> compl-function) or omni-completion (:help compl-omni) function to
> insert whatever you want based on whatever input you want. If you
> have several similar entries, you can see them all in a list. You
> could even parse "arguments" of sorts in your completion function for
> text that can change.

Another suggestion I may consider. Thank you.


--
--
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/d/optout.

No comments: