Home > Back-end >  Create a column comment in python source file
Create a column comment in python source file

Time:12-14

Hello I want to create a comment section right next to all my code lines for documentation purposes. I have over 1000 lines of code and I don't want to place all the # by myself.

The result I want to achieve:

    code()              # comment
    code()              # comment
    code()              # comment
    code()              # comment

Is there a way to do this automaticly?

CodePudding user response:

you can place Multi Cursors.

Make sure you don't have Word Wrap enabled

  1. click on the first line
  2. Shift Alt Click on the last line
  3. End - to go to the end of the line
  4. Type a number of spaces to make all lines larger than your comment column
  5. Home - go to start of line
  6. Use Arrow Right to move to your comment column
  7. Sift End Delete - to remove extra spaces
  8. Type # comment
  9. Esc - to leave Multi Cursor

CodePudding user response:

There are a number of extensions that do this well. See, e.g., betterAlign

You can bind the Align command to a keybinding if you want.

{
  "key": "alt a",
  "command": "simple-alignment.align"
},
  • Related