2 spaces indentation in google Docs
Asked Answered
D

4

7

To prepare an exam, I have to learn coding using google docs rather than using an IDE. It may seem idiot or impratical but the teacher really insists on that. It seems that is the same thing as Google interviews for example...

So far, I really got used with using two spaces indentation (I hate using tab indendation). And I want to learn how can I do that quickly in Google docs. Is there a shortcut or a "tips" (add-on?) for that?

For example, if you have an "if-condition" starting at the position number 4 and you want to move to the following line, it can be really convenient to have the cursor position at 4. Then, you'll add two spaces to start your block at position number 6. (ALL the if block will have at least position 6). But in Docs, when you move to the following line, the cursor always start at the beginning of the line except if you use the tab indentation. And it's really shitting if you want to indent your code properly...

Do you have a solution for that please ?

Djokjakarta answered 29/4, 2016 at 7:14 Comment(3)
Can't you program within a text editor and paste the results into Google docs? Also are you sure you are supposed to write in the doc, not use the script editor in there?Deficit
I'm afraid not. Google Docs is the only thing that I can use here. I thought it may be a common situation but it seems that we are only genius in my class lolDjokjakarta
These are features you would typically find in an IDE, I imagine part of forcing you to not use an IDE is for the experience of having to indent your code manually.Desdamonna
L
10

I was facing the same problem. To write Python code in google docs, my solution is:

  1. Switch off auto-capitalization, auto-correction and smart quotes. And other auto-substitutions so that you may write code without docs like formatting.

To do this: Tools> Preferences and uncheck the above items. Screen shots attached below.

  1. Set tab to two spaces. Right-click on ruler on top of page. Add left-tab stop, an arrow will appear, move this tab stop to 2 spaces from left of ruler. Try adding tab in the current line and if the tab size is OK, save this formatting.

To save: Format > Paragraph Styles > Normal Text > Update 'Normal Text' to match.

  1. Last, to add color(synatx highlight), you may use 'code blocks extension'. Click install.

Now, write code in docs, select the code in google doc, click on: Add-ons > Code Block. A pop up opens up. Choose language : 'python' for me. Choose theme: 'atom-one-dark' click Format.

The code looks much like IDE, and writing more code is easier too.

My Preferences screenshotSubstitutions screenshot

Lubric answered 18/4, 2021 at 3:17 Comment(2)
Thanks to you, I could discover the ruler of the top, and it is very usefulWallack
Does this work for only the top-level tab?Ringside
K
3

While I understand that sometimes a point can be made by making students do things in a way that might not seem logical, this one doesn't make any sense to me.

Students don't learn anything useful by pressing space twice instead of letting an editor or IDE do it for them.

I wonder, is it because he/she wants it delivered in Google Docs or because they want you coding that way? If it's the latter, you won't have to hide your workaround.

I can only suggest using a good text editor, I always use the excellent and free Notepad++, and copy and paste it to and from Google Docs. Your instructor will never know. In fact, I'd be hunting around to see of there was a way to access your code files directly in Google Docs from Notepad++, or to auto-sync a folder with Google docs.

Notepad++ has syntax colouring - which will save your life - and can be set to indent with tabs or spaces to whatever indent width you specify. If not using an IDE, I only use Notepad++.

Your instructor sounds like some I had, people who cross a line from being quirky but with a point to make to just being a dick. There is absolutely no point in telling a student to code only in Google docs. Google docs is a great thing, I love it, but it is by no stretch of the imagination a coding tool.

(I see that this is an aged thread, but I'll respond in case someone else with a similar issue - like this year's class for that course - comes looking for an answer.)

Keishakeisling answered 2/11, 2017 at 13:55 Comment(1)
Likely the reason the teacher is insisting on this is because Google Docs is used for Google phone interviews. Worth getting practice with it.Hemidemisemiquaver
S
0

You could try (ab)using bulleted lists:

  1. Insert a bulleted list
  2. Right click on the bullet, select "More bullets..."
  3. In the "Symbol" selection list, choose "Format & whitespace" and select one of the whitespace options as bullet char
  4. Repeat for as many levels (of bullet sub-lists) as you think you may need in your program
  5. Fix indentation to match whatever feels best for you

Every time you need to write a nested block, you will have to press "tab" only once, then bullet list level is kept and the indentation with it. To go back to the outer block, just press shift-tab.

However, IMHO it doesn't worth the trouble. Generally, interview question solutions are not that large and hitting spacebar a couple of times is not much of an overhead.

Sanskritic answered 4/5, 2016 at 13:0 Comment(0)
B
0

It's somewhat cumbersome but you can set as many tab stops as you want, and docs will move nested tabs to the next tab stop as well. For example:

tab stops

You can add tab stops by right clicking on that tab bar where you want the tab stop to be and clicking Add left tab stop. You'll want to have all text in the document selected if you want the tab stop to apply everywhere.

Briefcase answered 6/6, 2021 at 0:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.