Hi,
Duddy67 schrieb am 05.02.2015 um 09:55:
>
> In my vimrc file I put the following code in order to change the cursor
> shape:
>
> if &term =~ "xterm"
> " blinking vertical bar
> let &t_SI .= "\<Esc>[5 q"
> " blinking block
> let &t_EI .= "\<Esc>[1 q"
> endif
>
> It works great but now I'd like to take it further and change also the
> cursor shape (blinking underscore) whenever the overtype mode is used (r and
> R keys). How could I achieve this ?
there is an InsertEnter autocommand which is triggered just before
Insert mode, Replace mode, or Virtual Replace mode starts. The actual
mode is indicated by the v:insertmode variable which contains 'i', 'r',
or 'v', respectively.
I can't test this due to lack of access to a real terminal, but
if &term =~ "xterm"
autocmd InsertEnter *
\ if v:insertmode == 'i'
\ " blinking vertical bar
\ let &t_SI = "\<Esc>[5 q"
\ elseif v:insertmode == 'r' || v:insertmode == 'v'
\ " blinking underscore
\ let &t_SI = "<Switch Cursor to Underscore Here>"
\ endif
" blinking block
let &t_EI .= "\<Esc>[1 q"
endif
should get you somewhere.
Note that I removed the dot from the assignments to t_SI. Otherwise the
terminal sequence would grow whenever you enter Insert or Replace mode.
If t_SI is really initialized with some value that you want to append
to, you will have to remove the part that was appended in previous
invocations of the InsertEnter autocommand -- or save the original value
of t_SI before you define the autocommand and rebuild the complete
sequence every time from the stored value and the sequence used above.
The InsertEnter autocommand is not triggered when replacing single
characters with <r>, but you can always use a mapping:
nnoremap r :let &t_SI = "<Switch Cursor to Underscore Here>"<cr>r
Regards,
Jürgen
--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)
--
--
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.
Friday, February 6, 2015
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment