Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

I am trying to paste a piece of code in my Google+ stream but it removes the whitespace 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.

share|improve this question
add comment

6 Answers

up vote 11 down vote accepted

You could add the code to something like Pastebin;

http://pastebin.com/

and then share it as a link.

Hope this helps.

share|improve this answer
add comment

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 keyboard shortcut... How I used it is:

  1. I opened Charmap and
  2. changed options to display Unicode subranges;
  3. Selected General Punctuation range group
  4. Third group 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 Select
  7. 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.

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

I made a tool for converting code to Google+ compatible code. You find it at http://www.claudiodangelis.it/projects/googlepluscodeindenter

Here an example post: https://plus.google.com/u/0/115859961800127275872/posts/Sg9aSkCwTft

Hope this helps.

share|improve this answer
add comment

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.

share|improve this answer
add comment

I use to specify indent:

function factorial(x) {
⠂var result = 1;
⠂while(x > 1) {
⠂⠂result *= x;
⠂⠂x--;
⠂}
⠂return result;
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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