I've had this issue often where if I compile vim myself on a server (due to lack of root permissions), at various times, I'll get garbled lines in vim when I have split windows. This is hard to describe, and thus hard to search for, as well.
Here's an image of a vim window. In each split is my .vimrc. Everything is good right now:
Now, I hit some in the right split to scroll down, and suddenly, we have garbled text and line 176 showing up everywhere:
This is not particular to any specific file. I've tried removing all my plugins, and the issue persists.
It turns out, the offending line was
set encoding=utf-8
in my .vimrc. I basically commented out my entire vimrc, and searched through until I realized this line was the issue, and I'm not entirely sure why.
Related
Vim language highlighting has quit working only for one specific file.
I've been using Vim in WSL (Ubuntu) for several months now without problems. My PC is Windows 10 Professional. Strangely, Vim is no longer highlighting properly when I open a particular file. Everything works fine with every other file, but if I open this one file, it does not display correctly. The language highlighting is gone. Line numbers, tabs, and end-of-file-tildes still follow the color scheme, but my actual code is simply colored white. Does anyone know how to fix this?
More details:
The file type is *.v
If I rename the file, it displays correctly.
If multiple files are open at once (i.e. split view), every other file displays fine while this one file does not.
The problem arose in the middle of a work session, and I changed nothing in the vimrc before the problem arose.
After seeing the problem, I ran apt-get update and apt-get upgrade, followed by a restart.
I tried changing the color scheme in my vimrc.
Nothing I tried worked. Any ideas or insight would be greatly appreciated. Thanks!
EDIT: This question will be moved to vim.stackexchange.com
I have one mapping to toggle syntax, maybe it will help you
nnoremap <silent> <expr> <Leader>s exists('g:syntax_on') ? ':syntax off<cr>' : ':syntax enable<cr>'
I read all the other posts on this problem and tried them all. I am posting this since those solutions did not work for me. I am a vim beginner, so part of the problem here is not understanding all the workings of the .vimrc. Still, I need it to work in order to learn.
I added a line to open Chrome with a shortcut and ever since this I get the above message. I've since deleted the line, which never even worked, as well I've tried all the following which came from other posts, deleting each and trying them in combination.
Adding-
set shortmess=a
set cmdheight=2
Adding-
if v:version >= 703
"undo settings
set undodir=~/.vim/undofiles
set undofile
set undolevels=99999
set undolevels=10000
(Point here was to up the undo levels)
Adding- set nomore
When I enter into Vim, and then try to exit with q!, it always makes me enter the command twice. This never used to happen and must be connected to this error.
On vim 7.4, Sierra, regular terminal.
The last time I had some weird behaviour like that in Vim, I had something invalid in my ~/.viminfo file. This file keeps your Vim history: searches, commands, buffers, where you were in files you edited, etc.
My guess is that there are lines in the command line history section that are causing trouble.
To test my theory, rename your ~/.viminfo to some other name (effectively deleting it to Vim) and see if the behaviour is still there. Should that work and you don't mind losing your Vim history, just delete the file. Otherwise you can try to find the offending lines in it, but be careful to work on a differently named copy because Vim writes to this file.
I am a new comer to the vim world, and I have just installed spf13-vim for a quick start. Apart from that I have not touched my .vimrc file.
I mainly use vim to write some python scripts on a remote server, so I have to type 'set ft=python' each time I open a file using vim. I am wondering if it's possible to edit my .vimrc file to make python a default choice of vim.
Another confusing thing is that each time I type a blank in vim, it shows a inverted question mark on my vim screen. I think it's because of some mismatch in file encoding, but I have no more idea about it.
I know it's a stupid question, but right now I can't solve it myself. Any help is appreciated.
Edit:
I have solved the problem of setting python default by write 'set ft=python' to my .vimrc file. (I didn't know contents in .vimrc are commands in vim) But I still don't know how to eliminate the inverted question mark when I typed a blank char, even after I do some search.
Name the buffer you're editing from the start, don't forget the :filetype plugin in your .vimrc and then things will work correctly.
In any way having :set ft=whatever in your .vimrc is twice wrong. First it'll apply to all new sessions opened without a file. Moreover it'll only apply to the first buffer. I.e. it won't work with :new.
When using gVim, whenever I switch between two tabs where one tab is split vertically and the other is not, the horizontal size of the window is decreased by a small amount (probably one column).
This is really annoying as it forces me to resize the window every few minutes.
The behaviour can be reproduced as follows:
start gvim
create new tab :tabnew
split window vertically Ctrl+W v
switch tags gt (--> window size will decrease)
Is this somehow intended behaviour or is it just a bug? Anyway, is there some way to prevent this?
In case it matters: I am using Ubuntu 12.04 with Xfce, using the vim version from the repos (7.3, Included patches: 1-429).
Update 1
I followed the instructions of the FAQ posted by nMontu and tracked the issue down to the following line of my .vimrc:
set guifont=Meslo\ LG\ S\ DZ\ 12
Actually the issue is the font size, if I change it to
set guifont=Meslo\ LG\ S\ DZ\ 10
the problem is gone (leaving me with the problem of a too small font, of course...). It's only the font size, changing the font itself does not solve the problem. For other font sizes != 10 the problem is also there (I tested with sizes 8-14).
Update 2
I updated vim to version 7.4 and when testing with empty buffers, the problem is gone, even when using a font size != 10. However, as soon as I open files, it is there again :(
Following your steps on Linux Mint doesn't show the error. I've executed one hundred tabpage switches and the there was no change on the window size (qmgtq to record a macro, 100#m to execute it).
Notice that vim 7.3 is quite old, you should try updating it to 7.4. But the error you are experiencing probably isn't a vim bug. You should try to follow follow the procedure described on Vim-FAQ 2.5:
2.5. I have a "xyz" (some) problem with Vim. How do I determine it is a
problem with my setup or with Vim? / Have I found a bug in Vim?
First, you need to find out, whether the error is in the actual
runtime files or any plugin that is distributed with Vim or whether it
is a simple side effect of any configuration option from your .vimrc
or .gvimrc. So first, start vim like this:
vim -u NONE -U NONE -N -i NONE
this starts Vim in nocompatible mode (-N), without reading your
viminfo file (-i NONE), without reading any configuration file (-u
NONE for not reading .vimrc file and -U NONE for not reading a .gvimrc
file) or even plugin.
If the error does not occur when starting Vim this way, then the
problem is either related to some plugin of yours or some setting in
one of your local setup files. You need to find out, what triggers the
error, you try starting Vim this way:
vim -u NONE -U NONE -N
If the error occurs, the problem is your .viminfo file. Simply delete
the viminfo file then. If the error does not occur, try:
vim -u ~/.vimrc --noplugin -N -i NONE
This will simply use your .vimrc as configuration file, but not load
any plugins. If the error occurs this time, the error is possibly
caused by some configuration option inside your .vimrc file. Depending
on the length of your vimrc file, it can be quite hard to trace the
origin within that file.
The best way is to add :finish command in the middle of your .vimrc.
Then restart again using the same command line. If the error still
occurs, the bug must be caused because of a setting in the first half
of your .vimrc. If it doesn't happen, the problematic setting must be
in the second half of your .vimrc. So move the :finish command to the
middle of that half, of which you know that triggers the error and
move your way along, until you find the problematic option. If your
.vimrc is 350 lines long, you need at a maximum 9 tries to find the
offending line (in practise, this can often be further reduced, since
often lines depend on each other).
If the problem does not occur, when only loading your .vimrc file, the
error must be caused by a plugin or another runtime file (indent
autoload or syntax script). Check the output of the :scriptnames
command to see what files have been loaded and for each one try to
disable each one by one and see which one triggers the bug. Often
files that are loaded by vim, have a simple configuration variable to
disable them, but you need to check inside each file separately.
Edit
Vim's documentation is extremely well-written and very comprehensive. You are likely to find most of the details about Vim there. It also has a great FAQ, which can be viewed directly on Vim through this nice plugin.
Vim-FAQ 31.2 has a list of useful references:
For more information, read
'guifont'
'guifontset'
'guifontwide'
font-sizes
-font
-boldfont
-italicfont
-menufont
-menufontset
In special, on :help font-sizes:
Note: All fonts (except for the menu and tooltip) must be of the same
size!!! If you don't do this, text will disappear or mess up the
display. Vim does not check the font sizes. It's the size in screen
pixels that must be the same. Note that some fonts that have the same
point size don't have the same pixel size! Additionally, the
positioning of the fonts must be the same (ascent and descent). You
can check this with "xlsfonts -l {fontname}".
I don't know the font you mentioned (Meslo), but I would guess it is not mono-spaced.
Edit 2
Meslo is mono-spaced
It is possible that Meslo won't work, similar to what is stated in its FAQ:
Q: Can I use Meslo with ... ?
A: As for ... I don't know (yet). You may have to try it out. I do
know however that for the time being there appears to be a problem
with an application called SecureCRT which does not recognise Meslo as
a monospaced font. (see also: issue 2)
And issue 2 seems similar to your problem.
I'm trying to use Meslo in a terminal app that requires a fixed-width
font, but when I choose Meslo, it's claiming the font isn't
fixed-width.
You also mentioned that
and besides I am getting the same issue with other mono-spaced fonts
(i.e. 'Monospace') as well.
It is strange that it occurs with common mono-spaced fonts, as this kind of problem would certainly have been reported. If you are sure that it happens with fonts that follow the requirements on the Vim documentation then you should fill a bug report.
I have a file with 400+ lines (it's a thesis). When I edit it somewhere near
the top (say, on line 20), Vim is snappy as always. However, editing it near
the bottom (around line 400) causes a noticeable delay between me typing the character
and Vim showing it on the screen. As a consequence, it is almost impossible to
edit a file this big.
What is the reason for this and what can I do?
I've tried toggling the swapfile, syntax, scrolloff etc, but it doesn't
seem to help. The maximum number of lines for Vim should be 2147483647, so I
should actually have a long way to go here :)
In case this is related to setting maxmem, then what would be a reasonable
value, considering that I edit files up to 2500 lines?
Thanks very much for any help! Cheers.
Okay, folding was the problem here (I had some bad settings for foldlevelstart). So, based on my experiences and these issues:
set foldenable " can slow Vim down with some plugins
set foldlevelstart=99 " can slow Vim down with some plugins
set foldmethod=syntax " can slow Vim down with some plugins
Other things to check/toggle are syntax, filetype, wrap and line length (some plugins can be slow with very long lines).
Running Vim without your current settings is a good starting point. Thanks to #Frederik for pointing me to this:
vim -u NONE
After this, disabling all plugins is a good start. See also for general knowledge: :help slow
I recently came across this exact problem - lag while typing at the bottom of a relatively short (markdown) file. After uninstalling plugins and commenting out most of the settings in my .vimrc, I discovered that the issue was markdown folding coming from the vim-markdown plugin that is pre-installed with vim. Commenting out let g:markdown_folding = 1 did the trick.
I still wanted to have automatic folding on markdown files, so I installed vim-markdown-folding and there are no issues with performance.
In my case relative numbers with same file opened in multiple windows was lagging. I had to do either :set norelativenumber or close another windows.
Don't blame syntax only, several things can slow down editing in normal mode. e.g. auto completion; I had days of thinking that my Vim was slow because of syntax. I configured my autocompletion plugin to only trigger autocompletion once I have typed in at least 6 characters and the speed grew tremendously. I didn't even have to touch anything with syntax highlighting.