I’m working on programming assignments and my instructor requires us to use Google Docs instead of regular code editors. I know it sounds weird but that’s what we have to do.
I always use 2-space indentation when coding and I’m trying to figure out how to do this efficiently in Google Docs. Are there any keyboard shortcuts or maybe extensions that can help with this?
The main issue is when I’m writing code blocks like loops or conditionals. Let’s say my code starts at column 2 and I need the inner block to start at column 4. In a normal editor this happens automatically but in Google Docs the cursor just goes back to the beginning of each new line.
Has anyone found a good way to handle proper code indentation in Google Docs? Any tricks or workarounds would be really helpful.
I faced a similar challenge while working on programming assignments that required Google Docs. The best solution I found was to set up custom indentation using the ruler. You can adjust the indent settings under Format > Align & indent > Indentation options, setting it to 2 spaces. This allows you to use the Tab key for your nested code blocks, which helps maintain consistency. While it may seem cumbersome at first, it quickly becomes a fluid process as you adapt your writing style.
honestly the easiest trick i found is just using ctrl+] to increase indent quickly. you can hit it multiple times to get your 2-space increments. way faster than messing with rulers and stuff. ctrl+[ does the opposite to outdent when you need it.
In a similar situation, I found that creating a custom paragraph style for code formatting was extremely helpful. By navigating to Format > Paragraph styles > Options > Save as my default styles, you can set your indentation levels using the ruler feature at the top. Drag the left indent marker to achieve the desired spacing for each level of nesting. Although this requires some initial setup, once your styles are saved, they can be applied quickly to your text. Additionally, enabling the ruler visibility can make managing indentation a lot easier visually, although you will still need to manually apply these styles as you type.