'How can Vims conceal feature be used to simplify code?
After much Googling I have been unable to make Vim's code conceal feature work with Javascript and Typescript (without requiring a plugin).
I have been trying to use lines like the following in my .vimrc to conceal my code but without any luck:
syntax keyword Normal function conceal cchar=λ
syntax keyword Keyword return conceal cchar=>
Aim:
// Actual
function sum(a) {
return function inner(b) {
return a + b
}
}
// Displayed
λ sum a
> inner b
> a + b
Goals:
- Replace
functionwith the lambda symbol - Replace
returnwith the > symbol - Replace
[name]([args])withname args - Conceal the
{ - Conceal the
}
Solution 1:[1]
Your snippet appears to work as intended if you enable the "conceal" feature:
See :help 'conceallevel'.
But you may have a kind of race condition with other syntax scripts if you don't execute those :syntax commands at the right time. When in a TypeScript buffer, could you do :scriptnames and add the output of the command to your question?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

