Whack vim screen drawing errors - vim

Something extremely weird is happening when I open files in vim, and I can't remember doing anything that would have caused it.
Weird behaviors include:
no text being visible until I highlight it in visual mode, at which point it is visible from thereon. ":redraw!" does not make anything visible.
line 1 missing
occasionally the cursor appears one line below where it is editing
statuses become permanent and scroll up from the bottom, rather than just redrawing at the bottom
the vim text not extending to the bottom of the vertically maximized window
I lack the reputation to post screenshots but I'll happily provide any other information that could help in a diagnosis.
ETA: Ah! My .vimrc specified a column/row size. I've removed that line, and so far things are behaving well. Thank you!

vim is terminal based, and errors like this happen when the terminal you are using does not match the terminal vim thinks you are using. Most people use vim with terminal emulators. This kind of thing can happen when you resize the emulator window and vim does not find out about it, or more rarely, when the terminal-identifying-string specified in the environment does not match the terminal emulator you are running.
Without more details about the platform on which you are running vim, it is hard to be more specific-- but as a tip: don't resize the emulator window after it is created but before running vim.
Terminal emulators are supposed to communicate size changes back to the program running within them, but this is not 100% foolproof, especially when you are logged in to a remote machine within the emulator.

If you're doing this from a UNIX (Linux et al), try running :!resize to force your terminal to re-adjust its size parameters. At the very least it'll tell you what the system thinks your window is sized to, which may not match its actual size.

I had a similar problem when using vim with bash. When I switched from bash to zsh, it gave redraw errors where, while I typed, the cursor or screen would appear to go down one row for every 10 characters I typed. Scrolling with arrow keys also caused major display problems along the same lines, but worse.
I had this line in my previous .vimrc, I believe it was to set the color for vim
set t_256
I changed it to set term=xterm=256color and the problem went away.

Related

vi not recognizing scrolling, scrolls terminal instead

