On Sun, May 13, 2012 at 9:37 PM, Tim Chase <[email protected]> wrote:
> On 05/13/12 10:58, Dotan Cohen wrote:
>> I have a few of these wonderful helpers:
>> inoremap foreach<Return> foreach (<Space><Space>)<Return>{<Return><R
>>  eturn>}<Esc>3kA<Left><Left>
>>
>> I know that there is a snippets plugin, but I like this roll-my-own
>> solution for a number of reasons (one of which is to learn Vim).
>> However, one problem that I have is that the text f-o-r-e-a-c-h is not
>> shown until I get to the end of the map. Is there any way to configure
>> VIM to show the text normally, until it decides that there will be a
>> replacement? This is driving me crazy.
>
> You might try it with an abbreviation instead:
>
> :iab foreach foreach(<space>)<cr>{<cr><cr>}<up><up><up><end><left><left>
>
> which allows you to see it as you type it (also expands on <space>
> which I prefer over <enter>).
>
> Setting 'showcmd' doesn't quite do it (it shows each letter
> in-place), but it's not a bad followup solution.
>

Thanks, Tim. I did not know about iab, thank you. There are a few caveats:

1) I have one foreach that expands on space to give:
foreach ( | )
And another which expands on return to give:
foreach ( | )
{

}

I can live with having just the latter and having it expand on space,
but it is a drawback so I mention it.



2) The iab abbreviations add a space after the mapping, which is
precludes many combinations such as if I want to leave the cursor
between two parentheses.


3) The iab abbreviations will not work in the general case for
remapping handy things which do not end in a space, such as these:
inoremap ii <Esc>
inoremap kk <Esc>A
"Go back to between the last {} [] <> () "" '' or ><
inoremap hh 
<c-o>?\%<c-r>=line('.')<Return>l\({}\\|\[]\\|<>\\|><\\|()\\|""\\|''\\|
   ><lt>\)?s+1<Return>
inoremap ;; <Esc>A;<Return>
"For adding another method argument while inside quotes
inoremap ,, <Right>,<Space>
"For adding => while inside quotes (PHP associative arrays)
inoremap ,,j <Right><Space>=><Space>

In all these cases the user is stuck watching a cursor that does not
move according to his typing.



I know the reasons behind not showing the text (the text might never
be entered into the buffer). However, the feedback of seeing the text,
even if it is not intended for being added to the buffer, is very
important. In any case, by far _most_ of the leading characters are
used outside the mappings, so it is the common case that is being made
annoying for the sake of the uncommon case. If need be, I would prefer
that the text be added to the buffer and then removed if it matches a
map.

Is there any way to accomplish this?

Thank you!

-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

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