Using linebreak and line options at the same time - vim

The documentation of linebreak says:
This option is not used when the 'wrap' option is off or 'list' is on.
I find this unsatisfactory. Is there a workaround to use certain listchars and linebreak?
My ideal .vimrc looks like this:
set linebreak
set list
set listchars=tab:▸–,trail:·,extends:»,precedes:«,nbsp:⍽
… so I’m not actually interested in eol:$, which is presumably the reason why list conflicts with linebreak (that’s just my assumption but I see no other plausible reason for them to conflict).
There’s a closely related question but in that the OP specifically wants the EOL mark, and the accepted answer addresses only this, so it’s not useful for me.

I would guess (but do not know for sure) that the current implementation cannot deal with the change of the displayed width when a Tab character shrinks to ^I (assuming it has no value in 'listchars'). In any way, I think Vim could be enhanced to do just what you want, though it might not be easy to implement. It might be worth to raise this request on the vim_dev mailing list.
There are little good workarounds; one could theoretically use the new conceal feature to emulate certain things of :set list, but it interferes with syntax highlighting and there's only one choice for highlighting.

Related

Pair completion in Vim

I do my coding in Vim and recently have been getting more annoyed by its pair completion features. I don't really see the need for pair completion in general as I tend to naturally try to close pairs myself (by pair here I mean type the closing ')' of a set of parentheses, for example). What really annoys me is when I have text already written and to surround it by quotes for example I'll be at the beginning of the word, type ' and then two will pop up right over there rather than just 1 and then me pivoting to the end of the word and typing the other exclamation point. Anyways, that's it for my rant, so any help on stopping my vim from doing this would be appreciated. I use spfvim-13 (https://github.com/spf13/spf13-vim) and have only modified the .vimrc slightly. I wasn't able to pinpoint exactly from where this specific issue arises.
This is not a native vim behavior, it's definitely some plugin causing it. I can't pin-point a particular plugin that spf13 might be having for this, I looked for popular ones I know, like simple_pairs, delimitMate etc.
Best way to investigate what's causing is to just see the output of :verbose imap ' and you'll come to know where it's being set and then remove that plugin / setting.

Is there a stackoverflow site for vim?

It appears that vim.org supports questions only via mail and/or mail digests, and vim's own internal :help utility doesn't give me what I think I need regarding highlighting, so I'm here to ask my question. General searching via google gives me no good hits, possibly revealing that I'm just not asking with the right search terms.
My question will be: Can I highlight by regex independent of search highlighting?
If there is a stackoverflow site intended for vim questions such as that?
The simplest built-in way is
:mat[ch] {group} /{pattern}/
e.g. :match ErrorMsg /ERROR:/; you have two more slots with :2match and :3match (some plugins use those, too), and programatically an arbitrary number via the matchadd() function.
Differences
Whereas the search pattern is global in scope, the :match applies only to the current window. That can be unexpected. If you would like to have a quick way to define (and also jump to) some additional patterns (and don't mind installing a plugin), I can recommend you my Mark plugin.
There are tons of vim questions here on SO answered by some highly skilled vimmers so I don't see the need for a separate vim-SO-site...
But if you feel like creating one, you can always propose one at http://area51.stackexchange.com/
To answer your vim question: Have a look at this page http://vim.wikia.com/wiki/Highlight_multiple_words
Which describes a method to use multiple highlights.

vim: how to get parentheses matching like in DrRacket et al.?

I want to my vim setup to color my parentheses as is default in the DrRacket IDE for Scheme.
I know how to set up parentheses matching using the built-in MatchParen hlgroup but I think it's going to be hard to use that to good effect.
DrRacket highlights matching parenthese as follows:
make the background of the parentheses and all their contents a bit darker
also do this for any parentheses inside the parentheses
only do this for parentheses where the cursor is (like MatchParen)
Take a look at this screenshot to get a clearer idea what I mean:
This way you get a good visual feedback when writing paren-heavy languages such as Lisp.
Does a plugin exist that implements this behaviour? Or do you have tips on how I could
implement this myself?
I haven't seen a plugin implementing the staggered background coloring (and that would be difficult with low-color terminals and Vim shortcomings in the syntax highlighting), but a popular plugin is rainbow_parentheses.vim - Better Rainbow Parentheses, which uses different colors for each set of parens.
I wanted the same thing, so I forked the script and changed it accordingly.
Let me know if it works for you (and don't forget to set the colours to match your colour theme, as the defaults are unlikely to be pleasant!)
https://github.com/cbranch/rainbow_parentheses.vim
This script doesn't highlight on the cursor's position, but hopefully it is not difficult to merge the behaviour of the MatchParen plugin with this one. I personally don't care for it, so that is an exercise for others :)

Configure tab to show list of variants instead of cycling through in VIM

When opening new buffer it VIM, I type:
new /path/to/fi
If I hit "tab" at this point it cycles through files. How to configure VIM to show list of variants instead of going for the first one?
set wildmenu
Is all you need to add to your .vimrc. Read :help wildmenu.
Set your wildmode setting to something different, for example
set wildmode=list:longest
If I misunderstood the question completely, yell ... :)
(This is not a direct answer to your question, but I think it's even better :)
You should check out the Command-T plugin, inspired by TextMate's 'Go To File'. It filters out possible combinations very intelligently, just type a few characters of each subdirectory enough to distinguish it and it 'gets' it, the characters don't have to be at the beginning and can don't have to be sequential. It also shows you a list of options left.
I realize this is a terrible explanation so check out this video to see how it works.
The downside is it requires Vim to be compiled with Ruby support.
Control-P (ctrlp.vim) is a replacement for Command-T written in VimScript, so it doesn't require Ruby.

Is Vim's Haskell syntax highlighting broken?

It seems to me that Vim's syntax highlighting for Haskell is broken, or very buggy. Multiline comments in Haskell (beginning with {- and ending with -}) are arbitrarily greened-out and un-greened-out. Sometimes dragging the mouse over the commented code causes it to reverse color.
Has anyone else been experiencing this problem?
Vim's syntax highlighting trades off accuracy for performance, by default. To do this, it only examines a certain number of lines before the current position to determine how things should be highlighted. This means that it can sometimes get out of sync.
The different methods it uses to determine how much text to examine can be seen at :help :syn-sync. If you want it to Just Work, use :syn sync fromstart to make Vim consider the entire buffer up to the cursor to determine the highlighting.
This happens with other languages as well, it's just the way vim works. It does not actually use a parser, which would be required to be completely accurate all of the time. Actually, sometimes you may need more than just a syntax parser.
http://vimdoc.sourceforge.net/htmldoc/syntax.html

Resources