Title: Cutting and pasting powershell code nicely
Last modified: August 20, 2016

---

# Cutting and pasting powershell code nicely

 *  [Gavin Williams](https://wordpress.org/support/users/gavin-williams/)
 * (@gavin-williams)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/cutting-and-pasting-powershell-code-nicely/)
 * Hi All,
 * In a not-completely-unrelated field…
 * I use Powergui for my PS scripting.. and it makes the code very nice, (indentations,
   colour formatting etc).
 * However, when I try to post it to my blog (in wordpress).. the results can be
   very messy.
 * First, and most obvious, posting it via WORD makes it look very messy because
   of all the extra HMTL word does.
    Second, posting to notepad and up loses all
   the font and formatting.
 * I managed to get it to go up to wordpress in the right font and colours by using“
   cut and paste from PG to word… save word as HTM… open it in explorer, cut and
   paste it into Writer, post up via writer”. Which as you can see is very messy.
 * In fact, even having done that, it then wrapped the code lines around the pagewidth
   such that it failed when copied back into PGui.
 * Does anyone have an idea on how I can nicely cut and paste formatted powershell
   code into wordpress, (I’ve seen sometimes it is in a little window with a horizontal
   scroll bar)
 * Thanks!
 * Gavin

Viewing 9 replies - 1 through 9 (of 9 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/cutting-and-pasting-powershell-code-nicely/#post-2723401)
 * > posting it via WORD makes it look very messy because of all the extra HMTL 
   > word does
 * Don’t paste content from Microsoft Word into WordPress as the pasted text will
   also contain Word’s own formatting. Sooner or later, this formatting will stop
   your pages from being displayed correctly (if at all) in Internet Explorer. If
   you cannot possibly manage without Word, paste your text into NotePad (or another
   text editor) first, then copy from NotePad into WordPress. Or use Windows LiveWriter.
 * Are you correctly escaping all of your code before pasting it into WP from (say)
   NotePad? Are you wrapping it it `<pre><code></code></pre>` tags? Have you looked
   at any code syntax highlighting plugins?
 *  Thread Starter [Gavin Williams](https://wordpress.org/support/users/gavin-williams/)
 * (@gavin-williams)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/cutting-and-pasting-powershell-code-nicely/#post-2723407)
 * Hi esmi,
 * Yes thanks for that … I definitely saw all the posts around on the internet saying“
   don’t post from word”. Message received loud and clear.
 * However, what no-one seems to be able to answer is how to cut and paste while
   keeping the formatting. I don’t want to have to chagne font manually, and then
   manually recolour each of the words in the code green or red etc. And as I said,
   using livewriter got there eventually, but with linebreaks where there should
   not be.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/cutting-and-pasting-powershell-code-nicely/#post-2723409)
 * Are you wrapping the code `<pre><code></code></pre>` tags?
    Have you looked at
   any code syntax highlighting plugins?
 *  Thread Starter [Gavin Williams](https://wordpress.org/support/users/gavin-williams/)
 * (@gavin-williams)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/cutting-and-pasting-powershell-code-nicely/#post-2723422)
 * no.. I’m a bit of a newbie at this stuff..
 * what is
 *     ```
       ?
   
       And what are the code syntax highlighting plugins?
   
       I'm not afraid of doing legwork/research myself but I guess I just need the first kind of directional pointers
       ```
   
 *  Thread Starter [Gavin Williams](https://wordpress.org/support/users/gavin-williams/)
 * (@gavin-williams)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/cutting-and-pasting-powershell-code-nicely/#post-2723423)
 * Hey… something just happened on my last post!! 🙂
 * It looks like it’s doing the right stuff wr//t scrollbars
 * now if you can explain how/why it did that it will help.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/cutting-and-pasting-powershell-code-nicely/#post-2723428)
 * [http://wordpress.org/extend/plugins/wp-code-highlight/](http://wordpress.org/extend/plugins/wp-code-highlight/)
   
   [http://wordpress.org/extend/plugins/preserve-code-formatting/](http://wordpress.org/extend/plugins/preserve-code-formatting/)
   [http://wordpress.org/extend/plugins/hana-code-insert/](http://wordpress.org/extend/plugins/hana-code-insert/)
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/cutting-and-pasting-powershell-code-nicely/#post-2723435)
 * > something just happened on my last post!
 * You did not post code tags between backticks or use the code button.
 *  Thread Starter [Gavin Williams](https://wordpress.org/support/users/gavin-williams/)
 * (@gavin-williams)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/cutting-and-pasting-powershell-code-nicely/#post-2723451)
 * ok.. I installed the syntax highlighter and it is now putting the nice code colours
   on it..
    It seems that I can do something similar with ‘[sourcecode language 
   ="powershell"] [/sourcecode]‘
 * However the next strange thing is that when I paste two things happen.
 * 1. All the indentations are lost
    2. Doing a mouse-drag highlight copy/paste 
   pastes it back into my script editor as one long line with not linebreaks.
 * Am I missing something easy or else do I need to contact the plugin writer?
 * PS: thanks for help so far!
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/cutting-and-pasting-powershell-code-nicely/#post-2723456)
 * Try wrapping the code in `<pre><code></code></pre>` HTML tags.
 * [http://www.w3schools.com/tags/tag_pre.asp](http://www.w3schools.com/tags/tag_pre.asp)
   
   [http://www.w3schools.com/tags/tag_phrase_elements.asp](http://www.w3schools.com/tags/tag_phrase_elements.asp)

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Cutting and pasting powershell code nicely’ is closed to new replies.

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [powershell](https://wordpress.org/support/topic-tag/powershell/)

 * In: [Everything else WordPress](https://wordpress.org/support/forum/miscellaneous/)
 * 9 replies
 * 2 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [14 years, 1 month ago](https://wordpress.org/support/topic/cutting-and-pasting-powershell-code-nicely/#post-2723456)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
