Start a new topic

Comment in a shell script - copy & paste

I want to copy something from a shell script in a Rebex window to another window. In both windows I have the VI on.

Unfortunately, all lines after a comment also become comments. 


  Example:

# This is a comment
This is not a comment

changed by copy & paste in:

 

# # This is a comment
# This is not a comment

 

However, lines before the # are not changed. I checked all the settings. If I copy the lines to another application, everything is fine. It happens when pasting. What do you have to do to prevent this from happening again?

 

 

 

 

 


Hi Christian,


I just tried it and it seems to work for me.

Hey, Christian,


This isn't a feature of RoyalTS.  Rather, it's a feature of vim.  Vim is treating your pasted text as though you type it really quickly.  When you type a comment in vim and hit Enter, the next line will also be formatted as a comment so you don't need to type your own `#` character.  It also operates this way with indentation - it tries to guess at what indentation level you want for your next line.


To disable this feature while pasting:

  1. Press `:` to open the vim options prompt 
  2. Type `set paste` and press Enter
  3. Be sure to press `i` to enter Insert mode in vim
  4. Paste your text
  5. Optionally, exit paste mode by running the option `set nopaste`

Login or Signup to post a comment