m (Syntax highlighting when starting a string: fix annoyance moved to Remove annoyance with syntax highlighting when starting a string: Page moved by JohnBot to improve title) |
(Adjust previous/next navigation) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{review}} |
{{review}} |
||
+ | {{TipImported |
||
− | {{Tip |
||
|id=1120 |
|id=1120 |
||
+ | |previous=1119 |
||
− | |title=Syntax highlighting when starting a string: fix annoyance |
||
+ | |next=1126 |
||
− | |created=February 4, 2006 |
+ | |created=February 4, 2006 |
|complexity=intermediate |
|complexity=intermediate |
||
|author=AK |
|author=AK |
||
|version=5.7 |
|version=5.7 |
||
|rating=1/10 |
|rating=1/10 |
||
+ | |category1=Python |
||
− | |text= |
||
+ | |category2= |
||
⚫ | Did you ever notice how syntax highlight of the whole screen below current line changes when you start a string line (at least, in .py |
||
⚫ | |||
⚫ | Did you ever notice how syntax highlight of the whole screen below current line changes when you start a string line (at least, in .py Python files)? Vim thinks the rest of the screen is inside a string and highlights it as such. I find this extremely annoying and I found a very neat fix: you have to edit the syntax file for Python (or some other language), and add 'oneline' to the relevant line: |
||
+ | <pre> |
||
⚫ | |||
⚫ | |||
+ | </pre> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | |||
− | |||
− | |||
⚫ | |||
⚫ | |||
− | |||
⚫ | |||
⚫ | |||
− | |||
− | '''Anonymous''' |
||
− | , February 5, 2006 0:47 |
||
---- |
---- |
||
− | Just map the sting delimiter key to produce a pair of them and position you between them. |
+ | Just map the sting delimiter key to produce a pair of them and position you between them. |
+ | <pre> |
||
− | inoremap " "" |
+ | inoremap " ""<Esc>i |
⚫ | |||
+ | </pre> |
||
− | |||
⚫ | |||
− | '''Anonymous''' |
||
− | , February 5, 2006 15:28 |
||
---- |
---- |
||
− | <!-- parsed by vimtips.py in 0.550079 seconds--> |
||
− | [[Category:Python]] |
Latest revision as of 02:51, 20 July 2009
created February 4, 2006 · complexity intermediate · author AK · version 5.7
Did you ever notice how syntax highlight of the whole screen below current line changes when you start a string line (at least, in .py Python files)? Vim thinks the rest of the screen is inside a string and highlights it as such. I find this extremely annoying and I found a very neat fix: you have to edit the syntax file for Python (or some other language), and add 'oneline' to the relevant line:
syn region pythonString matchgroup=Normal start=+[uU]\='+ end=+'+ skip=+\\\\\|\'+ contains=pythonEscape oneline syn region pythonString matchgroup=Normal start=+[uU]\="+ end=+"+ skip=+\\\\\|\\"+ contains=pythonEscape oneline
This way, only the current line will change, from cursor to the end of line. Usually you're entering the string at the end of line, so you'll have no changes in syntax at all.
Comments[]
But then you lose the ability to see when you've forgotten to close a quote, etc.
Just map the sting delimiter key to produce a pair of them and position you between them.
inoremap " ""<Esc>i
That way you do not forget to close the string and you do not have the syntax coloring problem.