Synchronized block mode insert

classic Classic list List threaded Threaded
3 messages Options
enk
Reply | Threaded
Open this post in threaded view
|

Synchronized block mode insert

enk

I've seen this in the Mac editor TextMate: Block mode insert inserts
the characters in all relevant lines _as you type_!

It's by no means an important feature, but would look spiffy. I
figured that when vim keeps different buffers for the same file
synchronized as you type, doing this with lines in the same buffer
would be possible.

Are we going to see this feature someday?

Regards,
Erik Wognsen

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Synchronized block mode insert

Andy Wokula

Erik Wognsen schrieb:

> I've seen this in the Mac editor TextMate: Block mode insert inserts
> the characters in all relevant lines _as you type_!
>
> It's by no means an important feature, but would look spiffy. I
> figured that when vim keeps different buffers for the same file
> synchronized as you type, doing this with lines in the same buffer
> would be possible.
>
> Are we going to see this feature someday?
>
> Regards,
> Erik Wognsen

here is something in Vim script
... basically the same as what worked for the "typewriter":
It's like doing  I{char}<Esc>  from Visual block mode for every
character typed in.


" start "synchronized Visual-block-insert mode" with v_gI :
xmap gI <Plug>sim

vmap <script> <Plug>sim I<SID>m_

imap <SID>m_<Esc> <Esc>
ino <silent> <SID>m_ <C-R>=TwGetchar()<CR>

func! TwGetchar()
    if getchar(1)
        let chr = s:getchar()
    else
        let chr = "."
    endif
    call feedkeys("\<Plug>sim")
    if chr == "\<BS>"
        return "\egvhohxgv"
    elseif chr == "\<C-U>"
        return "\egvhoh0xgv"
    else
        return chr. "\egvlol"
    endif
endfunc

func! s:getchar()
    let chr = getchar()
    if chr != 0
        let chr = nr2char(chr)
    endif
    return chr
endfunc


" many problems yet ... but no serious ones:

" TODO
" - restrict to Visual block mode
" - handle situation when cursor cannot move left
" - Visual block mode, more than one column selected, <BS> pressed: prevent
"   data loss
" - listen to 'backspace' option (let cursor not move left from Insert start
"   position)
" - don't insert dummy char when not pressing a char within 'timeoutlen'
" - check with 'selection' not at default
" - enable [count]gI
" - ...
" - much more
" - ...

--
Andy

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

enk
Reply | Threaded
Open this post in threaded view
|

Re: Synchronized block mode insert

enk

On Fri, May 22, 2009 at 22:52, Andy Wokula <[hidden email]> wrote:

>
> Erik Wognsen schrieb:
>> I've seen this in the Mac editor TextMate: Block mode insert inserts
>> the characters in all relevant lines _as you type_!
>>
>> It's by no means an important feature, but would look spiffy. I
>> figured that when vim keeps different buffers for the same file
>> synchronized as you type, doing this with lines in the same buffer
>> would be possible.
>>
>> Are we going to see this feature someday?
>>
>> Regards,
>> Erik Wognsen
>
> here is something in Vim script
> ... basically the same as what worked for the "typewriter":
> It's like doing  I{char}<Esc>  from Visual block mode for every
> character typed in.
>
>
> " start "synchronized Visual-block-insert mode" with v_gI :
> xmap gI <Plug>sim
>
> vmap <script> <Plug>sim I<SID>m_
>
> imap <SID>m_<Esc>       <Esc>
> ino <silent> <SID>m_    <C-R>=TwGetchar()<CR>
>
> func! TwGetchar()
>    if getchar(1)
>        let chr = s:getchar()
>    else
>        let chr = "."
>    endif
>    call feedkeys("\<Plug>sim")
>    if chr == "\<BS>"
>        return "\egvhohxgv"
>    elseif chr == "\<C-U>"
>        return "\egvhoh0xgv"
>    else
>        return chr. "\egvlol"
>    endif
> endfunc
>
> func! s:getchar()
>    let chr = getchar()
>    if chr != 0
>        let chr = nr2char(chr)
>    endif
>    return chr
> endfunc
>
>
> " many problems yet ... but no serious ones:
>
> " TODO
> " - restrict to Visual block mode
> " - handle situation when cursor cannot move left
> " - Visual block mode, more than one column selected, <BS> pressed: prevent
> "   data loss
> " - listen to 'backspace' option (let cursor not move left from Insert start
> "   position)
> " - don't insert dummy char when not pressing a char within 'timeoutlen'
> " - check with 'selection' not at default
> " - enable [count]gI
> " - ...
> " - much more
> " - ...

That's kinda cool. Do you think you could make it work with <C-W> ?

I tried ''' elseif chr == "\<C-W>" return "\egvhohbxgv" ''' but it
doesn't work properly..

Could be cool to have it built-in though :-)
(And have it work with block append as well..)

/Erik

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---