When I'm not in insert mode and I'm navigating around my file with the motion keys (hjkl etc), the keys often appear in the buffer (illustrated below). I can observe this effect pretty readily in tmux, but it doesn't seem to happen without. If I run :!reset in vim the buffer returns to normal, but it doesn't stay that way for long. I'm not sure why this is happening and google yielded nothing. Halp?
Edit: It seems just a simple :e will fix the problem, too.
I experience the same thing. A few extra observations:
it only seems to happen when I hold down a motion key like j or k, causing rapid repeats
it happens both in and outside of tmux, but much more often in tmux
it happens much more often since I enabled vim-go's go_auto_sameids, which I believe is making a call to an external program (guru) for every cursor movement
This leads me to assume that it's a timing issue in vim that is exacerbated by latency added by things like tmux and/or plugins.
(Using gnome terminal; $TERM is screen-256color in tmux and xterm-256color outside)
I think this was alluded to on the tmux mailing list recently. Try decreasing the value of the escape-time parameter in tmux, so that tmux more quickly sends the escape character to vim to return to command mode, rather than waiting for more characters in an escape sequence. The default value is 500ms, so try something smaller, like 50.
In .tmux.conf:
set-option -g escape-time 50
Related
Starting just today, after editing a source file for a few minutes vim suddenly responds differently to my keys than I expect it to. I don't have many details as I saved and quit lest it eat my file.
I'm concerned it could be something wrong with the keyboard on my Acer Inspire E15, but typing this post works just fine.
One thing that happened is that entering ^P (Constrol-P) pasted a word, rather than moving to the previous line.
First, Ctrl-P doesn't move to the previous line, k usually does (in normal mode).
Next time:
First, observe in what mode you are: normal, insert, command-line.
Then check any mappings, for example with :verbose nmap <C-p>. You can also list all mappings with :map | :map!
Another pitfall is if you accidentally have :set paste; then, no mappings at all suddenly apply!
Also, consider the environment: Are you in a terminal, or do you use GUI GVIM; do you have any related apps (screen / tmux, or AutoKey) that may distort key bindings? Do you connect remotely through VNC / remote desktop; these sometimes can have "sticky keys" (like Shift-Lock) wreaking havoc.
And finally, real hardware failures are very rare :-)
I tried to do syntax highlighting in vim, but I've got weird color highlighting letters on blocks. On black, it is not much of a problem, but when it's sunny blue, it's not readable, so I would prefer a light background.
~/.vimrc does not seem to respond to set background=light if there is no colorscheme.
I'm not very proficient with vim, and I think I might have turned on a function inadvertently, by accidental key strokes. Is there a way to turn off all kind of search and highlight?
I'm reading readmes, but this makes it difficult. The image below shows my screen.
I've heard about such incomplete screen updates occurring then the value of $TERM isn't right. Especially inside a screen / tmux session, be sure to have set the correct value (screen-256color in that latter case).
You could try GVIM (the non-terminal GUI version of Vim) to get moving with your work; it shouldn't have those issues.
I think I might have turned on a function inadvertently, by accidental key strokes
Fear not, any settings only persist by editing the ~/.vimrc file (or by saving a session). You'll always get a clean new instance by quitting and re-starting Vim.
Functional keys (F1-F12) for vim in console don't work.
But the worst thing is when I hit such key, vim stays in some "mode" not allowing me to type anything for 2s... Very annoying
Another thing is after pressing Esc key vim pause for about 0.5s before go to normal mode.. But this is only happening in screen, even I set
export TERM=xterm
Anybody has some clean and short solution?
Sounds like some disagreement between the byte sequences vim thinks the terminal is going to send, and the sequences it actually does.
Also the half-second delay is a consequence of having some mappings that start with Escape.
I have recently been trying out tmux on my server as a replacement for byobu (screen). When I started editing some code on vim, I found it very laggy when I held on to j and k to scroll up and down.
I thought it might be because there was something wrong with my connection but I tried editing the same file on vim without tmux and I found it much more responsive with almost no lag.
So, is there anything I can do to make vim on tmux not lag?
It sounds like you are using tmux over ssh. If so, you may want to give mosh a try. It is built on top of ssh but with many advantages over ssh. One of them is:
Get rid of network lag.
SSH waits for the server's reply before showing you your own typing. That can make for a lousy user interface. Mosh is different: it gives an instant response to typing, deleting, and line editing. It does this adaptively and works even in full-screen programs like emacs and vim. On a bad connection, outstanding predictions are underlined so you won't be misled.
It worked much better than over ssh in my experience.
I often work on a remote machine, and I have the same vim scrolling problem. When you use vim inside tmux and you have multiple panes open at the same time, tmux can't just redraw the part of the screen where vim is running, but it has to redraw a much bigger portion (potentially the entire screen). This increases the number of escape characters that tmux is sending through your connection.
In my case, enabling ssh compression reduced this kind of slowness quite a lot. You can give it a try with:
ssh -C user#host
or put Compression yes into your ~/.ssh/config to make it permanent.
Why should I use tmux when iterm2 has split panes?
I have never used tmux, and want to know if there are advantages to using that in my workflow instead of the split pane features iterm2 has.
I really like the dimming of inactive windows that iTerm2 split panes offers. Does tmux do something similar?
What are the advantages/disadvantages of each?
There is another advantage of tmux: what happens if you accidentally close iterm2? If you do it really by accident, you want to reopen everything again. With tmux it is normally as simple as reattaching session without losing anything. Most terminal emulators send SIGHUP to all children which terminates them by default and thus you lose unsaved data (at least, shell and vim command history and other data stored in viminfo) and running processes and thus reopening means rerunning everything.
iTerm2 can use tmux for it's split panes. Personally, I'm used to tmux by itself at this point, so I've not leveraged this ability extensively - but if you are used to iTerm2 split panes, you can get the benefits of tmux (mostly screen-like session saving) with the iTerm aesthetics.
https://gitlab.com/gnachman/iterm2/wikis/TmuxIntegration
My approach (not based on any particular insight) is to use iTerm tabs and panes to separate servers, and screen / tmux on the server to persist sessions.
I don't often have anything of importance running locally, but often do remotely.
Never used iterm2, however I have played with tmux a little and there are several articles about using tmux and vim together. These articles show how you can control a tmux session via the tslime plugin, and others, from Vim. What's nice about it is that you can run a command in Vim to compile your files, run unit tests, etc. without every leaving Vim, but you see the command run in the other tmux pane.
Apologies for not being a complete answer, but hopefully it helps point you in the right direction.
LINK: https://joshuadavey.com/2012/01/10/faster-tdd-feedback-with-tmux-tslime-vim-and-turbux/