Open echristopherson opened 8 years ago
Thank you for reporting. I want to try cursor shape behavior but I'm poor at the terminal.
Please teach me what terminal emulator can be used and how to set t_Sl
and t_El
.
I'm really sorry for the delay.
I use iTerm 2 on OS X. In my vimrc I have:
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
tmux has its own escape codes for these; it translates them into something the real terminal emulator understands (if it understands any such code). For that case, I have:
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
There are other terminals (I think probably at least Konsole and GNOME Terminal) that support it, but the exact escape sequence varies somewhat.
The first of those is automatically sent by Vim when entering insert mode; the latter when leaving it. The quick shape changes I mention happen since your plugin leaves insert mode briefly when certain keys are pressed. I'm not sure there's much that can be done about it, honestly; even
In my own experiments, I discovered that adding <silent>
to the mapping of <space>
introduces this behavior. Remove the <silent>
and the cursor goes back to looking normal when you hit space bar (but then vim displays the function that gets called at the bottom).
Also, I only see this issue in vim 8.1-1790, not neovim 0.3.8, and not gvim.
(tested on linux with the following settings):
let &t_SI = "\e[6 q"
let &t_EI = "\e[2 q"
let &t_SR = "\e[3 q"
One workaround I've discovered is to :redraw
on the first line of the function invoked with <c-r>=
.
I don't know what :redraw
entails, but it sounds a bit inefficient.
demo code:
inoremap <silent> <space> <c-r>=Space()<cr>
fun! Space()
call s:HideVimCursorSpasm()
return ' '
endfun
fun! s:HideVimCursorSpasm()
if !has('nvim') && !has('gui_running') | redraw | end "hide cursor spasm that only occurs in vim
endfun
I don't think the aforementioned workaround works on iTerm in macos.
I think a better solution is to remove <silent>
from the mapping and just echo ''
at the beginning so it seems like it's a silent mapping.
I use t_SI and t_EI to change the shape of my cursor when entering insert or normal modes. I notice that with lexima active, the cursor shape changes perceptibly whenever I hit the space bar in insert mode. I assume lexima is entering and exiting normal mode behind the scenes. I don't know if it's feasible, but it would be nice if this didn't happen perceptibly.