I need a script code to highlight ‘[Capítulo’ and ‘]’ and everything between them. Thank you.
I want it to work everytime I open , for example, a .txt file. Just like code highlighting.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here’s an easy way to do it:
in vim, make sure syntax highlighting is on with
:syn onrun the command
:highlightto get a listing of all the highlight group names, and samples of what they look like. TheErrorgroup looks like it stands out well in my colorscheme, so I’ll use that in my example (but you can use any of the other names, likeTodoorSearch)This pattern will keep you from greedily matching the largest chunk. Even though other people are suggesting you use the regular expression
/\[Capítulo.*\]/– it’s probably not what you want, because it will match everything in between if there are two or more such patterns on a line.For example
/\[Capítulo.*\]/will match this entire line:The same example but with
/\[Capítulo[^\]]*\]/will only match stuff inside []:With regular expressions, it’s a common trick to make a group that matches everything but the character that you want to end your match, instead of using the
.*which will match as many characters as it can. In this case, we make the group[^\]]*– which says ‘match everything except ].‘If this works the way you want it to, add the syntax match line without the ‘
:‘ to your .vimrc