disable syntax highlighting in vim for new input in insert mode
When I edit a shell script with syntax highlighting enabled in vim, the moment I type opening " or ${ the editor immediately re-highlights the rest of the file as if it is a part of the string or variable name. Then when I type the closing " or } it re-highlights again. This leads to a lot of flashing.
Is it possible to disable this global live re-highlighting? For example, is there an option not to change any highlighting until I leave the insert mode? Or perhaps change the highlighting only for the lines that are affected by the new insert and keep the highlighting for the rest of lines until I end the edit?
vim syntax-highlighting
add a comment |
When I edit a shell script with syntax highlighting enabled in vim, the moment I type opening " or ${ the editor immediately re-highlights the rest of the file as if it is a part of the string or variable name. Then when I type the closing " or } it re-highlights again. This leads to a lot of flashing.
Is it possible to disable this global live re-highlighting? For example, is there an option not to change any highlighting until I leave the insert mode? Or perhaps change the highlighting only for the lines that are affected by the new insert and keep the highlighting for the rest of lines until I end the edit?
vim syntax-highlighting
add a comment |
When I edit a shell script with syntax highlighting enabled in vim, the moment I type opening " or ${ the editor immediately re-highlights the rest of the file as if it is a part of the string or variable name. Then when I type the closing " or } it re-highlights again. This leads to a lot of flashing.
Is it possible to disable this global live re-highlighting? For example, is there an option not to change any highlighting until I leave the insert mode? Or perhaps change the highlighting only for the lines that are affected by the new insert and keep the highlighting for the rest of lines until I end the edit?
vim syntax-highlighting
When I edit a shell script with syntax highlighting enabled in vim, the moment I type opening " or ${ the editor immediately re-highlights the rest of the file as if it is a part of the string or variable name. Then when I type the closing " or } it re-highlights again. This leads to a lot of flashing.
Is it possible to disable this global live re-highlighting? For example, is there an option not to change any highlighting until I leave the insert mode? Or perhaps change the highlighting only for the lines that are affected by the new insert and keep the highlighting for the rest of lines until I end the edit?
vim syntax-highlighting
vim syntax-highlighting
asked Jan 31 at 20:32
Igor BukanovIgor Bukanov
14815
14815
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
This unfortunately isn't possible. In theory, syntax highlighting could add assertions to the definitions that say "only match this if the cursor is not inside", but as this would make regular expressions more cumbersome (and potentially also much slower), it isn't done.
You only can completely disable / enable syntax highlighting when entering / leaving insert mode, but that would create even more flashing (and potentially cause slowdown as the whole buffer would need to be re-parsed).
The only practical advice I can offer is to use an autoclose plugin (the automatically append closing characters Wiki page describes some simple setups and a list of plugins) that automatically closes any opened parenthesis and thereby mostly avoids the issue.
Hm, does it mean that Vim does a full syntax highlighting on each keystroke without a delay? Other editors typically do highlighting after a delay not to re-highlight when the user writes the text and it is possible at least to set this delay via preferences.
– Igor Bukanov
Feb 1 at 16:00
Yes, the syntax may adapt after each keystroke; and this is done synchronously. The scope that is considered is set by:syn sync
– Ingo Karkat
Feb 1 at 22:28
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1400744%2fdisable-syntax-highlighting-in-vim-for-new-input-in-insert-mode%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This unfortunately isn't possible. In theory, syntax highlighting could add assertions to the definitions that say "only match this if the cursor is not inside", but as this would make regular expressions more cumbersome (and potentially also much slower), it isn't done.
You only can completely disable / enable syntax highlighting when entering / leaving insert mode, but that would create even more flashing (and potentially cause slowdown as the whole buffer would need to be re-parsed).
The only practical advice I can offer is to use an autoclose plugin (the automatically append closing characters Wiki page describes some simple setups and a list of plugins) that automatically closes any opened parenthesis and thereby mostly avoids the issue.
Hm, does it mean that Vim does a full syntax highlighting on each keystroke without a delay? Other editors typically do highlighting after a delay not to re-highlight when the user writes the text and it is possible at least to set this delay via preferences.
– Igor Bukanov
Feb 1 at 16:00
Yes, the syntax may adapt after each keystroke; and this is done synchronously. The scope that is considered is set by:syn sync
– Ingo Karkat
Feb 1 at 22:28
add a comment |
This unfortunately isn't possible. In theory, syntax highlighting could add assertions to the definitions that say "only match this if the cursor is not inside", but as this would make regular expressions more cumbersome (and potentially also much slower), it isn't done.
You only can completely disable / enable syntax highlighting when entering / leaving insert mode, but that would create even more flashing (and potentially cause slowdown as the whole buffer would need to be re-parsed).
The only practical advice I can offer is to use an autoclose plugin (the automatically append closing characters Wiki page describes some simple setups and a list of plugins) that automatically closes any opened parenthesis and thereby mostly avoids the issue.
Hm, does it mean that Vim does a full syntax highlighting on each keystroke without a delay? Other editors typically do highlighting after a delay not to re-highlight when the user writes the text and it is possible at least to set this delay via preferences.
– Igor Bukanov
Feb 1 at 16:00
Yes, the syntax may adapt after each keystroke; and this is done synchronously. The scope that is considered is set by:syn sync
– Ingo Karkat
Feb 1 at 22:28
add a comment |
This unfortunately isn't possible. In theory, syntax highlighting could add assertions to the definitions that say "only match this if the cursor is not inside", but as this would make regular expressions more cumbersome (and potentially also much slower), it isn't done.
You only can completely disable / enable syntax highlighting when entering / leaving insert mode, but that would create even more flashing (and potentially cause slowdown as the whole buffer would need to be re-parsed).
The only practical advice I can offer is to use an autoclose plugin (the automatically append closing characters Wiki page describes some simple setups and a list of plugins) that automatically closes any opened parenthesis and thereby mostly avoids the issue.
This unfortunately isn't possible. In theory, syntax highlighting could add assertions to the definitions that say "only match this if the cursor is not inside", but as this would make regular expressions more cumbersome (and potentially also much slower), it isn't done.
You only can completely disable / enable syntax highlighting when entering / leaving insert mode, but that would create even more flashing (and potentially cause slowdown as the whole buffer would need to be re-parsed).
The only practical advice I can offer is to use an autoclose plugin (the automatically append closing characters Wiki page describes some simple setups and a list of plugins) that automatically closes any opened parenthesis and thereby mostly avoids the issue.
answered Feb 1 at 7:38
Ingo KarkatIngo Karkat
17.7k22545
17.7k22545
Hm, does it mean that Vim does a full syntax highlighting on each keystroke without a delay? Other editors typically do highlighting after a delay not to re-highlight when the user writes the text and it is possible at least to set this delay via preferences.
– Igor Bukanov
Feb 1 at 16:00
Yes, the syntax may adapt after each keystroke; and this is done synchronously. The scope that is considered is set by:syn sync
– Ingo Karkat
Feb 1 at 22:28
add a comment |
Hm, does it mean that Vim does a full syntax highlighting on each keystroke without a delay? Other editors typically do highlighting after a delay not to re-highlight when the user writes the text and it is possible at least to set this delay via preferences.
– Igor Bukanov
Feb 1 at 16:00
Yes, the syntax may adapt after each keystroke; and this is done synchronously. The scope that is considered is set by:syn sync
– Ingo Karkat
Feb 1 at 22:28
Hm, does it mean that Vim does a full syntax highlighting on each keystroke without a delay? Other editors typically do highlighting after a delay not to re-highlight when the user writes the text and it is possible at least to set this delay via preferences.
– Igor Bukanov
Feb 1 at 16:00
Hm, does it mean that Vim does a full syntax highlighting on each keystroke without a delay? Other editors typically do highlighting after a delay not to re-highlight when the user writes the text and it is possible at least to set this delay via preferences.
– Igor Bukanov
Feb 1 at 16:00
Yes, the syntax may adapt after each keystroke; and this is done synchronously. The scope that is considered is set by
:syn sync
– Ingo Karkat
Feb 1 at 22:28
Yes, the syntax may adapt after each keystroke; and this is done synchronously. The scope that is considered is set by
:syn sync
– Ingo Karkat
Feb 1 at 22:28
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1400744%2fdisable-syntax-highlighting-in-vim-for-new-input-in-insert-mode%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown