Undesired characters while pasting in vi editor

When I am trying to paste my code from clipboard into vi editor, random symbols are getting generated as shown in the callback function below:

PS: I used Ctrl+V to paste


import rospy
from nav_msgs.msg import Odometry

def callback(msg):
print (�~@~\x_coord: �~@~]+str(msg.pose.pose.position.x))
print (�~@~\y_coord: �~@~]+str(msg.pose.pose.position.y))
Print (�~@~\z_coord: �~@~]+str(msg.pose.pose.position.z))

rospy.init_node(‘odom_subscriber’)
sub = rospy.Subscriber(’/odom’, Odometry, callback)
rospy.spin()


Please help me fix this so that I can paste my code without having to edit it after pasting.

Hi @animeshsinghal.iitb ,

I’ve just tried to do what you mentioned and it didn’t happen to me.
I’m using a EN keyboard. Could you check if your keyboard/computer encoding is properly configured?

It is also important to make sure the editor where you are copying from is using UTF encoding (or the one used in the browser, if you have configured the browser with a different one)

Please, check the gif attached how it should behave

video-2021-12-14_18.43.27

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.