Codefolding / Indent guides in Vim? - vim

During a research for useful vim plugins I found a screenshot of a vim window showing some kind of dotted guides highlighting either indentation or folds. I'm not sure about what they highlight actually.
Does anyone know which plugin generates these guides and what their purpose is?
You can find the screenshot right here: http://oi54.tinypic.com/2yysefm.jpg

If you use tabs to indent your code, you can use the 'list' option to make your tabs visible.
In your ~/.vimrc:
set list
set listchars=tab:┊\ <-- don't forget the trailing space.
Obviously, this will work only if Vim supports utf-8.

Related

GVIM : in /root/.vimrc i have ":colorscheme desert" which worked, but where would i have found this value if someone hadn't told me?

So in GVIM i changed the color-scheme to
desert
but i never understood how to find this line
:colorscheme desert
so i could place it in
/root/.vimrc
file.
where would i have found out about " :colorscheme desert " ?
You could read the help (it is quite long and very detailed)
:h
Opens up to the main help for vim. Under getting started you will see the following. You might have to scroll down a bit (Use Control+f to page down)
usr_toc.txt Table Of Contents
Getting Started
usr_01.txt About the manuals
usr_02.txt The first steps in Vim
usr_03.txt Moving around
usr_04.txt Making small changes
usr_05.txt Set your settings
usr_06.txt Using syntax highlighting
usr_07.txt Editing more than one file
usr_08.txt Splitting windows
usr_09.txt Using the GUI
usr_10.txt Making big changes
usr_11.txt Recovering from a crash
usr_12.txt Clever tricks
It seems the that usr_06.txt is related to syntax highlighting so that might be worth reading. So type :h usr_06.txt or <c-]> (Control+]) to jump to that file when your cursor is on top of it.
Once you are in there you can look at the table of contents again.
06.1 Switching it on
06.2 No or wrong colors?
06.3 Different colors
06.4 With colors or without colors
06.5 Printing with colors
06.6 Further reading
Different colors seems to be what you want. So type :h 06.3 (or <c-]>) and the first paragraph talks about changing the colorscheme.
Control+] jumps to a tag and is talked about in :h tagsrch.txt (And on the line "Jump to a subject" immediately as you open :h)
The help have an auto completion feature.
So you can type, :help color followed by Ctrl+d. You won't necessary find the good entry right of the bat but it should put you on the right track. It would have shown you a colorscheme option.
An alternative is to use :helpgrep. :helpgrep color should give you a list of help file wich contains the string color.
On Debian Linux, it's part of the the vim-runtime package and sits in /usr/share/vim/vim73/colors/desert.vim. You can list contents of this direcory for more options. I don't think they have hard-coded color schemes in vim itself, so vim help will not list them for you.
I suppose like most other vim plugins, customized color schemes can also be put in ~/.vim directory.

Mac OSX Terminal Vim displays javascript code with weird and horrid shade

