Display more characters as one

16 views
Skip to first unread message

jachymb

unread,
Jul 28, 2012, 6:32:11 AM7/28/12
to v...@vim.org
Hello, everybody! This is my first post here.

I stumbled upon the following feature in the haskell editor "yi", I am
curious if there is something simillar possible in vim (or a plugin for it).

The idea is quite simple: Display certain character sequences in source code
as one: for example "->" as "→", or "forall" as "∀" etc. The important
thing is that the characters in the edited file are left unchanged, only are
displayed differently to make the code look nicer and save some space on
screen.

Is this possible in vim too?



--
View this message in context: http://vim.1045645.n5.nabble.com/Display-more-characters-as-one-tp5709842.html
Sent from the Vim - General mailing list archive at Nabble.com.

Florian Rehnisch

unread,
Jul 28, 2012, 8:16:58 PM7/28/12
to vim...@googlegroups.com
On Sat, Jul 28, 2012 at 03:32:11AM -0700, jachymb wrote:
> The idea is quite simple: Display certain character sequences in source code
> as one: for example "->" as "→", or "forall" as "∀" etc. The important
> thing is that the characters in the edited file are left unchanged, only are
> displayed differently to make the code look nicer and save some space on
> screen.
>
> Is this possible in vim too?

Yes, with the conceal feature, which was introduced
by the 7.3 release:

|cchar :syn-cchar
|
|The "cchar" argument defines the character shown in place of the item
|when it is concealed (setting "cchar" only makes sense when the conceal
|argument is given.) If "cchar" is not set then the default conceal
|character defined in the 'listchars' option is used. Example: >
| :syntax match Entity "&" conceal cchar=&
|See hl-Conceal for highlighting.

Simon Ruderich

unread,
Jul 28, 2012, 8:23:32 PM7/28/12
to vim...@googlegroups.com
On Sat, Jul 28, 2012 at 03:32:11AM -0700, jachymb wrote:
> Hello, everybody! This is my first post here.

Welcome ;-)

> I stumbled upon the following feature in the haskell editor "yi", I am
> curious if there is something simillar possible in vim (or a plugin for it).
>
> The idea is quite simple: Display certain character sequences in source code
> as one: for example "->" as "→", or "forall" as "∀" etc. The important
> thing is that the characters in the edited file are left unchanged, only are
> displayed differently to make the code look nicer and save some space on
> screen.
>
> Is this possible in vim too?

Yes, Vim supports this since 7.3. For more information see:

:help conceal

The following script looks useful:

http://www.vim.org/scripts/script.php?script_id=3200

The script contains installation instructions.

Regards,
Simon
--
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9

jachymb

unread,
Jul 29, 2012, 6:13:00 AM7/29/12
to v...@vim.org

Thanks,

that's exactly what I was looking for! :-)

 

Jachym


View this message in context: Re: Display more characters as one

jachymb

unread,
Jul 29, 2012, 2:10:44 PM7/29/12
to v...@vim.org

But maybe one more question to this topic, though:

Is it possible to create different conceal "classes"? I mean, when I do some syntax mathching with conceal, I have to link the conceal to only one syntax type like this: "hi! link Conceal Operator". But not all things I want to conceal are necessarily opearors. Is there a solution to this?

Jachym

 

On Saturday 28 of July 2012 17:23:49 you wrote:


View this message in context: Re: Display more characters as one

Simon Ruderich

unread,
Jul 29, 2012, 11:32:13 PM7/29/12
to vim...@googlegroups.com, v...@vim.org
On Sun, Jul 29, 2012 at 11:10:44AM -0700, jachymb wrote:
> But maybe one more question to this topic, though:
> Is it possible to create different conceal "classes"? I mean, when I do some
> syntax mathching with conceal, I have to link the conceal to only one syntax
> type like this: "hi! link Conceal Operator". But not all things I want to
> conceal are necessarily opearors. Is there a solution to this?

You shouldn't link to Conceal. Instead use the conceal argument
to :syntax, e.g.:

syntax match hsNiceOperator "\\" conceal cchar=λ

I'm not sure why the plugin links to Conceal, but it's not
necessary and everything works fine without it (e.g. the above
line is enough - it needs 'conceallevel' set to 1 or 2).
Reply all
Reply to author
Forward
0 new messages