I like CMD + D to select the next identical selection, OPT + DOWN/UP to move the selections down or up a line, SHIFT + OPT + DOWN/UP to duplicate the selection, and CMD + / to turn the line into a comment. How bout you?

  • Kwartel@programming.dev
    link
    fedilink
    English
    arrow-up
    5
    ·
    1 year ago

    Ctrl + space to force open the autocomplete. Ctrl + . to open the issue fixer. Especially useful to fix missing imports.

  • spartanatreyu@programming.dev
    link
    fedilink
    English
    arrow-up
    5
    ·
    1 year ago

    Honestly, the single thing that can improve editing speed is learning how to code with multiple cursors.

    It takes about a solid week of practice just to recognise and catch yourself in a situation where using multiple cursors would make you more efficient, and to start using the shortcuts. It takes another week or two to get back up to your old regular speed. After that, you’ll find that the old speed ceiling has been removed and you’ll continue to get faster and faster until you hit a new ceiling (which is usually your WPM).

    • alr@programming.dev
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago

      This 100%. Part of my job is writing test cases, which can be extremely repetitive. With multiple cursors, I can frame out a dozen or more cases simultaneously and then go through and fill in the details. It significantly reduces typing time.

      Also, if you work with any sort of XML or HTML, learn Emmett abbreviations and learn them properly. It will take you an hour to learn them properly, but they save so much time over typing tedious tags longhand. Being able to type html>(head>meta[charset=utf-8]/+title{My page})+body saves so much time over

      <html>
          <head>
              <meta charset="utf-8"/>
              <title>My page</title>
          </head>
          <body>
      
          </body>
      </html>
      
      • spartanatreyu@programming.dev
        link
        fedilink
        English
        arrow-up
        3
        ·
        1 year ago

        Protip: when using emmet, just type ! once then press tab.

        It will write out:

        
        <!DOCTYPE html>
        <html lang="en">
        <head>
        	<meta charset="UTF-8">
        	<meta name="viewport" content="width=device-width, initial-scale=1.0">
        	<title>Document</title>
        </head>
        <body>
        	
        </body>
        </html>
        
        

        With the first tab stop at: device-width, the second tab stop at 1.0, the third at document, and the fourth indented between the body tags.

        This means that if you want to create a new html page specifically with the title “My page” and end with the cursor in the body ready for your new hand written html or your next emmet abbreviation, you only need to press the following:

        1. !
        2. Tab (or whatever your emmet expansion shortcut is)
        3. Tab Tab (to move past the first and second tab stops
        4. My Title
        5. Tab (to move the cursor inside the body tag)

        So it only takes 13 keystrokes (of which 8 keystrokes were typing out the title) to create the following:

        <!DOCTYPE html>
        <html lang="en">
        <head>
        	<meta charset="UTF-8">
        	<meta name="viewport" content="width=device-width, initial-scale=1.0">
        	<title>My Title</title>
        </head>
        <body>
        	>|<-- cursor is here
        </body>
        </html>
        
  • nickel@programming.dev
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    1 year ago

    A few shortcuts that I use a lot are really basic, but very powerful. Frankly, I’m always surprised when I’m pairing with a co-worker and they don’t know about them.

    Cmd+p to open the fuzzy file finder search. This is a huge one and I’m shocked when I see people hunting through the file explorer to find the file they are looking for.

    Cmd+shift+f to open the fuzzy workspace text search. Basically grep your workspace for code.

    F1 or Cmd+p+> - Action menu. So many good actions in here from running formatters, to toggling light/dark mode, reload window, etc.

    Ctrl+r (mac) - Fuzzy search for recently opened projects/files. Hitting Enter opens it in same window or Cmd+Enter opens in new window. I use this sooo much and most people don’t know about it.

    Cmd+n to open a new vscode window. Although I rarely use this as I almost always just use Ctrl+r.

    VSCode has great fuzzy search and if you use it, it lets you move around your code and codebases so much faster.

    Installing CLI tools so when in the terminal, you can run code <path> to open vscode at that working directory.

    Can’t remember the last time I used File->Open to open a new project window.

    Cmd+b to open/close the left drawer

    Cmd+shift+e to open the file explorer.

  • lorefnon@programming.dev
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    Vim has a rich ecosystem of plugins like easymotion which allow you to jump directly to different parts of the current file with minimal keystrokes. There are vscode extensions like Jumpy and Acejump which provide a similar keyboard-driven cursor jumping support for vscode.

    I highly recommend trying out one of these if you haven’t already. Once you get habituated to easymotion, you wonder how you survived without this so long.

  • tgv@programming.dev
    link
    fedilink
    English
    arrow-up
    2
    arrow-down
    1
    ·
    1 year ago

    For awesome shortcuts, you need to look at emacs. But there are plenty useful shortcuts. Cmd-\ jumps to the matching bracket, cmd-click jumps to the definition of a symbol, cmd-F opens the find dialog with the currently selected text in the search field, there’s one to show the call hierarchy (but I never can remember the shortcut), etc. You can assign your own short cuts; I think I set or changed the collapse/expand region commands. If you go to Code > Settings > Keyboard shortcuts, you see them all.

    All commands are also available under cmd-shift-p, and it has a decent search function.

    • spartanatreyu@programming.dev
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      For awesome shortcuts, you need to look at emacs.

      What do you mean?

      Every example you went through is already there without emacs.

      (P.S. Jump to Matching Bracket is actually Cmd-Shift-\)

      • tgv@programming.dev
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        Obviously every example is for vscode. It’s what the poster asked.

        Emacs has better shortcuts, hands down. And you can record them into a macro, which you then can assign to another shortcut. You can also write functions in lisp, and assign those to shortcuts. And you can pass arguments to shortcuts. E.g. ^I means indent selection, but if you add ^U plus a number before it, it’ll indent the selection with that number of spaces.

        • spartanatreyu@programming.dev
          link
          fedilink
          English
          arrow-up
          1
          ·
          1 year ago

          Ah I misread your comment. I thought you were suggesting that vscode users turn on emacs shortcuts to gain shortcuts that were already in vscode.

          I’m not familiar with any emacs macros, they seem like a more quick-and-dirty version of what vscode has going on with it’s extensions.

          Your indent example would be easier in vscode, since in vscode land you only need to make a selection then press Tab, and the LSP will automatically indent it to the correct level. And if you have a formatter installed, simply saving the file will format the file (indentation included).

          But I’m guessing you included the indent example to show how to pass in an argument.

          VSCode can do similar things, but it’s not exactly the same. I use the following

          • Emmet
          • Find (with regex)
          • Fold Level “n”
          • Snippets with tab-stops
          • tgv@programming.dev
            link
            fedilink
            English
            arrow-up
            1
            ·
            1 year ago

            Emacs is completely programmable. Everything is written in LISP, and everything can be overruled. You can make the ‘a’ key insert the character ‘a’, but 1 in a 100 times insert ‘b’. Emacs is the originator of incremental regex search, it had auto-complete long before even Visual Studio, and it has more than one way to use snippets. It doesn’t simply have levels of indent and regions, but an extensive org-mode that can do the weirdest things wit them. You can select a piece of text, pipe it through a shell command, and have it replace the original. It has a symbolic expression solver! But that comes at a price: emacs is complex. But if you want to have an idea of how flexible an editor can be, take a look. It’s still going strong, despite its age.