OS / Editor efficiency

General tips

The best general tip that I have is to identify where you would gain the most time using shortcuts. To illustrate, here’s a contrived example: suppose you never knew about copy/paste and found yourself frequently duplicating text manually. Learning about copy/paste would likely be by far the biggest time-saver you could incorporate into your workflow.

As the example shows, this process can be broken down into two phases: discovery and incorporation:

  • Discovery: it’s difficult to use something if you don’t know it even exists! I suggest hunting through menus or keybindings files/settings to figure out which commands are even available to you. I’ve found some interesting ones from time to time. For example, in Sublime, you can select a bunch of lines and prune out duplicate values using Edit → Permute Lines → Unique. I wouldn’t have known that I could even do this unless I was searching through menus for it. Some ways to help you with this:
    • Try to analyze where you’re spending most of your time. For example, if you find yourself deleting entire lines multiple times per day, perhaps you could write in a note somewhere “find a hotkey for deleting lines”.
    • Try ditching your mouse for a day (or at least drastically reduce your usage). This will force you to find a keyboard-based solution for what you’re trying to accomplish.
    • Find resources like CheatSheet that list a bunch of shortcuts.
  • Incorporation: now that you know something like Permute Lines exists, you need to actually start using it! For certain shortcuts like commenting code, it will be obvious (“instead of typing // here, I’ll press the comment shortcut”), but for others, you may need to be more mindful. I find it helpful to write it on my TODO list or a sticky note for a day to try finding a place for a particular shortcut.

As for why any of this is important, it’s simple: context-switching can kill your productivity. The less time you spend going from “what am I doing?” to “how do I do it?”, the less chance you have to lose focus.

Regarding the mouse: it’s not like using your mouse is bad, it’s just probably not the best. For that reason, I’ve always used 10+-button mice. My current one is a Logitech G600 and it has 12 thumb buttons. I did a short video on this specifically for this post.

Windows tips 

Note: I’m writing this for Windows 10. There’s a full list of keyboard shortcuts here.

  • Keyboard shortcuts (“win” means “the Windows key” on your keyboard, and the “→” is used to indicate multiple hotkeys must be used in succession)
    • Win+# (e.g. win+1): navigate to that numbered icon on your taskbar. For example, in this picture of my taskbar from earlier, I have Chrome, then Explorer, then Visual Studio Code in my taskbar. That means that win+1 will activate Chrome, win+2 Explorer, and win+3 VSCode.
      • If you have multiple windows open of the same application, holding the Windows key and pressing the corresponding # multiple times will cycle through the Windows. E.g. win+1, win+1 will get to my second Chrome window.
    • Win+left or win+right: snap the focused window to the side of the screen. You can just keep pressing these to move them to different monitors, but win+shift+left and win+shift+right are better shortcuts for that.
    • Win+up: maximize the current window.
    • Win+T: set the focus to the taskbar. Because I stream, I don’t like using alt+tab since it shows previews of windows even from my second monitor and I’m worried I’ll leak information. Instead, to get to the final icon in the taskbar, I press win+T → end → enter.
    • Win+E: open a new Explorer window.
    • Win+period or win+semicolon: this brings up the emoji menu, which I use all the time. From there, just type something like “tada” and press enter: 🎉
    • While in most programs with an address bar: alt+D will bring you to your address bar.
    • When in a common file dialog (i.e. the “save” or “open” dialogs like this one), alt+T → alt+N will set the focus to the name/path section. You may think that only alt+N is needed, but if the focus is in the address bar at the top, then alt+N does not work.
    • Anything with a Quick Access Toolbar (i.e. all Office products or Explorer itself):
      • Right-click any shortcut in the ribbon and choose “Add to Quick Access Toolbar”
      • From there, you’ll see an icon appear in the upper left. Just like with win+#, now alt+# will activate that shortcut, where “#” is the index of the icon. For example, in this picture, alt+2 will make a new folder.
    • Text editing shortcuts like ctrl+backspace and ctrl+delete to delete the last/next word all at once.
  • Mouse shortcuts
    • Double-clicking a word in almost any program will select the whole word.
    • A double-click followed by dragging the cursor around will select entire words rather than individual characters (try it now to select a bunch of words in this bullet point!).
    • Triple-clicking text in almost any program will select the entire line.
    • triple-click followed by dragging the cursor around will select entire lines.
  • Console tips
    • In CMD, Doskey can be used for aliases, but I had some issue with it years ago that caused me never to look into it again. Instead, I just make .cmd  files in my %userprofile%  and run those. For example, I like the alias s  for opening my text editor, so I make %userprofile%\s.cmd  with these contents:
      • @echo off
        set vsc="C:\Program Files\Microsoft VS Code\Code.exe"
        start "" %vsc% %*
      • After that, I can type something like s new_file.js to make a file in VSC.
    • ConEmu is a great tabbed console emulator that lets you assign a global shortcut to your terminal. I use the shortcut so that I can access my console from anywhere in the operating system.
  • AutoHotkey
    • AutoHotkey lets you trigger commands either by typing arbitrary text (e.g. I can type `vsc  and it will turn into Visual Studio Code) or by pressing a keyboard shortcut. I uploaded my own AHK scripts here for reference. You can use this to fix typos that you make frequently, position windows in a particular way, format text, or really anything else that you would do yourself with a mouse and keyboard.

Text editor shortcuts 

Notes:

  • I don’t use VIM keybindings.
  • I’m not listing the actual keypresses needed to activate these since they’re not necessarily specific to a particular editor. Even if they were, I customize my shortcuts so that they’re not the defaults. To find out what these are for you, you should be able to search through your text editor’s list of shortcuts.
  • am going to list the name of the shortcut in parentheses that Visual Studio Code assigns, that way if it’s not obvious what my description refers to, you can at least try it out in VSC! Some of these may come from an extension, in which case the shortcut is a link to the extension.
  • I’m not going to include “obvious” ones like “copy and paste”, “go to the next tab”, or “comment code”.
  • I wrote blog posts about specific extensions and shortcuts for Sublime here and Visual Studio Code here.
  • Here’s a video from 2015 of me using many of these shortcuts and some extra features in Sublime.

Most used functions:

  • Multiple cursor management: these are all supremely useful for so many scenarios while developing that it’s hard to give a single example. Essentially, any time you find yourself wanting to use the find/replace dialogs, possibly with complex regex, you can probably do whatever you’re trying to do more easily with multiple cursors.
    • Select next instance of word (editor.action.addSelectionToNextFindMatch)
    • Ignore current instance of word (editor.action.moveSelectionToNextFindMatch)
    • Select all instances of word (editor.action.selectHighlights)
    • Extend line up or down (editor.action.insertCursorAbove)
  • Duplicate selection or entire line (editor.action.copyLinesDownAction)
  • Move entire lines up or down (editor.action.moveLinesUpAction): this is great for moving code into and out of block statements or just rearranging your code.
  • Quickly open a file (workbench.action.quickOpen)
  • Quickly navigate to a function (workbench.action.gotoSymbol)
  • Soft undo (cursorUndo): suppose you’re trying to use multiple cursors to select the next three instances of the word “hello”, but you accidentally select the next four instances. Some people would press escape and then try again, but with soft undo, you can simply undo the last cursor.
  • Close all windows to the right (workbench.action.closeEditorsToTheRight): useful when you have lots of temporary buffers open. I frequently find myself also using this in combination with the Windows shortcut alt+N for choosing “Don‘t save” when the dialog pops up.
  • Toggle words (extension.toggle): as mentioned in both the Sublime and VSCode blog posts, this is the best extension that you never realized you wanted. It can convert true to false , ==  to !=, and whatever other pairs you may want (width/height, up/down, Monday/Tuesday/Wednesday/etc.).

Closing

I shared what I thought may be important, but you may have come into this post expecting something else. I’d love to hear how I can make this post better! Feel free to share feedback with me on Discord.