Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

UPDATE: At the end of this blog, you will find updated steps that are able to correct indentation issue.

There are certain limitations to syntax highlighting feature provided by SCN Editor.

ABAP syntax highlighting is not supported, and fixed-width typeface (common for code) can't be set.

People in ABAP Development space might find it useful

When we copy highlighted code from New ABAP Editor, and paste into SCN Editor, all formatting is lost.

Same limitation applies to highlighted text taken from MS Word document.

However, pasting code from New ABAP Editor to MS Word document retains formatting.

After following the steps, you would be able to paste code with syntax highlighting like this:

* get workitem runtime object
CALL METHOD cl_swf_run_wim_factory=>find_by_wiid
EXPORTING
im_wiid    
= workitem_id
RECEIVING
re_instance
= lv_wi_handle.

Prerequisites

  1. Your computer has Microsoft Office installed. (these steps were performed using 2007 version)
  2. Create an empty MS Word document, and save it as Web page, Filtered (*.htm) format.
  3. Close the document.
  4. Right-click and Edit option on file would launch MS Word.

Steps to follow

  1. Copy code snippet from New ABAP Editor.
  2. Open empty html file (created as a prerequisite). You can open it directly from MS Word or by right-click on file and choosing Edit option.
  3. Paste code snippet into MS Word html document.
  4. Copy code snippet from MS Word html document.
  5. Paste into SCN Editor.
  6. Close MS Word html document without saving so that same steps can be followed next time.

Added bonus

This method does not rely on buttons present in SCN Editor.

You might have noticed the SCN Editor hides some buttons when you post comment to a blog, like changing font or using advanced features.

Using this method, you would be able to post better snippets even in blog comments.

In addition, same technique might work for colorful text taken from other sources.

P.S.:

You might notice that code indentation is lost. MS Word is somehow stripping the leading blanks.

I'll update this blog when I find an easy way to fix it.

Modified steps that help retain indentation

It took some hits and trials to find a method that is easy to use by an average user.

Technically, spaces following a line break (<br> tag) are not sent by MS Word to clipboard.

However, spaces following a paragraph break (</p><p>) are sent by MS Word to clipboard.

This is one of the several limitations of MS Word when it acts like an html editor.

So, after pasting code in MS Word htm file, we replace Manual line break with Paragraph mark.

Updated steps (steps 4 to 8 fix indentation) have keyboard shortcuts as they save time. But it can be done using Mouse too with few more clicks.

  1. Copy code snippet from New ABAP Editor.
  2. Open empty html file (created as a prerequisite). You can open it directly from MS Word or by right-click on file and choosing Edit option.
  3. Paste code snippet into MS Word html document.
  4. Press Ctrl+H to open search/replace popup.
  5. Type ^l (caret or shift+6 followed by letter l) in Find what field.
  6. Type ^p (caret or shift+6 followed by letter p) in Replace with field.
  7. Press Alt+A to Replace All
  8. Press Esc to close search/replace popup
  9. Copy code snippet from MS Word html document.
  10. Paste into SCN Editor.
  11. Close MS Word html document without saving so that same steps can be followed next time.

Here is a screenshot that shows search/replace operation.

Final Result

After following steps, syntax highlighted code with indentation can be pasted in SCN Editor as shown below.

* get workitem runtime object

CALL METHOD cl_swf_run_wim_factory=>find_by_wiid

  EXPORTING

    im_wiid     = workitem_id

  RECEIVING

    re_instance = lv_wi_handle.

//

17 Comments