jszakmeister / vim-togglecursor Goto Github PK
View Code? Open in Web Editor NEWToggle the cursor shape in the terminal for Vim.
Home Page: http://www.vim.org/scripts/script.php?script_id=4403
Toggle the cursor shape in the terminal for Vim.
Home Page: http://www.vim.org/scripts/script.php?script_id=4403
Recently I find that after exiting Vim, my mouse is still a pointer instead of the I beam, indicating that the program inside the terminal is controlling the mouse.
Uninstalling this plugin things are back to normal. My tmux is version 2.8 and I only notice this recently. My Vim is the latest and my terminal is xfce4-terminal.
As of neovim 0.2+ $NVIM_TUI_ENABLE_CURSOR_SHAPE
is removed: https://github.com/neovim/neovim/wiki/Following-HEAD#20170402
A new way to control cursor shape through guicursor is recommended: https://github.com/neovim/neovim/wiki/FAQ#how-to-change-cursor-shape-in-the-terminal
Hi, I am not sure if it's just me, but this plugin does not work when I am inside a TMUX session.
Is there a way to make it work?
My specs: Ubuntu 14.04, XTerm, Tmux 1.8
Thank You
After trying all the random configuration snippets floating around the internet this plugin just worked™.
Thank you for making and releasing it 😄
Hi,
I'm using your plugin with Vim (Version 8.0) in Gnome TrueColor terminal and it works fine.
Under Tmux (version 2.6 since today!) however, the behaviour is not correct:
Hi,
Can we add pangoterm to the terminal checks as it supports the feature.
Ta
health#nvim#check
========================================================================
## Configuration
- WARNING: $NVIM_TUI_ENABLE_CURSOR_SHAPE is ignored in Nvim 0.2+
- ADVICE:
- Use the 'guicursor' option to configure cursor shape. :help 'guicursor'
- https://github.com/neovim/neovim/wiki/Following-HEAD#20170402```
My VIM is inside a vagrant (virtual box) with linux OS having VIM 8.0.134
The cursor is not changing when I change the modes in it.
I think since this plugin depends on what type of terminal it is, it mightn't be able to detect it.
When I run sudo vim
, the plugin does not work (cursor does not change shape). How can I overcome this problem?
Hi
I just checked with vim:
guake does nothing (OK - the old libvte)
guake with tmux does nothing (Ok too)
konsole - works
konsole under tmux - works
urxvt (rxvt-unicode 9.21) - works
urxvt under tmux does not work (nothing happens).
xterm (297 version) works
xterm under tmux does not work.
I believe that your plugin checks for $KONSOLE_DBUS_SESSION but it does not check for the real terminal emulator under a tmux session. I do not know is it possible at all. Quick search on google didn't help.
Hi,
I'm quite new with vim and programming but this plugin is very helpful.
The problem is that when I use GNU's screen - it doesn't work. Maybe you have a solution?
Thanks!
AsaF
I'm using Konsole on Kubuntu with GNU Screen and this plugin doesn't seem to work with it. I know the documentation mentions issues with Tmux, so I was wondering if the same issue exists in Screen.
Should I just switch to Tmux or do you think this issue is solvable in Screen?
PS: Great job on the plugin. Really digging it.
As by default only, this plugin doenst cause any effects on vim running in Alacritty.
I've changed vim rc to include the 'togglecursor_force' variable, and still nothing comes out.
if match($TERM, 'xterm') == 0
let g:togglecursor_force = 'xterm'
endif
I couldn't find much support in general google search. I would appretiate if someone else could help me out.
My $TERM variable currently is xterm-256colors
I have installed this plugin via vundle, but it seems doesn't work at all.
my terminal-version is gnome-terminal-3.14.2
@jszakmeister Just thought I would bump that feature, because I'm very interested in it.
I want a blinking line cursor in insert mode and a blinking underline cursor in replace mode.
I would like to reproduce my cursor settings for when I use GUIs:
https://github.com/Greduan/dotfiles/blob/ae350bbdf40e9ac727a0ebb8f57fb89d58054145/vim/gvimrc.vim#L27-L38
vim-togglecursor
overwites t_SI
and t_EI
preventing other settings from being applied (i.e. as shown in https://coderwall.com/p/if9mda/automatically-set-paste-mode-in-vim-when-pasting-in-insert-mode).
Patch to allow additional, external settings to be supplied as option variables:
From 41e441f9d9305448b5cf48421f6b5b723b287a26 Mon Sep 17 00:00:00 2001
From: James Goodall
Date: Fri, 6 Aug 2021 13:58:47 -0700
Subject: [PATCH] Allow existing values of t_SI, t_EI to be preserved
---
plugin/togglecursor.vim | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/plugin/togglecursor.vim b/plugin/togglecursor.vim
index 07cbdfb..8824642 100644
--- a/plugin/togglecursor.vim
+++ b/plugin/togglecursor.vim
@@ -136,6 +136,14 @@ if !exists("g:togglecursor_disable_tmux")
let g:togglecursor_disable_tmux = 0
endif
+if !exists("g:togglecursor_t_SI_external")
+ let g:togglecursor_t_SI_external = ''
+endif
+
+if !exists("g:togglecursor_t_EI_external")
+ let g:togglecursor_t_SI_external = ''
+endif
+
" -------------------------------------------------------------
" Functions
" -------------------------------------------------------------
@@ -173,8 +181,8 @@ function! s:ToggleCursorInit()
return
endif
- let &t_EI = s:GetEscapeCode(g:togglecursor_default)
- let &t_SI = s:GetEscapeCode(g:togglecursor_insert)
+ let &t_EI = s:GetEscapeCode(g:togglecursor_default) . g:togglecursor_t_EI_external
+ let &t_SI = g:togglecursor_t_SI_external . s:GetEscapeCode(g:togglecursor_insert)
if s:sr_supported
let &t_SR = s:GetEscapeCode(g:togglecursor_replace)
endif
@@ -189,10 +197,10 @@ endfunction
function! s:ToggleCursorByMode()
if v:insertmode == 'r' || v:insertmode == 'v'
- let &t_SI = s:GetEscapeCode(g:togglecursor_replace)
+ let &t_SI = g:togglecursor_t_SI_external . s:GetEscapeCode(g:togglecursor_insert)
else
" Default to the insert mode cursor.
- let &t_SI = s:GetEscapeCode(g:togglecursor_insert)
+ let &t_SI = g:togglecursor_t_SI_external . s:GetEscapeCode(g:togglecursor_insert)
endif
endfunction
--
1.8.3.1
First of all, thanks a lot for the plugin! It works great so far.
Until now I defined the shapes manually in my .vimrc, but this plugin comes in handy.
I found out recently when using
autocmd VimLeave * let &t_me="\<Esc>]50;CursorShape=1\x7"
I can revert the cursor to its initial shape before entering vim.
Would be great to see this in your plugin.
Cheers
Using backspace in insert mode causes flicker, see the gif:
$ echo $TERM
screen-256color
$ vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 1 2014 20:27:42)
MacOS X (unix) version
Included patches: 1-488
Compiled by Homebrew
Huge version without GUI. Features included (+) or not (-):
+acl +farsi +mouse_netterm +syntax
+arabic +file_in_path +mouse_sgr +tag_binary
+autocmd +find_in_path -mouse_sysmouse +tag_old_static
-balloon_eval +float +mouse_urxvt -tag_any_white
-browse +folding +mouse_xterm -tcl
++builtin_terms -footer +multi_byte +terminfo
+byte_offset +fork() +multi_lang +termresponse
+cindent -gettext -mzscheme +textobjects
-clientserver -hangul_input +netbeans_intg +title
+clipboard +iconv +path_extra -toolbar
+cmdline_compl +insert_expand +perl +user_commands
+cmdline_hist +jumplist +persistent_undo +vertsplit
+cmdline_info +keymap +postscript +virtualedit
+comments +langmap +printer +visual
+conceal +libcall +profile +visualextra
+cryptv +linebreak +python +viminfo
+cscope +lispindent -python3 +vreplace
+cursorbind +listcmds +quickfix +wildignore
+cursorshape +localmap +reltime +wildmenu
+dialog_con -lua +rightleft +windows
+diff +menu +ruby +writebackup
+digraphs +mksession +scrollbind -X11
-dnd +modify_fname +signs -xfontset
-ebcdic +mouse +smartindent -xim
+emacs_tags -mouseshape -sniff -xsmp
+eval +mouse_dec +startuptime -xterm_clipboard
+ex_extra -mouse_gpm +statusline -xterm_save
+extra_search -mouse_jsbterm -sun_workshop -xpm
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/local/share/vim"
Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H -F/usr/local/Frameworks -DMACOS_X_UNIX -Os -w -pipe -march=native -mmacosx-version-min=10.10 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: /usr/bin/clang -L. -L/Users/jottr/.rbenv/versions/2.0.0-p247/lib -fstack-protector -L/usr/local/lib -L/usr/local/lib -F/usr/local/Frameworks -Wl,-headerpad_max_install_names -o vim -lm -lncurses -liconv -framework Cocoa -fstack-protector -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -framework Python -lruby-static -lobjc -L/Users/jottr/.rbenv/versions/2.0.0-p247/lib
I noticed that whilst in Insert mode and switching to another pane in tmux that my cursor didn't preserve its normal block state. I'm opening this issue to gauge interest in a patch that'd fix this.
First of all thanks for this great plugin.
On urxvt I don't encounter this problem, however on Konsole, whenever I change the font size (using Ctrl- Or Ctrl+), the font size is reset whenever the cursor changes.
My config is simple:
let g:togglecursor_default = "block"
let g:togglecursor_insert = "line"
let g:togglecursor_leave = "block"
let g:togglecursor_replace = "underline"
Any idea? Thanks again!
I'm using gnome-terminal inside tmux (I ended up manually setting s:supported_terminal to 'xterm') and when I enter insert mode my mouse cursor appears as the text cursor changes to a vertical bar. When I return to normal mode and begin to navigate, my mouse cursor disappears. When using vim I would prefer my mouse to remain hidden at all times unless I move it, so this is a bit distracting. Why is it appearing and how can I keep it hidden?
For some reasons my cursor keeps disappearing if I open a file in Vim (using vim /path/to/file
command) inside gnome-terminal with tmux and powerline. When I change my mouse focus from gnome-terminal to another window (I am using Vim under terminal), OR replace vim-togglecursor
with this snippet of Vimscript inside my .vimrc
:
" Toggle cursor between block and ibeam shape in different modes (Insert,
" Normal, Visual, Replace. Also make them blink.
function! ToggleCursorByMode()
if exists('$TMUX')
if v:insertmode == 'r' || v:insertmode == 'v'
let &t_SI = "\<Esc>Ptmux;\<Esc>\e[3 q\<Esc>\\"
else
let &t_SI = "\<Esc>Ptmux;\<Esc>\e[5 q\<Esc>\\"
endif
let &t_EI = "\<Esc>Ptmux;\<Esc>\e[0 q\<Esc>\\"
else
if v:insertmode == 'r' || v:insertmode == 'v'
let &t_SI = "\e[3 q"
else
let &t_SI = "\e[5 q"
endif
let &t_EI = "\e[0 q"
endif
endfunction
call ToggleCursorByMode()
augroup AutoCursor
autocmd InsertEnter * :call ToggleCursorByMode()
autogroup END
Everything was working as expected. Without the above snippet of codes, sometimes even during cursor moving in Normal mode, my cursor disapearred and I had to move the mouse focus to another window beside gnome-terminal again and then move back.
I believe there is currently a problem of autocmd VimEnter *
statement in plugin/togglecursor.vim
unable to load <SID>ToggleCursorInit()
at Vim startup, because as long as I replaced vim-togglecursor
with the above code, OR tried to move focus to another window (which triggered FocusGained
& FocusLost
), the cursor started working again. So I guess you may want to add an autocmd BufWinEnter *
OR invoking ToggleCursorInit() outside of autocmd (so it will be run when Vim sources the .vimrc
file).
Here is my version information:
OS: Arch Linux
Shell: zsh 5.0.8
Multiplexor: tmux 2.0
Vim: VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jul 11 2015 08:44:54)
Included patches: 1-778
GNOME: Version 3.16.2
Hi,
When quitting Insert Mode with ESC and hitting 'r' to replace one character, the cursor is rendered as a vertical line, not an underline.
Thanks for this plugin.
xfce4-terminal
doesn't support DECSCUSR
.
Even so, the plugin seems to think it does.
Entering insert mode in nvim I get this: -- INSERT --�[5 q
could you add cursor color config ?
not just shape ..
Thanks
when i use putty , it doesn't work ..
xterm supports a blinking I-beam cursor--no need to use an underscore.
https://github.com/saamalik/dotvim/blob/master/init/xterm.vim
The latest version of urxvt (9.21 - 31/12/2014) added the DECSCUSR xterm extension to set the cursor to a vertical bar.
See http://dist.schmorp.de/rxvt-unicode/Changes
So it would be nice if urxvt could be whitelisted somehow.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.