I develop javascript and just recently I found that I still love to use Terminal Vim instead of MacVim. Then I was totally annoyed when I opened my usual javascript file in the Terminal Vim: the statements of the code are irregularly highlighted with a mysterious color.
Just to clarify that other file types I have opened (e.g. c, html etc.) do not have the problem. I have scoured website but I could not find an answer. This is just so unacceptable, could someone help me out. A million thanks!
My .vimrc screen shot:
You appear to be using Syntastic.
The first line with the red background seems to be marked as an error.
The Error highlight group is very often set to use a red background.
My conclusion is that what you see is exactly what you should see. It is ugly on purpose and designed to look like that: you don't want to miss errors, do you?
However, Syntastic can be set to not use the Error highlighting to mark errors but the "signs" feature instead which is a lot less ugly.
You should have read the Syntastic documentation as it is all explained in plain english:
:help syntastic-error-signs
Also, set background=dark is not very useful (it doesn't change the background color, if that's what you want) and can be removed safely from your ~/.vimrc.
I found out that it was this plugin jslint.vim that caused the text to be highlighted. The problem is that this plugin could not be disabled properly which I thought I did. Thanks to the hint of #romaini, syntactic is a better plugin to check code errors and make proper configuration.
As a side note, for those who would like to use vim solarized color scheme, please use the solarized terminal color scheme first. Otherwise the color scheme won't be displayed properly.
Thank you for all of your comments and answers! Really appreciated.
Try changing your colorscheme. Open the file in Vim, then do
:colorscheme blink
To cycle through all possible colourschemes, type :colorscheme, then a space, then press Tab. When you reach a colorscheme that sounds promising, press Enter, and see if the text looks OK. Keep doing this until you find a colorscheme that you like.
Once you have found a colorscheme that you like, copy its name, and put the following in your .vimrc:
colorscheme name
(name is the name of the colorscheme you like.)
My favourite colorscheme is blink, but there are many good ones. You can even go online and download new ones if the defaults are not good enough.
Seems the syntax are not recognized correctly. Could you try:
:set filetype=javascript
One other thing to look at to make things look better (will change colors not highlighting). Make sure that your terminal reports itself as xterm-256colors. You can check this by typing echo $TERM.
If it doesn't return xterm-256colors go to Preferences -> Settings -> Advanced (tab) on the profile you are using.
Change the drop down at the top to xterm-256colors.

Search highlighting (hlsearch) not working in vim

I have a problem with search highlighting in vim. I have used it before but currently it does not work at all.
I have entered :set hlsearch, which is also in my .vimrc file.
I have entered :set hlsearch? and the result is hlsearch, indicating that I have successfully turned the option on. (right?)
I am running vim and not vi, so that is not the problem.
I have searched around but only found people asking about turning OFF search highlighting.
I would appreciate any input as this has been driving me nuts. Thanks!
Edit: highlighting also doesn't work for spellcheck, so evidently it's something global about highlighting.
When you have problems with multiple highlightings (like search and spell in your case), first check the defined highlightings with
:hi
If any groups are wrong or off, check your :colorscheme, and maybe try another.
In the console, color problems are often related to the number of available colors, a hairy problem. Check with
:set t_Co?
Another good tool for checking problems with individual syntax items is the SyntaxAttr.vim - Show syntax highlighting attributes of character under cursor plugin.

Can vim recognize indentation styles (tabs vs. spaces) automatically?

I'm working on a large codebase, where each file has different indentation conventions: tabs, 4 spaces, 3 spaces, etc.
I currently default on tabs and do set shiftwidth=N expandtab smarttab when I come across a spaces-indented file, but that's annoying.
Is there any functionality in Vim, or a plugin, which can recognize that, for instance, the current buffer uses an indentation with three spaces per shift?
Various plugins exist that attempt to handle that situation. Here are a few I found by search for detect indent at vim.org
sleuth
DetectIndent
yafia
IndentConsistencyCop
IndentFinder
Good question,I'm facing the same problem too, and recently I wrote such a vim plugin for myself:https://github.com/luochen1990/indent-detector.vim
it has the following features:
detect mixed indent and echo warnning on bufEnter and bufWrite
automatically.
switch setting about indenting to fit the current indenting style automatically.
detecting time is limited, so you don't
need to worry about opening huge files.
I think it is well designed, and need to be known, post an issue on github if you have any suggestion :)

Weird VIM colorscheme, I don't know what's going wrong in my configuration

I got a weird vim interface, please take a look at the following image:
How can I remove those red blocks? It's not highlighted search.
What I did is switch from Gentoo to Arch, my ~/.vimrc remain unchanged.
Many thanks!
Looks like you've got spell-checking enabled.
:set nospell
If you want to find who set 'spell' (it's off by default), use:
:verbose set spell?
There's a syntax file that has those strings in it, telling the colorscheme to color them in some special way. The colorscheme defines that special way to be utterly hideous. :)
If you want that text highlighted, just differently, you'll need to edit your colorscheme. If you don't want that text highlighted, you need to remove them from the syntax definition.
Unfortunately I don't know much about that stuff as I'm mostly happy with the defaults on Windows...

Resources