Stop vim from messing up my indentation on comments
For some reason Vim thinks all of my comments should have all indentation removed. If I add #
to the beginning of a line, suddenly all leading whitespace is removed. How can I stop this?
I have Janus and NERDtree installed, in case it's relevent, along with copious other personal configurations in my .vimrc
, but none that (as far as I know) would cause such behavior.
vim vi
add a comment |
For some reason Vim thinks all of my comments should have all indentation removed. If I add #
to the beginning of a line, suddenly all leading whitespace is removed. How can I stop this?
I have Janus and NERDtree installed, in case it's relevent, along with copious other personal configurations in my .vimrc
, but none that (as far as I know) would cause such behavior.
vim vi
add a comment |
For some reason Vim thinks all of my comments should have all indentation removed. If I add #
to the beginning of a line, suddenly all leading whitespace is removed. How can I stop this?
I have Janus and NERDtree installed, in case it's relevent, along with copious other personal configurations in my .vimrc
, but none that (as far as I know) would cause such behavior.
vim vi
For some reason Vim thinks all of my comments should have all indentation removed. If I add #
to the beginning of a line, suddenly all leading whitespace is removed. How can I stop this?
I have Janus and NERDtree installed, in case it's relevent, along with copious other personal configurations in my .vimrc
, but none that (as far as I know) would cause such behavior.
vim vi
vim vi
edited Dec 25 '13 at 3:30
iconoclast
asked Dec 24 '13 at 20:53
iconoclasticonoclast
3,82163870
3,82163870
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
This is a battle I fought as well, and think I finally won. The problem is that there are a dozen different ways the behavior can be overridden (by plugins/syntaxes).
Here's all the settings I had to use to win the battle:
set nosmartindent
set cindent
filetype plugin indent on
set cinkeys-=0#
set indentkeys-=0#
autocmd FileType * set cindent "some file types override it
With the autocmd
, the first set cindent
shouldn't be necessary, but this is one of those things where I kept adding lines until the behavior went away.
I was able to skip the last two lines and still solve the problem
– iconoclast
Dec 25 '13 at 3:50
1
@iconoclast note though that you may still have issues with some types of files. The last line is because some syntax files override indentation settings.
– Patrick
Dec 25 '13 at 10:07
1
OMG!!!set indentkeys-=0#
!! FINALLY MY SUFFERING IS OVER!!!!!!!!
– Kasapo
Nov 26 '18 at 16:19
add a comment |
You might want to check out the Vim Wiki Indenting source code page and checkout how 'autoindent' works.
add a comment |
ref this answer:
http://vim.wikia.com/wiki/Restoring_indent_after_typing_hash
modify to:
set nosmartindent
set cindent
set cinkeys-=0#
set indentkeys-=0#
or:
:inoremap # X<BS>#
add a comment |
I have sloved the problem by commenting set smartindet
.
New contributor
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2funix.stackexchange.com%2fquestions%2f106526%2fstop-vim-from-messing-up-my-indentation-on-comments%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is a battle I fought as well, and think I finally won. The problem is that there are a dozen different ways the behavior can be overridden (by plugins/syntaxes).
Here's all the settings I had to use to win the battle:
set nosmartindent
set cindent
filetype plugin indent on
set cinkeys-=0#
set indentkeys-=0#
autocmd FileType * set cindent "some file types override it
With the autocmd
, the first set cindent
shouldn't be necessary, but this is one of those things where I kept adding lines until the behavior went away.
I was able to skip the last two lines and still solve the problem
– iconoclast
Dec 25 '13 at 3:50
1
@iconoclast note though that you may still have issues with some types of files. The last line is because some syntax files override indentation settings.
– Patrick
Dec 25 '13 at 10:07
1
OMG!!!set indentkeys-=0#
!! FINALLY MY SUFFERING IS OVER!!!!!!!!
– Kasapo
Nov 26 '18 at 16:19
add a comment |
This is a battle I fought as well, and think I finally won. The problem is that there are a dozen different ways the behavior can be overridden (by plugins/syntaxes).
Here's all the settings I had to use to win the battle:
set nosmartindent
set cindent
filetype plugin indent on
set cinkeys-=0#
set indentkeys-=0#
autocmd FileType * set cindent "some file types override it
With the autocmd
, the first set cindent
shouldn't be necessary, but this is one of those things where I kept adding lines until the behavior went away.
I was able to skip the last two lines and still solve the problem
– iconoclast
Dec 25 '13 at 3:50
1
@iconoclast note though that you may still have issues with some types of files. The last line is because some syntax files override indentation settings.
– Patrick
Dec 25 '13 at 10:07
1
OMG!!!set indentkeys-=0#
!! FINALLY MY SUFFERING IS OVER!!!!!!!!
– Kasapo
Nov 26 '18 at 16:19
add a comment |
This is a battle I fought as well, and think I finally won. The problem is that there are a dozen different ways the behavior can be overridden (by plugins/syntaxes).
Here's all the settings I had to use to win the battle:
set nosmartindent
set cindent
filetype plugin indent on
set cinkeys-=0#
set indentkeys-=0#
autocmd FileType * set cindent "some file types override it
With the autocmd
, the first set cindent
shouldn't be necessary, but this is one of those things where I kept adding lines until the behavior went away.
This is a battle I fought as well, and think I finally won. The problem is that there are a dozen different ways the behavior can be overridden (by plugins/syntaxes).
Here's all the settings I had to use to win the battle:
set nosmartindent
set cindent
filetype plugin indent on
set cinkeys-=0#
set indentkeys-=0#
autocmd FileType * set cindent "some file types override it
With the autocmd
, the first set cindent
shouldn't be necessary, but this is one of those things where I kept adding lines until the behavior went away.
answered Dec 24 '13 at 22:46
PatrickPatrick
50.6k11131181
50.6k11131181
I was able to skip the last two lines and still solve the problem
– iconoclast
Dec 25 '13 at 3:50
1
@iconoclast note though that you may still have issues with some types of files. The last line is because some syntax files override indentation settings.
– Patrick
Dec 25 '13 at 10:07
1
OMG!!!set indentkeys-=0#
!! FINALLY MY SUFFERING IS OVER!!!!!!!!
– Kasapo
Nov 26 '18 at 16:19
add a comment |
I was able to skip the last two lines and still solve the problem
– iconoclast
Dec 25 '13 at 3:50
1
@iconoclast note though that you may still have issues with some types of files. The last line is because some syntax files override indentation settings.
– Patrick
Dec 25 '13 at 10:07
1
OMG!!!set indentkeys-=0#
!! FINALLY MY SUFFERING IS OVER!!!!!!!!
– Kasapo
Nov 26 '18 at 16:19
I was able to skip the last two lines and still solve the problem
– iconoclast
Dec 25 '13 at 3:50
I was able to skip the last two lines and still solve the problem
– iconoclast
Dec 25 '13 at 3:50
1
1
@iconoclast note though that you may still have issues with some types of files. The last line is because some syntax files override indentation settings.
– Patrick
Dec 25 '13 at 10:07
@iconoclast note though that you may still have issues with some types of files. The last line is because some syntax files override indentation settings.
– Patrick
Dec 25 '13 at 10:07
1
1
OMG!!!
set indentkeys-=0#
!! FINALLY MY SUFFERING IS OVER!!!!!!!!– Kasapo
Nov 26 '18 at 16:19
OMG!!!
set indentkeys-=0#
!! FINALLY MY SUFFERING IS OVER!!!!!!!!– Kasapo
Nov 26 '18 at 16:19
add a comment |
You might want to check out the Vim Wiki Indenting source code page and checkout how 'autoindent' works.
add a comment |
You might want to check out the Vim Wiki Indenting source code page and checkout how 'autoindent' works.
add a comment |
You might want to check out the Vim Wiki Indenting source code page and checkout how 'autoindent' works.
You might want to check out the Vim Wiki Indenting source code page and checkout how 'autoindent' works.
answered Dec 24 '13 at 21:27
KiffinKiffin
28815
28815
add a comment |
add a comment |
ref this answer:
http://vim.wikia.com/wiki/Restoring_indent_after_typing_hash
modify to:
set nosmartindent
set cindent
set cinkeys-=0#
set indentkeys-=0#
or:
:inoremap # X<BS>#
add a comment |
ref this answer:
http://vim.wikia.com/wiki/Restoring_indent_after_typing_hash
modify to:
set nosmartindent
set cindent
set cinkeys-=0#
set indentkeys-=0#
or:
:inoremap # X<BS>#
add a comment |
ref this answer:
http://vim.wikia.com/wiki/Restoring_indent_after_typing_hash
modify to:
set nosmartindent
set cindent
set cinkeys-=0#
set indentkeys-=0#
or:
:inoremap # X<BS>#
ref this answer:
http://vim.wikia.com/wiki/Restoring_indent_after_typing_hash
modify to:
set nosmartindent
set cindent
set cinkeys-=0#
set indentkeys-=0#
or:
:inoremap # X<BS>#
edited Jul 28 '16 at 14:29
Kevdog777
2,107123259
2,107123259
answered Jul 28 '16 at 13:50
extr15extr15
211
211
add a comment |
add a comment |
I have sloved the problem by commenting set smartindet
.
New contributor
add a comment |
I have sloved the problem by commenting set smartindet
.
New contributor
add a comment |
I have sloved the problem by commenting set smartindet
.
New contributor
I have sloved the problem by commenting set smartindet
.
New contributor
New contributor
answered 1 min ago
GH1995GH1995
1
1
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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%2funix.stackexchange.com%2fquestions%2f106526%2fstop-vim-from-messing-up-my-indentation-on-comments%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