VIM: How to change the Showbreak Highlight color without using the NonText Color-element - vim

I noted that the 'showbreak' symbol is highlighted with the highlight "NonText" color-element. NonText is also used for the EOL Characters.
I would like to keep the highlight-color for the EOL characters but want to change it for the showbreak symbol is that possible?
Another problem is that my showbreak symbol is not displayed.
I would like to use this symbol "↳" and put it in the linenumbers column (using set cpoptions+=n). I can't find out how to display the symbol and how to put a space after the showbreak symbol (between the text and the symbol).
Can anyone help me?

I don't think you're going to get highlighting to be different than the EOL character, at least I am not aware of a way to do that.
For the second part I can help with. I was able to get "↳ " to show up in my line number column with the following settings:
let &showbreak = '↳ '
set wrap
set cpo=n
Note that there is a space after the ↳. This lines up nice until you have > 9 lines in the file. If you wanted it to line up with the last character of the number column regardless of the number of lines I'm not sure what you're going to have to do.
Edit: I've recently written a proof-of-concept function for someone on IRC that highlights the first character on a line that has been wrapped with a different highlight group. It hasn't been tested much but it seems to work. Not exactly what you're looking for but maybe it's worth a look.

:help hl-NonText makes it pretty clear that you cannot have different colors for the 'showbreak' string and other non-text strings, of which eol is a member (see :help 'listchars'):
NonText
'~' and '#' at the end of the window, characters from 'showbreak' and
other characters that do not really exist in the text (e.g., ">"
displayed when a double-wide character doesn't fit at the end of the
line).
If you're willing to accept this limitation (#elliottcable) hi! link NonText LineNr will match the 'showbreak' string to the line number colors.
If you really wanted to get clever, as a compromise you could create a mapping or command to toggle between ':set list' and ':set nolist' that would also adjust the NonText highlight setting simultaneously.
If you use :set relativenumber (added in vim 7.3), :set showbreak=↳\ \ \ will reliably keep your 'showbreak' neatly lined up since the number width will not change as you navigate through the file. (This in addition to the :set cpo+=n and :set wrap #Randy Morris mentioned in his answer.)
You'll definitely need UTF-8 for the ↳ character, since it does not appear in other encodings. I'd strongly recommend you carefully document your encoding problems, with details about how to reproduce them along with your OS, its version, and the :version output of vim, and post them as separate questions. UTF-8 should be helping you wrangle multiple languages rather than being an impediment.

Related

vimrc set highlight mode

I have the following in my .vimrc file:
version 6.0
" set highlight mode
set highlight=8b,#-,db,es,lb,mb,M-,nu,rs,sr,tb,vr,ws
Which was largely borrowed from here.
I don't understand what this line does:
set highlight=8b,#-,db,es,lb,mb,M-,nu,rs,sr,tb,vr,ws
I spent a few hours trying to figure out why my line numbers were not conforming to my colorscheme, and have traced it back to this line. If I remove the nu from the list, my line numbers start highlighting correctly. I can't find any documentation explaining what any of those two-character patterns mean. Changing or removing the other ones does not seem to affect anything obvious.
Can someone please point me to some documentation that explains what's going on here?
Edit: I read the :help highlight page in Vim, and could not find anything explaining this syntax. If it exists in help, could someone please tell me how to find the relevant section?
As was in the comments, :help 'highlight' has your answers.
Each argument is a pair of type-mode parameters.
The meaning of each of the pairs you listed is:
8b special characters for :map (eg <cr>) are bold
#- ~ characters after eof, along with some other special symbols, are not formatted
db directories are bold
es errors are standout
lb last search results are bold
mb more-prompt (when messages take up more than the screen) is bold
M- current mode (eg insert) is not formatted
nu line number is underlined
rs enter and y/n prompts are standout
sr status line of current window is reverse
tb titles of options (eg from :set all) are bold
vr visual highlighting is reverse
ws warnings are standout
If you wanted to customise these options, here's the meaning of each possible value for the mode parameter (second character):
r reverse
i italic
b bold
s standout
u underline
c undercurl
n no highlighting
- no highlighting
: use a highlight group
I won't go into detail for all the possible type parameters (first character), but you can find them in the previously mentioned help page.

vim: how to let vim use apostrophe as start of a string

I am working on a sql file with some m4 macro embedded. Since m4 uses apostrophe to mark the start of string literals, it breaks the string highlighting of the file totally. Like
m4_include(`SQLCommon.m4')
I am wondering whether there is any option we can let vim to pair apostrophe with a single quotation mark. I searched on-line but didn't find any answer.
Thanks!
You're going to want to override vim's normal syntax highlighting for sqlString.
I was able to get the behavior I think you're looking for with just this:
:syntax region m4String start=/`/ end=/'/
To achieve nesting, we have to tell vim that a m4 string can contain more of the same:
:syntax region m4String start=/`/ end=/'/ contains=m4String extend
If you'd like to color those strings separately instead of just disrupting the normal highlighting you can separately link to the String highlight group.
:hi link m4String String
I wasn't entirely sure what you were looking for though; if the backtick-apostrophe delimited strings are inside of the normal SQL strings this won't work.

Accents in vim: Cannot write "â"

I can't get "â" to be written. I can write "Â" though (carrot + capital A).
Any other accent can be written as in any other text editor.
Any suggestions?
Thank you in advance.
You may want to look at the :digraph comamnd in Vim. It will show you the combinations to use with <C-k> to make accented characters. In your case, you want <C-k> followed by a>.
Note: <C-k> means "Control + k" whereas a> means the letter "a" followed by a ">" (greater than sign).
If you are using a latin keyboard layout and are unable to directly type the accented character, check if there is any mapping using it:
:verbose imap â
If so, just remap the command to another key.
<C-K>a^ works for me in Vim 7.3.
You could use digraphs, as pointed out on other answers. But this kind of diacritical character is very common on some languages. If that is true for you, you could set the keymap option:
:set keymap=accents
The list of characters added by this option can be seen in $VIM\keymap\accents.vim.
That being said, this should be working without this option. It is possible that you are with some problem with the value your 'enconding' option, as mentioned here.
First look at digraphs, as mentioned before.
But just to be thorough, and because I haven't seen it mentioned yet, note that any unicode character at all can be inserted via <C-v>uXXXX<cr> (where XXXX is the hexadecimal code point number of the character.) More on this at :help i_^v
For a list of code point values for different characters, try:
https://en.wikipedia.org/wiki/List_of_Unicode_characters
Or use a handy Perl script called unum, which lets you search characters by name, and other fun stuff.
EDIT: markup fix

how to get the digraph key or unicode from a special character

I am configuring tmux & powerline. I would like to change the default separators in tmux status line. I managed to figure out where to do it, however I could not get the special character that I want.
I want to type, in Vim, a left/right pointing triangle that spans the whole line-height, but the only thing I could find is a small triangle (unicode : 25B6,25BA,25C0,25C4...)
There is a big right pointing triangle already in a powerline configuration file, which I could copy and paste, but I want to know its unicode and want a left one. Is there a way to get the unicode from the symbol in Vim or anywhere else?
You can get the codepoint value of a character in Vim by positioning the cursor on the character in question and typing either ga or :ascii.
You can either use ga in command mode or :ascii on the command line (even though it says ascii, it shows information for general encodings)
You may add a permanent preview of current character in your status line (see :h statusline), eg.:
:let &statusline = &statusline . "\ [%03b\ 0x%B]"

vim select paragraph -- how to redefine paragraph boundaries?

In vim, vip selects "inner paragraph" :help v_ip,
however it is of limited use.
vim paragraph boundary is hard coded, a
paragraph is separated by 2 or more blank lines.
:help paragraph
Some archaic marcos like .IP, also seem to be supported as
paragraph separators, but it is all hard coded.
I want to specify my own paragraph separators to easily
select paragraphs of text in vim.
Like perl in paragraph mode using an regexp splitter.
I tried setting paragraphs to be delimited by blank lines or braces:
:set paragraph+={ cpoptions+={
but does NOT work as documented,
braces are ignored by 'vip' selection command.
The solution I want should work for all paragraphs commands
like vip, vap, dip, dap, {,}.
Note how you can map operators, so you won't have to remap vip or vap (you could map aH to your movement operation - and all of the following work magically using your selections:
daH
vaHy
d2aH
etc
I don't know if it's an option for you, but you can change paragraph delimiting in certain way by including the 'w' flag in 'formatoptions'. Check out help for 'fo-table' to read more. Basically it makes it so that lines ending in a space are like 'soft returns' and lines ending in a non-space character mark the end of paragraphs. Empty lines are not markers at all in this case. The 'w' formation flag does work with all vip, vap, etc., if I recall.
If that isn't going to do the trick for you, then I suggest remapping the vip, vap, etc. sequences to a custom function of your own. That way you can set it up to select things exactly as you want.
See :help paragraphs.
'paragraphs' 'para' string (default "IPLPPPQPP TPHPLIPpLpItpplpipbp")
global
Specifies the nroff macros that separate paragraphs. These are pairs
of two letters (see object-motions).

Resources