When I start vim with one of these plugins:
TagBar
Session
I see sometimes garbage characters in the buffer when I open vim.
Here are these characters:
;2R^[[>1;2802;0c
By uninstalling these two plugins, I don't see these garbage characters anymore.
If I type dd, it does not even delete these characters. Vim says the buffer is empty.
Putting this command at the end of my .vimrc is a workaround for this problem:
autocmd VimEnter * redraw!
With this, these characters are deleted immediately.
How can I fix this problem?
Vim asks the terminal for its version, what you're seeing is the response (cp. :help v:termresponse). It only appears printed in the terminal; that's why you can't "edit" it and it appears after a redraw.
Why Vim doesn't properly receive it, I don't know. Switching the terminal program might help. You could also try to suppress the query via :set t_RV= in your ~/.vimrc.
Thanks Ingo! I only get this on the mac, so for me it's
if has('mac')
:set t_RV=
endif
I switched to neovim and I've never seen this issue anymore.
Related
I recently upgraded to Ubuntu 16.04 and this problem returned. I vaguely recall fixing it on 14.04 but I can't remember how.
I've got the tmux window split into two panes. vim is running in the left pane displaying a file. If the vim cursor is on a parenthesis of any sort when I switch panes, the parenthesis will become a caret on the display though it isn't changed in the file. Switching back to vim and moving the cursor will cause it to redraw correctly.
Outside of tmux TERM is gnome-256color. Inside tmux TERM is screen-256color.
Any ideas on what is causing this?
Update
I can make it happen by simply changing focus using Alt-Tab. That is, I don't need to switch tabs in tmux. Simply moving focus around the screen will cause it to happen.
Update2
It turns out it was unrelated to gnome-terminal so I removed references to it.
This was happening because of vim's parenthesis highlighting on matching.
From :help matchparen
The functionality mentioned here is a standard-plugin.
This plugin is only available if 'compatible' is not set.
You can avoid loading this plugin by setting the "loaded_matchparen" variable:
:let loaded_matchparen = 1
The plugin installs CursorMoved, CursorMovedI and WinEnter autocommands to
redefine the match highlighting.
:NoMatchParen :DoMatchParen
To disable the plugin after it was loaded use this command:
:NoMatchParen
And to enable it again:
:DoMatchParen
You can use autocommands to toggle this.
Something like
:autocmd FocusLost * :NoMatchParen
:autocmd FocusGained * :DoMatchParen
Should work.
You can use tmux-focus-events.vim plugin if your console vim doesn't support these autocommands
Also take a look at this post in unix stachexchange.
If I have this line in my vimrc
au VimLeave %bdelete
Then whenever vim starts it says
--- Auto-Commands ---
Press ENTER or type command to continue
I have that line there to empty the buffers from gvim, because new gvim instances have massive :ls output from previous runs. Notably, gvim doesn't actually produce this prompt.
Obviously I can set this instance up to only occur during gvim startup and not console vim, but I'd like to understand this rather than avoid it. Mostly I'm confused that VimLeave seems to cause things to happen on startup.
TIA
Altreus
The problem is that this is an incomplete :autocmd definition, so Vim attempts to list all VimLeave autocommands defined for the pattern %bdelete. You need to specify the any file pattern to make it work:
au VimLeave * %bdelete
Also, check whether you have % in your 'viminfo' option; that one enables the saving and restoring of the buffer list you're complaining about. The f option of file marks may also result in buffers being restored; you could try :set viminfo+=f0.
New Vim instances don't inherit the buffer list of the previous instance unless you add % to the viminfo option.
Setting that option to a sane value will remove the need for your broken fix. Reading the documentation before adding options to your config will prevent you from similar issues.
See :help 'viminfo'.
In a previous post here - vim buffer Trying char-by-char conversion - I was running into a problem when opening up certain files and vim wasn't able to detect the encodings in that file and this was resolved by the solution provided by Ingo.
But after I installed vim's NERDTree plugin, I am running into the same problem again.
It appears that buffer opened by NERDTree mapping map <F2> :NERDTreeToggle<CR> does not obey the :set encoding=utf-8 directive.
I have to manually run :set encoding=utf-8 again in order for the Trying char~by-char conversion... problem to be resolved.
Also, my nerdtree directory shows up with a weird ? instead of the | symbol. Like this:-
What am I doing wrong?
I have temporarily solved this problem by mapping
map <F2> :NERDTreeToggle<CR>:set encoding=utf-8<CR>
instead of the original plain
map <F2> :NERDTreeToggle<CR>
However this solution is not good enough as the Trying char~by-char conversion warning still pops up whenever I browse open a specific directory in the NERDTree buffer.
So, I would like to hear if anyone has a better solution! Thanks!
The nerdtree ? character problem was solved by this post - vim - nerdtree suddenly broke
You shouldn't need to do anything: NERDTree doesn't manipulate encoding and encoding is a global option that you set once and for all in your ~/.vimrc. Go back to an almost empty ~/.vimrc and build from that (with encoding and other options).
I have two buffers in my vim session, and I set syntax on in my vimrc , I used minibufexpl to manage bufs.
I used :q to quit the current buf, but the other buf would auto set the syntax off, I have to use :set syntax=on to open the syntax highlight manually. Could someone give me a solution that not set the syntax off automatic after one buf quit? Thanks!! (I tried :bd to quit the buf instead of :q, sometimes it stay the syntax on but sometimes no).
If you're using minibufexpl.vim, add the following to your .vimrc:
let g:miniBufExplForceSyntaxEnable = 1
It appears to be caused by a bug in vim. For the details, refer to the release notes for minibufexpl version 6.3.1
Note that this will work for :bd but not :q
This might be much too late, but I was experiencing the exact same problem and found that adding the line
set hidden
to my .vimrc solves this problem. This makes vim hide buffers rather than closing them when you enter ":q" It also seems to keep my syntax highlighting enabled between files when I navigate with minibufexplorer.
Hope this helps.
You can use syntax enable or syntax on in your vimrc. For more info use :h syntax.
Ok then check that your syntax files are correct, it should looke like this
au BufNewFile,BufRead *.cpp set syntax=cpp11 <-- it's the line I have for cpp files.
Hope this help.
May be you should add this line to gvimrc:
autocmd BufDelete * syntax on
A plugin is misbehaving.
After closing the buffer (and losing syntax highlighting), investigate, by e.g.
:verbose set syntax?
This will show something like
syntax=cpp
Last set from C:\Program Files\Vim\vim73\syntax\syntax.vim
You might also be able to see what goes wrong my doing
:debug quit
If all else fails, try eliminating sources of errors by disabling plugins one-by-one (or removing all, and enabling one-by-one). At some point the problem will appear/disappear and you have found the guilty party.
I'm getting some junk in my command bar when I load vim. Specifically, :95;c appears, and I have to escape out. This happens in Vim 7.2 (the one that comes with OS X), but not in MacVim, which uses 7.3. I've narrowed it down to these two lines in my vimrc:
nnoremap ; :
nnoremap <esc> :noh<cr>
If both lines are present, the junk shows up (with all plugins, colorschemes, and other vimrc lines, etc removed). If either is disabled, it goes away. I'm hella confused, since despite being a bit of a vimrc newb, I think I understand these lines. I have no idea why they would conflict.
Avoid mapping <Esc>, especially in console Vim. This special key is used in the ANSI escape sequences used for terminal control and coloring.
I had this issue and it was caused by a comment in the .vimrc, like this:
set background=light"can be light or dark
changed to add a space:
set background=light "can be light or dark
hope this helps someone.