Tim Chase <[email protected]> [09-09-20 11:14]:
>
> > I am a C/C++-programmer.
> > And I a first time tourist in the world of python.
>
> welcome to my favorite language :)
>
> > Since python does not have start-/end-of-block
> > marker a la "{}" in C: How can I indent a
> > block of code? How does vim know, how large
> > such a block is, where it starts and where it
> > ends? How can I acchieve, what "==" does for
> > C/C++-code?
>
> Because C-like languages use secondary indicators for block
> identification ({...}), the reformat commands in vim take the
> known block structure and makes indentation match. Because
> python uses indentation *as* the block identification, your
> question becomes akin to "how do I get vim to automatically
> insert '{' and '}' in my C code where I want them?". And the
> [un?]fortunate answer is that you can't -- it involves knowing
> the programmer's intent.
>
> It took me all of 5 minutes to get past the "aagh, there are no
> block-delimiters other than indentation" aspect of Python and I
> realized that I already indented my C-like languages exactly as I
> did my Python, so I was saving typing and the possibility of
> getting my braces out of sync with my intent. The "dangling
> else" is notorious in C-like languages (yes, coding standards
> that require braces for both if/else parts help, but you become
> redundant when you add braces *and* indentation), where you have
>
> if (condition)
> do_a();
> else
> do_b();
> do_c();
>
> The indentation shows the programmer's indent, but the parser
> doesn't understand that and instead sees
>
> if (condition)
> {
> do_a();
> }
> else
> {
> do_b();
> }
> do_c();
>
> By relying on indentation, Python does what the developer
> intended/expected.
>
> Anyways, enough rambling about python for me. Off to bed :)
>
> -tim
>
>
>
>
>
Hi Tim,
thanks for your reply. My opinion about the python style
of isyntactically indentation is a little different,
but I dont want to start a flame war here ... ;)
What remains is my question:
How can I ident python code?
Suppose I have
for ...
a = ...
b = ...
c = ...
and want
for ...
a =
b =
c =
Pressing TABs in each line?
Marking a visual block and do a I^V^I<esc>?
Or there something more efficient?
Best regards,
mcc
--
Please don't send me any Word- or Powerpoint-Attachments
unless it's absolutely neccessary. - Send simply Text.
See http://www.gnu.org/philosophy/no-word-attachments.html
In a world without fences and walls nobody needs gates and windows.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---