This question has been flagged
1 Reply
6164 Views

Helloooooooooooooooooooooooooooooooooooo!

I publish many posts on this forum. You know.

Are you able to copy/paste your code/text from your computer to this forum with all indentation and line changes kept?

Each time I copy and paste code on this forum, I have to reindent all my code and I have to redo all line changes (enter).

It is really really annoying...

And you?

In image :

When I paste code on the forum, it is like this.


EDIT #1

For the first time in my life, I managed to paste code WITH ENDS OF LINE RESPECTED!!!! 


This one was ok (my first!!!) on pasting. Ends of line kept!



These two don't keep ends of line on pasting :




EDIT #2

When I paste some code on any other sites, it works each time. All my EOL are respected.








Avatar
Discard
Best Answer

Here are some steps that I use for that

1- Copy the text into a simple text editor like Gedit or notepad just to clear the format of the text source

2- Paste it into the place where you wanna have the text at the end

3- Select the text pasted and apply the code style from the wand style dropdown menu

and that's all

Note: Always is better to just left a line at the end of the post with any character just to be able to continue writing after the code style applied

#Edit: Another way that works in more complex scenarios

class purchase_requisition(osv.osv):
    _name = "purchase.requisition"
    _description = "Purchase Requisition"
    _inherit = ['mail.thread', 'ir.needaction_mixin']

    def _get_po_line(self, cr, uid, ids, field_names, arg=None, context=None):
        result = dict((res_id, []) for res_id in ids)
        for element in self.browse(cr, uid, ids, context=context):
            for po in element.purchase_ids:
                result[element.id] += [po_line.id for po_line in po.order_line]
        return result

That's how I do it

This is the screencast:

Avatar
Discard
Author

My text is always in UTF-8 encoding. I have tried many browser, many text editor. Impossible to keep line changes when I paste.

I update with another way I use that always works!!, see the screencast

Author

Do you indent your code with spaces or tabs?

Author

Your trick with the Browser Inspector (edit as html) works well with Python code. But not with the XML. Probably because XML is tagged. I have tried many encoding, many browser, many eof... Nothing stable. On other forum, when I paste, it always works.