Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Match end of line (EOL) with syntax match in vim

When I hit / in vim and search for $ it highlights all eols. But when I try to match them with syntax match it does not seem to work.

function! ConcealNonText()
    set conceallevel=1
    set concealcursor=v
    syntax match NonText /$/ conceal cchar=¶
endfunction

augroup ConcealNonText
    autocmd!
    autocmd VimEnter * call ConcealNonText()
augroup END

Any hints how I could match it in order to display eols as concealed chars? I know I could use set list listchars but that has some visual side effects in my opinion.

like image 312
Saucier Avatar asked Nov 12 '22 08:11

Saucier


1 Answers

Looks like your requirement is to show in place of the eol. Although the code you have given maybe a possible solution, but it surely is not an ideal one. Vim provides a much simpler way of achieving what you wish. What you really need to do is lookup :h listchars.

Following is an example of what you should put in your vimrc to achieve what you desire :

set list
set listchars+=eol:¶

Once you put this, vim will show the character for the eol character.

like image 163
Dhruva Sagar Avatar answered Nov 15 '22 04:11

Dhruva Sagar