Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to indent my code in codeblocks?

Tags:

codeblocks

What are the best code blocks short cuts ? Also is there some way we can directly indent all our code ? In addition how can we move through the active tabs in codeblocks ?

like image 281
Nikunj Banka Avatar asked Feb 05 '13 12:02

Nikunj Banka


People also ask

What key can you use to help indent your code blocks accurately?

Highlight the lines of text. Then hit tab to indent them a level to the right, and shift-tab to outdent them a level to the left.


2 Answers

Tips about tab identation are helpful when you write your code from begining. But if you paste code in CodeBlocks from some external source, like PDF document, that code often will not have good identation.

In this case, you need to select code, right click on it, and choose Format use AStyle option. This is a plugin for CodeBlocks for right text formatting.

I hope this will help someone!

like image 140
akelec Avatar answered Sep 18 '22 09:09

akelec


You (these are the default settings I believe) can select a block of code and press the Tab key. This will indent the entire block.

So for indenting a whole file: Ctrl + A, then Tab.

In addition, you can use Shift + Tab on a selected block to "unindent"

You can move through the open tabs with Ctrl + Shift + Tab.

As for the best shortcuts:

I like Ctrl + D to duplicate a line and

Ctrl + L to copy it.

Anyway, you can set whatever shortkeys you like in the Editor menu (there you will also be able to find all shortkey currently set).

like image 22
Aleph Avatar answered Sep 20 '22 09:09

Aleph