3

I'm getting very odd characters (001B in a block, which apparently is escape?) in vim when I enter a newline, and sometimes when I switch to normal mode.

You can see the result here:

Screenshot of odd characters

What's odd is that it behaves normally in gvim/macvim/iTerm2 vim, but not gnome-terminal. I'm using base16-shell to get base16-ocean, and the colortest succeeds.

Here is my corresponding vimrc:

.vimrc

Chai T. Rex
  • 5,126
  • 1
  • 24
  • 48
mjedmonds
  • 41
  • 5
  • @Terrance - Worked fine for me. – You'reAGitForNotUsingGit Nov 29 '16 at 19:52
  • @AndroidDev Glad you got it working. Mine was giving me inaccessible possibly because it was a link to a dropbox which might be blocked here. – Terrance Nov 29 '16 at 19:53
  • Have you tried it in any other terminal ? Open `xterm` and try there. – Sergiy Kolodyazhnyy Nov 29 '16 at 20:54
  • @mjedmonds Is this `gnome-terminal` on OS X or macOS? – Chai T. Rex Nov 29 '16 at 20:57
  • @ChaiT.Rex gnome-terminal on Ubuntu 14.04 – mjedmonds Nov 30 '16 at 00:45
  • @Serg Problem doesn't exist in xterm (but I would still prefer to use gnome-terminal, everything else looks bad in xterm) – mjedmonds Nov 30 '16 at 00:46
  • Esc is usually used to start an ANSI escape code. It looks like both Esc and P are being shown. According to [the Wikipedia article](https://en.wikipedia.org/wiki/ANSI_escape_code), `ESC P` means "Controls a device. In xterm, uses of this sequence include defining User-Defined Keys, and requesting or setting Termcap/Terminfo data." Not sure why they're not being handled properly. – Chai T. Rex Nov 30 '16 at 00:57
  • 1
    @mjedmonds you don't necessarily have to use `xterm`. This just proves that the issue isn't vim, but with `gnome-terminal`. You can always switch to `terminator` or `konsole` - there's plenty of choice for terminal emulators. As far as `gnome-terminal`, can you take a look at your profile settings, and let me know if they are same or different form what I have ? screenshot: http://imgur.com/a/sX1Ze – Sergiy Kolodyazhnyy Nov 30 '16 at 01:15
  • @Serg Changing to `terminator` won't solve this problem, it uses the same terminal emulation widget (`vte`) as gnome-terminal, hence has the same emulation features and bugs. – egmont Nov 30 '16 at 08:34
  • You're probably hitting gnome-terminal (vte) bug http://bugzilla.gnome.org/show_bug.cgi?id=403130. You could track down what is the escape sequence printed at your setup that's not supported by vte, and modify your setup so that it's not printed. – egmont Nov 30 '16 at 12:45
  • It's the t_SI and t_EI definition in your vimrc around line 134 that print ESC P as well as that 50;CursorShape stuff which are not supported by gnome-terminal. I don't know what ESC P is supposed to do. Changing the cursor shape is supported by recent gnome-terminal (vte) versions, although via different escape sequences than this 50;CursorShape (see http://askubuntu.com/a/620306/398785). – egmont Nov 30 '16 at 12:48
  • @egmont bingo! thank you and others. A solution for the vimrc is here: [updated vimrc](https://github.com/mjedmonds/.dotfiles/commit/41c1d4639d7b2b047d260602f27a80695cf73f9c) – mjedmonds Nov 30 '16 at 23:11

2 Answers2

1

Per @egmont, Solution is to update vim's cursors to avoid gnome-terminals' vte bug.

See solution at my updated vimrc: https://github.com/mjedmonds/.dotfiles/commit/41c1d4639d7b2b047d260602f27a80695cf73f9c

mjedmonds
  • 41
  • 5
0

Thanks to @mjedmonds for the original solution. I found it quite good for Terminator but still had a couple of buggy screens (vim from ptipython for one) and issues with the initial cursor. So I removed the apple filters and added a little - potential users will probably benefit from comparing the two.

" Solve extra characters on vim screens in terminator in Linux
" Enable different cursors based on the mode from
" https://github.com/mjedmonds/dotfiles/commit/41c1d4639d7b2b047d260602f27a80695cf73f9c
" Information on cursors to complete it from
" https://vim.fandom.com/wiki/Change_cursor_shape_in_different_modes"

if has("autocmd")
  au BufNewFile,VimEnter,BufEnter,InsertLeave * 
    \ silent execute '!echo -ne "\e[2 q"' | redraw!
  au InsertEnter,InsertChange *
    \ if v:insertmode == 'i' | 
    \   silent execute '!echo -ne "\e[6 q"' | redraw! |
    \ elseif v:insertmode == 'r' |
    \   silent execute '!echo -ne "\e[4 q"' | redraw! |
    \ endif
  au VimLeave * silent execute '!echo -ne "\e[ q"' | redraw!
endif

let &t_SI = "\<Esc>P\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_SR = "\<Esc>P\<Esc>\<Esc>]50;CursorShape=2\x7\<Esc>\\"
let &t_EI = "\<Esc>P\<Esc>\<Esc>]50;CursorShape=2\x7\<Esc>\\"
John 9631
  • 817
  • 8
  • 6