How to indent my code in codeblocks?

前端 未结 6 1246
野趣味
野趣味 2020-12-31 06:55

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 ? <

相关标签:
6条回答
  • 2020-12-31 07:26

    I have not had much luck with the code formatter in C::B. I like my code to look like this...

    if (blah..) {
      SomeCode();
    } else {
      DifferentCode();
    }
    

    it allows more code to fit on a screen, and is still reasonably readable.

    After trying to tweak the settings in Settings->Editor, then Source Formatter tab, when I went to format my code, it removed the if line entirely, and I have not been able to unset my tweaks to make it work.

    Fornatually, ctrl-z still works.

    The code formatter should never remove code, only play with white space.

    Maybe there is a better plugin.

    Mark.

    0 讨论(0)
  • 2020-12-31 07:29

    CTRL+A to select the code and TAB for alignment.

    0 讨论(0)
  • 2020-12-31 07:31

    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).

    0 讨论(0)
  • 2020-12-31 07:46

    In addition in How to switch between tabs in codeblocks.

    codebocks 20.03
    Linux (KDE Neon)

    To switch between tabs.

    Activate this with CTRL+SHIFT+TAB, then you can use the know options:

    • CTRL+TAB , to switch to the right tab.

    • CTRL+SHIFT+TAB , to switch to the left tab.

    • Or this other option, but this is not in the keyboard shortcuts, this option doesn't work in a cycle mode, when your get the last right tab, it jump to the bottom tabs:

      • CTRL+ right-arrow-key , to switch to the right tab.
      • CTRL+ left-arrow-key , to switch to the left tab.

    Remember to activate with CTRL+SHIFT+TAB.

    After you land in the desire tab you can type TAB to begin to start writing code.

    0 讨论(0)
  • 2020-12-31 07:49

    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!

    0 讨论(0)
  • 2020-12-31 07:52

    ]2

    Add shortcut as you wish from Settings->Editor->Keyboard shortcuts->plugins->Source code formatters(Astyle) or use Plugins->Source code formatters(Astyle)

    0 讨论(0)
提交回复
热议问题