4 ms·
Ask HN: What are your favourite programming shortcuts
My favourites are in VS Code:
Navigate back: Alt + left
Navigate forward: Alt + right
Switch tabs: CTRL + Page up/down
Split tabs: CTRL + ALT + left/right
- pwg 3y agoCtrl+[ - jump to matching paren./brace/bracket Ctrl+w - scroll up one line Ctrl+z - scroll down one line These are the mappings I have set in Joe on my system, the Ctrl+w/z is originally from Wordstar, although I first encountered that mapping in Turbo Pascal 4.
- KomoD 3y agoctrl+c, ctrl+v
- yen223 3y ago"Expand selection" in Intellij and similar, option + up by default. This shortcut is, no joke, a very big part of why I'm still paying for Jetbrains tools.
- anonthrow 3y agothis is now possible in every IDE thanks to tree-sitter.
- joehx2 3y agoI've recently discovered `git switch -` and `git merge -`. It switches to the previous branch you were on or merges the previous branch you were own. No need to know the name. So if I need to pull updates on the previous branch I was on and merge them into my current branch, I can just: git switch - git pull git switch - git merge -
- yen223 3y agoFor those who may not know, `cd -` brings you to the previous directory.
- sethammons 3y agoUnfamiliar with 'switch'; i do 'git checkout -' all the time to toggle back and forth
- jytechdevops 3y agopushd popd
- fragmede 3y agocommand-shift-3 in bash comments out the current line and hits enter.
- khrbtxyz 3y agoIs this something special you have set up on your Mac? I keep getting screenshots when I hit command-shift-3. https://support.apple.com/en-us/102646 https://support.apple.com/en-us/102646
- khrbtxyz 3y agoFound it in the readline manual https://tiswww.cwru.edu/php/chet/readline/readline.html#index-insert_002dcomment-_0028M_002d_0023_0029 https://tiswww.cwru.edu/php/chet/readline/readline.html#inde... insert-comment (M-#) Without a numeric argument, the value of the comment-begin variable is inserted at the beginning of the current line.
- interbased 3y agoNot a shortcut persay but I love setting alias’s in my .zshrc file to make all my common commands a few key strokes.
- khaledh 3y agoIn JetBrains IDEs: pressing shift twice while some text is selected opens the Find in Files dialog with the selected text already populated.
- solardev 3y agoIn Jetbrains, you can shift-F6 to rename something (like a variable or function) via a built-in refactorer. It'll do it (somewhat) intelligently across not just the current file, but your whole project. Like in a React project, you can rename the first part of `[isThisThingOn, setIsThisThingOn] = useState()` and it'll automatically rename the setter and all the components that inherit that state. Or if you rename `<MyComponent/>` to something else, it'll rename that component, the imports, the filename itself, etc. across your whole project. It works pretty well but does have its quirks, like how it handles properties inside objects or type definitions, so it's worth double-checking the IDE's work for readability. VScode has something similar (F2), I think, but maybe only for some languages? https://code.visualstudio.com/docs/editor/refactoring#_rename-symbol https://code.visualstudio.com/docs/editor/refactoring#_renam.... It's cute that they kept the F2 shortcut key from the Windows (3.1?) days.
- kebsup 3y agoAfter more than 5yrs of coding in jetbrains, I've recently started using F2 to go to the next error.
- az09mugen 3y agoIn sublime text ctrl+m (go to matching parenthesis/brace), ctrl+d (multiple selection), alt+F3 (multiselect all occurencies). In Jetbrains, alt+F7 to show usages of function/method
- fuzztester 3y agoIf you're a vi(m) user on a *nix OS, running: $ set -o vi at the (ba)sh prompt ($ by default), enables vi-mode command-line editing. (The default is emacs.). You are initially in append mode on the current command line. Now you can do ESC to go to command mode, then use k and j to move up and down respectively in the command history, b and w to move backward or forward, and can use many other vi(m) movement and editing commands on the history lines, including/ and n to search for patterns. Been using this since early days of using Unix. Invaluable productivity aid.
- dassyjohnson 3y ago[dead]
- useRust 3y agoAnyone has useful mac shortcuts?