I have an instance of vi on a remote server that is not behaving like it used to, and I'm not sure what made this happen.
On my local shell, (and the remote server before this started happening), if I scroll with my mouse/touchpad, it would navigate the cursor within vim. I have checked my .vimrc and there's nothing in it relating to the mouse, and I did not make any changes to it before this issue started.
The only thing I can think of is that a few weeks ago, I was trying to figure out how I could split two files in the same vi instance so I could yank from one file to another, and I tried some : commands that I didn't really understand (didn't get any productive results). And also, I ran tmux once, but I don't think there are any . files that are applying unwanted settings (not sure).
I can't find anything to check the vi settings being applied, but I know that my .vimrc is working, and it's not anything in there (if I comment everything out it still behaves this way).
I just want my vi to respond the same way.
Describing the problem more exactly:
If I scroll, the cursor doesn't move, instead it scrolls on the terminal window, and it shows the previous bash commands instead of scrolling the file being edited. If I navigate using vim keys, it still works.
Randomly, I discovered that it actually had to do with the a specific terminal instance that was causing the issue. Closed it, opened a new one, no issue now. If anyone has any insight on why this could've been, I'd love to know.
.vimrc applies to vim not vi, doesn't it ?
the problem of scrolling might come from your terminal emulator as well.
I usually use embedded terminal in VS code which is not ideal (since it's not made for administration ...) but it's practical with keybinds to jump from one window to another, copy paste ...
I know some colleagues who use, mobaXterm or mremoteNG on windows.
I know I should give a go to Terminator, but it's on linux only and I don't want to run a local vm just for that.

IntelliJ terminal cursor shape

So, I am obsessed with Vim. I use vi mode everywhere - in all the editors and IDEs that support it. I use it it my browser (vimium, wasavi). I use 'hjkl' navigation everywhere thanks to awesome Karabiner. I use vi mode in my terminal via iTerm under zsh. Long time ago I found this little trick that changes cursor shape in the terminal depending of what mode you're currently in.
Now, although it perfectly works for iTerm, sadly it doesn't work in OS X's builtin terminal. I couldn't care less about that, except it also doesn't work in my favorite WebStorm. I thought I could trick it and instead of changing cursor's shape I could try tweaking its color. Still didn't work.
Please guys, help me to find a way to tweak cursor in IDEA's Terminal.
Thanks!
p.s.: Some may suggest to change the prompt depending the mode, but honestly I don't like that. I still believe there's a way to change cursor shape or color. Prob. just need to find the right escape sequence.
Unfortunately it looks like Intellij terminal draws it's own cursor without respect to bash or zsh settings.
Note I'm assuming community and pro editions of Intellij use the same terminal plugin
You can see the Terminal plugin source here
The terminal plugin uses Jediterm, a Java based terminal emulator written by JetBrains
Most of the drawing of the terminal window is handled in TerminalPanel.java and has a nested class called TerminalCursor
From the TerminalCursor class you can see that Java Graphics is used to draw boxes for regular cursors and blinking cursors.
Code that draws a rectangle for the cursor
I'm still not sure how the unfocused cursor is drawn since it's just an outline, and I can't find a handler for lost focus on the frame.
You can change the terminal cursor shape from the dialogue below:
Now, this is a lot prettier to work with:

vim not deleting characters in xterm

I have recently reinstalled my gentoo system and am now experiencing a strange problem in vim in an xterm:
If I exit the edit mode the "-- INSERT --" still is visible, though the edit mode is not active. Also, if I scroll through text longer lines are still shown throughout the window. I think it is a mistake in the clearing of characters or in some font configuration.
However, if I start a gnu screen session and use vim, everything is working fine.
Any hints of how to get my vim working properly in xterm without screen?
Is my problem well enough described to be understandable? If not I could try to add screenshots...
Thanks in advance.
jesterchen

Focus follow mouse in vim

I am aware that the mousefocus option is only supposed to work in gVim. But I was wondering, if it's possible to have the console Vim switch to different windows in response to mouse clicks, would it be not possible to easily add following mouse movement to it, too?
I'm an xmonad user, I love the focus following the pointer feature, I do a lot of pdf viewing and browsing while writing in Vim, and I'd be so much happier if I didn't have to keep mentally switching back and forth between two different types of focus changing.
If that's completely not possible, I guess opening new Vim windows (as with :split) in new instances of the terminal is no easier to do?
It would not be at all simple to add this. Using the mouse within the terminal works by vim sending control codes to the terminal requesting that mouse actions be sent as part of the input stream. Terminals only report clicks not changes in the pointer position, so vim has no way of knowing where the mouse is.
With major changes it would likely be possible for a vim with X support to get pointer activity directly from the X server, but that would likely be reported by pixel rather than by character so further work would need to be done before it could determine which vim window is currently under the pointer.
set mouse=a
should do the trick but it will probably depend on your terminal emulator. See :help 'mouse'.
This works for Windows 7/Cygwin 32bit mintty/vim 7.3: (I DO NOT use gvim!)
Having installed this: http://ehiti.de/katmouse/, I can scroll the window under my cursor without having to have clicked to select a window, click-selecting of single vim-windows works, too. It does not pull the vim window to the foreground, if another window overlaps it, if that is what you desire. Still it can be scrolled without click-selecting it first.
So:
Check if there exists a software paket for your distribution, that implements your desired mouse behavior on the OS level. When this works for my self-compiled vim in cygwin, it might very well work with console vim on linux, too.
This post here serves as evidence, that it is possible at all, that is the reason this was not made a comment. When I am on linux again I will investigate this further and update this post, but that might take a while.
On set mouse=a: The vim help states you a need a terminal capable of handling mouse inputs, further information can be found here. :help ttymouse might also be helpful, i.e. if you have a xterm-compliant console, but :help term is set to something else.
UPDATE: (Freshly installed Fedora 19 with packages, no self-compiled stuff.)
Fedora 19 + se mouse=a = scrolling in single console vim window with several buffers opened next to each other independently works, too. Window manager used is LXDE.

In Vim, why doesn't my mouse work past the 220th column?

I tend to maximize a terminal to one screen, and vertically split several windows in Vim. Everything works fine for the first few windows on the left, but clicking past about the 220th column in the terminal doesn't work correctly. Any mouse clicks past column 220 seem to be wrapping around to column 1. I've tested in xterm, urxvt, and Gnome terminal with and without tmux/screen; always the same behavior. If I greatly increase the size of the font in Gnome terminal, I can click on the last column (although it is no longer past column #220).
If I run a command in a terminal that prints to standard output, I can click all the way to the right of the terminal. The problem does seem to be related to Vim.
I have set mouse=a in .vimrc. I'll post the entire file on request, but it doesn't seem to have anything else related to the mouse.
It's probably irrelevant, but I'm running Xmonad+Gnome. Thanks in advance.
This has been fixed in Vim 7.3.632. See :h sgr-mouse. Or just put this in your ~/.vimrc:
set ttymouse=sgr
If you want to be compatible with versions that don't have mouse_sgr compiled in, use:
if has("mouse_sgr")
set ttymouse=sgr
else
set ttymouse=xterm2
end
To see if your version of Vim has mouse_sgr, run vim --version from the command-line, or in Vim, enter :version, and look for +mouse_sgr.
If you're using older versions of screen, or terminal emulators that don't support SGR, you may need to upgrade or switch. These settings work with all new versions of screen, tmux, gnome-terminal, PuTTY/KiTTY, iTerm2, and Terminal.app, using TERM=xterm-256color or screen-256color.
Update: If you're using neovim, SGR support is enabled by default.
Edit:
I deleted the bug report, as that tracker was for the website, not the text editor.
In looking in the correct place for an existing bug report, I found this:
http://groups.google.com/group/vim_dev/browse_thread/thread/4c137e64d2032441/b3993eaa89589619?lnk=gst&q=mouse#b3993eaa89589619
To summarize, it was an xterm limitation that has been lifted. However, Vim does not yet support columns longer than 223.
Original:
This seems to be a bug, as supported by comments made by redstreet. I filed a bug report:
https://sourceforge.net/tracker/?func=detail&aid=3389331&group_id=27891&atid=391887
A few years later, the bug still seems to be present.
The solution I found is neovim: a modern refactor of vim. Among other features, this bug has been resolved.
I simply copied my .vimrc into .nvimrc, and my plugins just worked with nvim. Maybe I'll just keep using that.

Resources