LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Inserting code snippets in posts (https://www.linuxquestions.org/questions/linux-newbie-8/inserting-code-snippets-in-posts-689333/)

lelmo82 12-09-2008 09:34 AM

Inserting code snippets in posts
 
Someone please point me at instructions for inserting code snippets into posts. Thanks and please excuse my abject ignorance. Les

colucix 12-09-2008 09:40 AM

Hi Les. You have to use CODE tags. You can either go in advanced mode (see the button Go Advanced at the bottom of the Quick Reply box), select the text you want to embed in code tags and press the hash button (#). Or you can explicitly put code tags around the text, like this:

[CODE]This will be a code snippet![/CODE]

resulting in
Code:

This will be a code snippet!

lelmo82 12-09-2008 11:23 AM

code snippets in posts
 
Many thanks for reply! Now dumb question #2: How do I Copy/Paste a long coded file from my Operationg systems (Fedora 9, Ubuntu 8.10?) I hope (and I am sure you do also) that this is my last question. Again,many thanks!

colucix 12-09-2008 11:42 AM

Well... just copy and paste using the mouse buttons: select with the left-button, paste with the middle-button. Hmmm... maybe this is not the kind of answer you expected. More seriuosly, if you have a long code or a text file in general or a long output from a command, you can copy it using the xsel command.

xsel is an application that is not usually available in the default installation of Linux, but there should be a package available for Debian-based systems. Anyway the compilation from source is very straightforward. Once you have xsel installed you can "copy" the content of a file using
Code:

xsel < testfile
then use the middle mouse button to paste. You can also "copy" the very long output of a command using process substitution, for example
Code:

xsel < <(ls -lR /)
then paste in the usual way. Look for details about xsel on the developer's web page.


All times are GMT -5. The time now is 07:16 PM.