Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odgovori
7956 Prikazi

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
Opusti
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
Opusti
Avtor

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

Avtor

Do you indent your code with spaces or tabs?

Avtor

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.

Related Posts Odgovori Prikazi Aktivnost
3
jul. 25
2206
0
jan. 24
2663
0
nov. 23
2502
2
mar. 17
4668
2
jan. 24
34