4

I want to change the cursor shape from an underscore to vertical when entering insert mode within VIM running in Terminal.app. (NOTE: I am aware that this is the default behavior under macvim.)

This reference: http://vim.wikia.com/wiki/Change_cursor_shape_in_different_modes provides instructions on how to do this. For example, the following works with iterm2:

let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"

Unfortunately, this does not work with Terminal.app (under Lion).

Are there any tricks for this with Terminal.app - or is this just not supported?

mokagio
  • 16,391
  • 3
  • 51
  • 58
Rocketman
  • 3,464
  • 5
  • 27
  • 30

3 Answers3

0

I'm absolutely certain I've seen an Applescript-based solution in the past but 5 minutes of google didn't bring anything. It was a little barbaric but it seemed to work… IIRC it changed the cursor shape preference on the fly and was triggered with an autocmd.

Keep searching, it's somewhere.

Are there any reason why you don't want to use iTerm?

romainl
  • 186,200
  • 21
  • 280
  • 313
  • 1
    Thanks for response. Yes - for now I am using iterm2. The only reason that I would prefer Terminal.app if I could get this to work is pretty minor. I use an image background (a leather texture for aesthetics). I find that Terminal.app handles the rendering much better. iterm2 renders a little choppy with some delays - when for example scrolling through man docs and such. – Rocketman Aug 21 '12 at 01:08
  • I would say that the changing cursor is minor too but *less* minor than the background image rendering issues. I went through a second google session with no luck. – romainl Aug 21 '12 at 05:21
0

I ran into this a similar problem myself, and found that this answer helped:

https://superuser.com/questions/712098/customize-vim-cursor-style-under-mac-os-x-terminal

When I started running vim inside tmux (still using terminal) the commands to change the cursor started working!

Tmux is a really cool terminal manager that lets you have multiple terminal windows, tabs, split-screens, you name it, as well as save your sessions. Heres a nice tutorial I used to get it installed and useful:

http://fideloper.com/mac-vim-tmux

Community
  • 1
  • 1
Andrei T
  • 163
  • 1
  • 8
0

OP asked this question in August 2012. It's very unlikely that Terminal.app supported the ability to change the cursor shape to a vertical bar at that time, because Terminal.app as a general rule provides very few features that are not imitating xterm. (The undocumented OSC 6 and 7 are the only exception to that rule which comes to mind).

xterm patch #282 about 6 weeks later introduced this feature as an extension to its emulation of DECSCUSR:

extend DECSCUSR to provide a way to set the cursor to a vertical bar (patch by Paul Bolle).

documented as follows:

CSI Ps SP q
          Set cursor style (DECSCUSR), VT520.
            Ps = 0  ⇒  blinking block.
            Ps = 1  ⇒  blinking block (default).
            Ps = 2  ⇒  steady block.
            Ps = 3  ⇒  blinking underline.
            Ps = 4  ⇒  steady underline.
            Ps = 5  ⇒  blinking bar, xterm.
            Ps = 6  ⇒  steady bar, xterm.

As indicated in a similar question (Customize vim cursor style under Mac OS X Terminal, July 2017) you can set vim's variables to use those escape sequences:

let &t_SI="\033[6 q" " start insert mode (steady bar, xterm)
let &t_EI="\033[1 q" " end insert mode
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105