vim newb - indenting python comments

I

infixum

I'm just starting to use vim. It has helped me do a lot of repetitive
editing of Python files.

One problem I have is that the >> indent in normal mode doesn't work
when a line starts with the # character. Any idea what I'm doing
wrong?

Thanks in advance for your help.
 
T

Tim Chase

One problem I have is that the >> indent in normal mode doesn't work
when a line starts with the # character. Any idea what I'm doing
wrong?

In short, ">>" *does* indent in normal mode (I presume you
accurately mean "Normal" mode, rather than "Insert" mode). The
question becomes why doesn't it work in your particular copy of Vim?

To evidence this, start vim with

vim -u NONE myfile.py

(which bypasses startup files) and you'll see that >> does indeed
shift commented lines.

To track down the problem, you'll need to provide a little more
info. Starting Vim the way you normally do, pointed at a
problematic python file, what is the output of

:scriptnames

What mappings do you have defined:

:nmap

(particularly any mappings for ">" and its kin).

What are your filetype settings:

:filetype

What are your settings for 'indentkeys', 'indentexpr',
'shiftwidth', 'tabstop', 'expandtab' and 'filetype'

:set indentkeys? indentexpr? sw? ts? et? ft?

Which version of Vim are you using:

:version

Hopefully some of those will point you at the problem child.
Otherwise, drop by the Vim mailing list and there are a lot of
other smart cookies there that may have other ideas.

-tkc
 
I

infixum

In short, ">>" *does* indent in normal mode (I presume you
accurately mean "Normal" mode, rather than "Insert" mode).  The
question becomes why doesn't it work in your particular copy of Vim?

To evidence this, start vim with

  vim -u NONE myfile.py

(which bypasses startup files) and you'll see that >> does indeed
shift commented lines.

It worked just as you described.
To track down the problem, you'll need to provide a little more
info.  Starting Vim the way you normally do, pointed at a
problematic python file, what is the output of

  :scriptnames

There are 16 in all. I feel a bit foolish in that I had no idea these
were being loaded (sourced?).
What mappings do you have defined:

  :nmap

(particularly any mappings for ">" and its kin).

What are your filetype settings:

  :filetype

What are your settings for 'indentkeys', 'indentexpr',
'shiftwidth', 'tabstop', 'expandtab' and 'filetype'

  :set indentkeys? indentexpr? sw? ts? et? ft?

Which version of Vim are you using:

  :version

7.1 under Cygwin on Windows XP
Hopefully some of those will point you at the problem child.
Otherwise, drop by the Vim mailing list and there are a lot of
other smart cookies there that may have other ideas.

-tkc

Thanks; this is already really helpful. I'm going to try to sift
through those 16 scripts and try to familiarize myself with vim
customization a bit more. I may be back, but you've given me some
help to get over the hump and start learning the tool. Thanks again.
 
R

Robert Kern

Tim said:
In short, ">>" *does* indent in normal mode (I presume you
accurately mean "Normal" mode, rather than "Insert" mode). The
question becomes why doesn't it work in your particular copy of Vim?

To evidence this, start vim with

vim -u NONE myfile.py

(which bypasses startup files) and you'll see that >> does indeed
shift commented lines.

To track down the problem, you'll need to provide a little more
info. Starting Vim the way you normally do, pointed at a
problematic python file, what is the output of

:scriptnames

What mappings do you have defined:

:nmap

(particularly any mappings for ">" and its kin).

What are your filetype settings:

:filetype

What are your settings for 'indentkeys', 'indentexpr',
'shiftwidth', 'tabstop', 'expandtab' and 'filetype'

:set indentkeys? indentexpr? sw? ts? et? ft?

:set cindent?

Having this set (in the absence of anything else) will replicate the behavior
for me (vim 7.1 OS X).

:filetype plugin on
:filetype indent on

Fixes it.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top