Indentation

This is the place for queries that don't fit in any of the other categories.

Indentation

Postby benwhelan94 » Mon May 12, 2014 6:57 pm

Hello, i was just wondering if there is a way to quickly indent a mass line of codes in one action?

say i have

Code: Select all
code:
    code
    code
    code
code:
   code:
      code
      code


and i want to push it all forwards by one indentation (4), how can i do this quickly?
benwhelan94
 
Posts: 19
Joined: Wed Apr 23, 2014 1:25 pm

Re: Indentation

Postby micseydel » Mon May 12, 2014 7:02 pm

That will depend on your editor. Common ones I'm aware of are to highlight all the lines you care about, then either press Tab or Ctrl+]. Your editor might have something different instead though, so if you let us know what it is, or simply Google it for your editor, you can get a more specific answer.
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1443
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: Indentation

Postby benwhelan94 » Mon May 12, 2014 7:03 pm

idle!
benwhelan94
 
Posts: 19
Joined: Wed Apr 23, 2014 1:25 pm

Re: Indentation

Postby micseydel » Mon May 12, 2014 7:04 pm

Highlight the lines, then hit the Tab key.
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1443
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: Indentation

Postby 7stud » Mon May 12, 2014 7:06 pm

On my editor, macvim, I can highlight the code, and hit '>' or '<' to indent or unindent. If I type a 2 before the arrow, macvim will move two indents either way.
7stud
 
Posts: 106
Joined: Wed Apr 02, 2014 2:36 am

Re: Indentation

Postby 7stud » Mon May 12, 2014 7:07 pm

idle!

Fyi, you are using the worst text editor in existence.
7stud
 
Posts: 106
Joined: Wed Apr 02, 2014 2:36 am

Re: Indentation

Postby benwhelan94 » Mon May 12, 2014 7:13 pm

haha why's it so bad? tbh only using it because its what they use at my uni, and i'm a noob beginner. Any recommendations for a new one would be welcomed!
benwhelan94
 
Posts: 19
Joined: Wed Apr 23, 2014 1:25 pm

Re: Indentation

Postby snippsat » Mon May 12, 2014 9:11 pm

Any recommendations for a new one would be welcomed!

There is a post about editor's for Python here.
viewtopic.php?f=10&t=11200
User avatar
snippsat
 
Posts: 273
Joined: Thu Feb 21, 2013 12:04 am

Re: Indentation

Postby Marbelous » Mon May 12, 2014 10:35 pm

IDLE is very basic and can have issues if you execute your code from within the editor. BUT, it ships with Python, does the job and is easy to learn so there's no reason to dismiss it out of hand. Especially if your teachers and fellow students are using it. I often use it on my Raspberry Pi computers. I just use it for an editor and run my code from the command line. For any bigger projects I love the Pycharm 3 Free edition (but it has a learning curve all its own).

Cntl-] and Cntl-[ are the indent and un-indent shortcuts. TAB is actually the code completion function.

BTW, did it really not dawn on you to look in the EDIT and FORMAT menus before you posted this question??? :? Check it out, there are other shortcuts you may like.
Marbelous
 
Posts: 155
Joined: Fri May 31, 2013 8:12 pm


Return to General Coding Help

Who is online

Users browsing this forum: Google [Bot] and 3 guests