skip to Main Content

I’d like to edit my Visual Studio Code.

When I write my symbols on my keyboard to VSC, they’ll get written Column by Column on the current Row.
Line of Code + Column.
(Ln , Col )

Extensions: "Select By"

= to jump to a certain column.
However, when i like to jump to ‘column 50’, it will only jump to the >End of Line.

// Example
// Goal is to get a Hotkey to Jump to Column 50
// Activated Hotkey*
cout << "Hello World:" << endl;   // If i use my Hotkey i get to the Column 30, not 50. Picture is enhanced*

/* The end of line is here: 30. */

Question: How can I achieve my Jump
via the given Extension? (Any easy solution would be helpful).
I don’t like to use the Ln, Col in Vsc, because clicking on the UI is for me over the time to slow.
I’d like to use f.e. Cmd + M to get to my "middle", So for me column 50.
Hence, i don’t like to go to Middle of my current Screenformat.

Additional prefered Question: One way how i like to solve the issue is in C64 Style.
Is there any way to fill out the Visual Studio Code Screen by empty chars?
So as an Preset.
I know, that i can just copy & Paste. Or write an empty script. But that doesn’t seem convenient inside the Configuration. I tryed to find that now unsucessfully since 2 weeks..

The reason is for me, that i currently try to code more cleaner.
And to achieve that (I have read many Clean Code Books during school and Github), i just like to try this time an historical approach by setting my own column points/ marks. (Basic C64-menu wise)

Thank you in advance!
Sincerely

Edit: I have enhanced beforehand.

enter image description here
Edit2: I have tryed the Find and Transform Extension pointed by Mark. Thank you for your time!

When i press the given Hotkey, It does marks the previous chars. but it doesn’t start at column 50.
It marks at end of line.
I only like to move the cursor to column 50 and surpress the end of line.
enter image description here

2

Answers


  1. does this key binding work

      {
        "key": "ctrl+i ctrl+m",  // or any other key binding
        "when": "editorTextFocus",
        "command": "moveby.calculation",
        "args": {
          "charNrEx": "50"
        }
      }
    

    Or use Ctrl+G and type lineNr:charNr

    Login or Signup to reply.
  2. At the risk of not fully understanding the question, if what you want to do is pad any line to the 50th column with spaces, you can try this approach.

    1. Install the extension Find and Transform
    2. Make this keybinding (or it could be a command):
    {
      "key": "alt+q",                  // whatever keybinding you want
      "command": "findInCurrentFile",
      "args": {
        
        // this will select the current line, cursor can start anywhere on line
        "preCommands": ["cursorEnd", "cursorHomeSelect", "cursorHomeSelect"],
        
        "replace": [
          "$${",
            "const str = `${TM_CURRENT_LINE}`;",
            "let currentLength = str.length;",        // current line length
            "if (currentLength >= 49) return str;",   // do nothing
    
            // pad to whatever column you want
            "else return `${str.padEnd(49, ' ')}`;",  // pad with spaces
          "}$$"
        ],
        "restrictFind": "line",                       // only on lines with a cursor
        "postCommands": ["cursorRight"]               // just cancels the selection
      }
    }
    

    pad line to 50th column with spaces

    It’ll work on multiple lines too if each line has a cursor on it

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search