Cannot disable vim line break symbols - vim

I had recently updated some of the plugins in vim.After that a "$" sign is appearing in all the line ends of the file. I understand this is a line break issue . I added the following lines in vimrc
set wrap
set linebreak
set nolist
But still the $ sign is there.
The funny part is ,if I use set nolist in any of the file it removes the $ sign.
But it is not picking from vimrc. any solution for this?

The scriptnames command in vim is particularly useful for this. It shows the scripts that loaded successfully.
To show the ones that don't load for some reason, you can start vim with the -V option.
That should hopefully be enough for you to identify either:
that your script is failing; or
scripts that may load after your script, that could change the behaviour back with set list.

Related

Vim weird behaviour with backspace with empty .vimrc

I'm having a weird issue with vim on Ubuntu. I've been using it for the last few weeks, trying to learn, on Windows and it behaves differently now that I'm using it on Linux.
I noticed that while in insert mode pressing backspace will delete text just like any other editor on Windows, but on Linux the text is "deleted" yet it stays there until I press ESC or write over it.
I was trying to fix this but I'm confused as to whether this is intended behaviour or not. It happens in gvim too.
The reason of this question is this, however:
I deleted my .vimrc file to see if any of my config was at fault and it fixed it. Backspace was now back to its regular self.
But then I tried creating an empty .vimrc file and that made it go back to the delayed delete. It's empty. Why the hell?
So I have no idea what's causing this. Hope my question makes sense my English ain't the best. Thanks.
Alright so looking at :h compatible I found this:
"When a |vimrc| or |gvimrc| file is found while Vim is starting up,
this option is switched off, and all options that have not been
modified will be set to the Vim defaults. Effectively, this means
that when a |vimrc| or |gvimrc| file exists, Vim will use the Vim
defaults, otherwise it will use the Vi defaults. (Note: This doesn't
happen for the system-wide vimrc or gvimrc file, nor for a file given
with the |-u| argument). Also see |compatible-default| and
|posix-compliance|."
So if I'm getting this right, running Vim with a .vimrc file should automatically set nocompatible and running it without one should set compatible... ? Whatever the case, I tried checking with :verbose set compatible? and it always says nocompatible is on so the -N flag shouldn't do anything... Yet it fixes the issue.
Without a vimrc Vim will load /usr/share/vim/vim80/defaults.vim (depending on your vim version). In this file the bs/backspace parameter is set to 2, or actually it is indent,eol,start which is the same as 2 (see :h bs)
Now if you create an empty .vimrc, defaults.vim will not be loaded, so your bs will possibly be 0.
This behaviour is described in :h defaults.vim
So to solve your problem, just put set bs=2 in your .vimrc
Alright I fixed it.
Running vim with the -N command makes it work properly. I'm not sure why but that's what's happening.

VIm How to fix - Already at oldest change Press ENTER or type command to continue

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.

set vim to autoindent using the same characters as the previous line

I use tabs for indentation in all my files. However, some bigger projects still use spaces, so I also need to follow those guidelines when I contribute.
This issue could easily be solved if the editor would detect the indent character used in the edited file, and use that one when e.g. autoindenting.
Sadly, vim forces spaces for indent, even when I am editing a file which otherwise only uses tabs.
How can I tell vim to always just use what the file is using (and use tabs if the file isn't using anything)?
I tried adding the following line (as I understand it, this should be forcing tabs - not exactly what I want, but better than inserting spaces everywhere) to ~/.vimrc and reopening the file I was editing, but this failed to take effect.
I am running vim-8.0.0386.
It looks like tpope/sleuth plugin is exactly what you want.
Otherwise, DetectIndent works too.
Clone the DetectIndent repo in your .vim/bundle/ directory (I use pathogen to install plugins), then open any file and type: :DetectIndent
Now shiftwidth, expandtab and tabstop should be adjusted to your file.
Here's another plugin recommendation: My IndentConsistencyCop plugin. It does not only detect the used indent setting, but also warns you if inconsistent settings are used within the same file.

How to exit automatically at end of file on vim?

I tried vim/less.sh as pager with syntax highlighting, but there is a little issue:
when displaying small file, vim uses 'full screen' and waits for a command from user.
Can I let vim to act like a less --quit-at-eof?
In other words, is there a way to automatically quit vim if displayed file is several lines length?
I found one solution with a shell script: count file lines by wc -l, then get terminal height, if size is small - use custom vim config file, where custom config file ending with :quit string.
However, this solution looks terrible and leave extra lines with ~ after end of small file, so I'm looking for better way to do this.
Vim switches to the alternate terminal page, so when you exit it, its contents are gone. Even if you turn that off:
$ vim --cmd 'set t_ti= t_te='
UI stuff like the ~, ruler and statusline would remain, too. Therefore, the solution you've found looks like a reasonable workaround. Either use that or (better) get used to quitting the Vim pager.

Vim response quite slow

If I open a file containing 5,000 lines of code and continue to input, I found that my vim became very slow, it displays my input after about 1s.
It even won't become any better after I start up with --noplugin. But after switching my .vimrc file, everything gets fine again. The .vimrc file is written by myself and after checking for some time, I still can't locate the error. I have clear all the key maps, but the problem still exists.
So can you give my any advise or tell my how to debug in vim? I found there is a debug option but can't get how to work.
You can use the --startuptime option when start vim:
--startuptime {fname} *--startuptime*
During startup write timing messages to the file {fname}.
This can be used to find out where time is spent while loading
your .vimrc, plugins and opening the first file.
When {fname} already exists new messages are appended.
(Only available when compiled with the |+startuptime|
feature).
Take following steps to diagnose the problem:
type vim --startuptime log.txt main.java in bash to start vim
type :tabe log.txt in vim to view the log.
The reason for slowness is often the not set or wrong set ruby_path on compile time of vim (see also discussion on google vim/ruby google group). It is easier to set it in vimrc, because you can change it without recompiling vim. You can set the path through the g:ruby_path variable in your .vimrc file. Don't copy and paste both, use the right one.
If you setup RBENV you have to use this one:
" ruby path if you are using rbenv
let g:ruby_path = system('echo $HOME/.rbenv/shims')
If you setup RVM you have to use this one:
" ruby path if you are using RVM
let g:ruby_path = system('rvm current')
You can also use the vim-rbenv plugin, which sets the path too.
For me the part on loading ruby specific functions in vim got 10 times faster.
If you are using jruby, than the start up slowliness can be even bigger. See examples for fixing it here.
If running vim 7.4,
put this in your .vimrc
set regexpengine=1
vim 7.4 has a new regex engine that appear not to work well in some situations. Previous version vim 7.3 used the old engine ( set regexpengine=1 ).
The "slow response" from syntax highlighting problem affects the vim help files as well ( and .vimrc file too ).
Something like this is usually caused by syntax colouring. Try with :syntax off.
Add these lines to your ~/.vimrc or ~/.config/nvim/init.vim:
set lazyredraw " don't redraw everytime
set synmaxcol=128 " avoid slow rendering for long lines
syntax sync minlines=64 " faster syntax hl
Also if you're using tmux, consider adding this to your ~/.tmux.conf:
set -sg escape-time 10

Resources