17

I am trying to paste a piece of code in my Google+ stream but it removes the white space from the start of the lines making the code less appealing, aesthetically speaking. Basically, the functionality that I'm after is the "Code Sample" button of the WYSIWYG editor that I'm writing on right now.

12

You could add the code to something like Pastebin;

http://pastebin.com/

and then share it as a link.

Hope this helps.

10

Em space works!

I've finally cracked this indentation issue in Google+. I use em space and Google+ doesn't simply remove/replace it. It stays there.

The only problem is how do you type it out? Its Unicode code is U+2003 but there's not any keyboard shortcut... How I used it is:

  1. Open Character Map.
  2. Change options to display By Unicode Block.
  3. Select General Punctuation Unicode Block.
  4. Starting characters starts with seemingly empty boxes, because they represent all kinds of different space characters, then continue with various dashes.
  5. Click on the first empty box and move to the next until you get to em space (look for description in status bar).
  6. Click Copy.

Then you can simply go and edit your Google+ post and paste it as many times as you need to indent your code.

Following is the screenshot for the Character Map program with em space selected:

em space in Character Map

This procedure seems complicated, but it's not really. These are few fast and easy steps. It's also true that you most likely don't put code in all of your posts anyway.

Here's a link to Google+ post that also includes some indented code.

9

Google+ doesn't offer many formatting options. At best it offers a very watered down version of Markdown, with only bold, italic, and strikethrough.

So unless and until Google adds more options you're out of luck.

The only other possible option would be to create a GIF with the text of your code and include that in your post.

2

Google have apparently recently made a change to Google+ whereby the spaces at the beginning and/or end of a line for both posts and comments is retained rather than discarded, which was the previous behavior.

I just tested it and it works.

1

I use to specify indent:

function factorial(x) {
⠂var result = 1;
⠂while(x > 1) {
⠂⠂result *= x;
⠂⠂x--;
⠂}
⠂return result;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.