Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How can I make Vim change cursor in different modes so that these conditions are satisfied:

  1. Without using gconftool or such tools. I need this affect only one instance of Vim, not the whole terminal.
  2. This must be working in Gnome Terminal and GVim.

I have tried changing with sample in help gcr, but it only works for GVim, and not Vim in Gnome terminal.

I have tested http://vim.wikia.com/wiki/Change_cursor_shape_in_different_modes, but it changed the cursor for the whole terminal.

Playing with gcr is preferred.

Edit: I know that gcr is only for GUI mode, but I mean some kind of functionality like that inside of vim. May be with some kind of plugin ...

share|improve this question
    
gcr will not satisfy your requirements, since this is for, as its name states(guicursor), a GUI. Did you read the vim help file for gcr? It clearly states: "only available when compiled with GUI enabled, and for MS-DOS and Win32 console" –  Kevin Bowen Mar 8 '13 at 8:51
    
Yeah, of course it is for GUI, And that's why I asked for help! –  Mostafa Shahverdy Mar 8 '13 at 15:02
add comment

1 Answer 1

You won't be able to change it in gnome-terminal as it derives it's cursor settings using gconf and vim is unable to override this.

However, this is what I have in my .vimrc file, using gconf and it works as intended i.e. resets it to what is was before (cursor_shape block). You should be able to use gcr to set the cursor in gvim independently.

" for gnome-terminal
au InsertEnter * silent execute "!gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/cursor_shape underline"
au InsertLeave * silent execute "!gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/cursor_shape block"
au VimLeave * silent execute "!gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/cursor_shape block"
au VimEnter * silent execute "!gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/cursor_shape block"
share|improve this answer
    
This is wrong. This will affect other instances of VIM and gnome-terminal itself. If I kill my VIM suddenly, then the cursor won't change back to its normal. The worst thing is that If I open more than one instance of VIM in different modes, all will be cluttered! –  Mostafa Shahverdy Mar 10 '13 at 3:26
    
This is actually a nice feature. I prefer to have the cursor always the block shape and the same for the terminal. (Nice feature when sitting in the sun :-) I use the status bar to recognize command/insert/replace modes. –  Ferdinand Prantl Jul 7 '13 at 14:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.