Copying Command Text From Office Programs

by Seth Miller

I just had to post this because it’s one of those things that I would have continued to waste time “putting up with” had I not taken a few minutes to figure it out.

Most SOPs and other documentation I write is in Microsoft Word if it is going to be distributed. I stick with Vim if it is just for me, but generally I want to share the information I take time to put together.

If I’m using commands from documentation done in an Office product, there is an unfortunate side effect of having those commands in a neat bulleted list. By default, highlighting and selecting something will include the formatting of the list and look like this:

•	select 'alter user '||name||' identified by values '''||password||''';'
from user$ where upper(name) = upper('&USER');

If I paste that into my terminal, it will look something like this:

SYS@ORCL > b"select 'alter user '||name||' identified by values '''||password||''';' 
from user$ where upper(name) = upper('&USER');
SP2-0734: unknown command beginning "b"select '..." - rest of line ignored.

There does not appear to be any way to change the behavior of copying text to not include formatting. A simple solution is to put a space in front of the command and do not include it in the selection. This will give you a copy of text that doesn’t include any bullets or list settings.

SQL> select 'alter user '||name||' identified by values '''||password||''';'
from user$ where upper(name) = upper('&USER');
Enter value for user: scott
old   1: select 'alter user '||name||' identified by values '''||password||''';'
from user$ where upper(name) = upper('&USER')
new   1: select 'alter user '||name||' identified by values '''||password||''';'
from user$ where upper(name) = upper('scott')

'ALTERUSER'||NAME||'IDENTIFIEDBYVALUES'''||PASSWORD||''';'
--------------------------------------------------------------------------------
alter user SCOTT identified by values '351CD6466E9C1771';

SQL>