You could create a custom operator and map the following to a shortcut.
bpy.ops.text.move(type='LINE_BEGIN')
bpy.ops.text.insert(text="#")
or if selecting the line is tiresome you can just automate the selection step then comment
bpy.ops.text.select_line()
bpy.ops.text.comment_toggle()
Creating a custom operator would look something like this
import bpy
class CommentLineOperator(bpy.types.Operator):
bl_idname = 'text.comment_line'
bl_label = 'Comment a line'
def execute(self, context):
bpy.ops.text.select_line()
bpy.ops.text.comment() >> bpy.ops.text.comment_toggle() since 2.8
return {'FINISHED'}
bpy.utils.register_class(CommentLineOperator)
bpy.utils.unregister_class(CommentLineOperator)
After that, you should be able to map a shortcut easily to text.comment_line.
To have this load at startup, just save it with a .py extension and drop it into your scripts/startup/ folder. See How could a single Python script run when Blender is started?.