Stupid unindenting when starting a comment with #

0 views
Skip to first unread message

skawaii

unread,
Aug 27, 2007, 2:39:51 PM8/27/07
to vim...@googlegroups.com

I've run into this every time I work on some Ruby and Python code and it's
really starting to irritate me. When I'm indented and start a comment with
#, the line becomes completely unindented. To illustrate:

Before:
for (blah blah blah): blah blah blah
<-- cursor is here

After:
for (blah blah blah): blah blah blah
# <-- the indentation has been dominated

Anyone know how to fix this?

Thanks.
--
View this message in context: http://www.nabble.com/Stupid-unindenting-when-starting-a-comment-with---tf4057169.html#a11525218
Sent from the Vim - General mailing list archive at Nabble.com.

Fuzzy Logic

unread,
Aug 27, 2007, 3:06:45 PM8/27/07
to vim...@googlegroups.com
I imagine you could see :help smartindent for a solution to this.

Fuzzy


--
Latin: Dum spiro spero.
English: While I breathe, I hope.

Mike Hansen

unread,
Aug 27, 2007, 3:25:10 PM8/27/07
to vim...@googlegroups.com

> -----Original Message-----
> From: vim...@googlegroups.com
> [mailto:vim...@googlegroups.com] On Behalf Of skawaii
> Subject: Stupid unindenting when starting a comment with #
>
> I've run into this every time I work on some Ruby and Python
> code and it's
> really starting to irritate me. When I'm indented and start a
> comment with
> #, the line becomes completely unindented. To illustrate:
>
> Before:
> for (blah blah blah): blah blah blah
> <-- cursor is here
>
> After:
> for (blah blah blah): blah blah blah
> # <-- the indentation has been dominated
>
> Anyone know how to fix this?
>
> Thanks.

In your .vimrc, make sure you have "filetype indent on". You probably
don't need "set smartindent".

I think that's what fixed it for me.

Mike

ska...@gmail.com

unread,
Aug 27, 2007, 3:50:47 PM8/27/07
to vim_use
"filetype indent on" did the trick. Thanks for the tip. I couldn't
find the answer to this anywhere (although it has been a month or so
since I've looked).

Thanks!

Dave Land

unread,
Aug 27, 2007, 10:15:13 PM8/27/07
to vim...@googlegroups.com
Thanks for "filetype indent on" *and* the instruction to leave
"set smartindent" off -- that was getting in the way, too.

Yongwei Wu

unread,
Aug 28, 2007, 12:17:10 AM8/28/07
to vim...@googlegroups.com
On 28/08/07, ska...@gmail.com <ska...@gmail.com> wrote:
>
> "filetype indent on" did the trick. Thanks for the tip. I couldn't
> find the answer to this anywhere (although it has been a month or so
> since I've looked).

Have you checked Fuzzy's answer? To be clearer, I am pasting from the
help file about smartindent:

When typing '#' as the first character in a new line, the indent for
that line is removed, the '#' is put in the first column. The
indent is restored for the next line. If you don't want this, use
this mapping: ":inoremap # X^H#", where ^H is entered with CTRL-V
CTRL-H.

Also be sure to bottom-post, as I am doing.

Best regards,

Yongwei

--
Wu Yongwei
URL: http://wyw.dcweb.cn/

Reply all
Reply to author
Forward
0 new messages