Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

2 spaces indentation in google Docs

Tags:

google-docs

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 ?

like image 528
salamanka44 Avatar asked Apr 29 '16 07:04

salamanka44


People also ask

What is a two space indent?

If you represent the indents using space characters (ASCII SP), then 2 spaces is 2 characters fewer than 4 spaces. If you allow TAB characters to be used, then (on Windows) a TAB indents by up to 4 spaces, so TAB characters result in fewer characters.

How do I change the indentation spacing in Google Docs?

Select the text you want to indent. Click the Increase indent shortcut button to increase the indent by increments of a half-inch. All lines of the paragraph will indent. Click the Decrease indent shortcut button to decrease the indent by increments of a half-inch.

Why won't Google Docs let me indent the second line?

Click the View tab at the top of the window. Select the Show Ruler option if it's not already selected. Select the text to indent. Drag the left indent triangle on the ruler to the desired location.


2 Answers

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

like image 79
Nisha Sinha Avatar answered Sep 23 '22 01:09

Nisha Sinha


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

like image 28
scaiferw Avatar answered Sep 21 '22 01:09

scaiferw