News for hackers. Stuff that matters.
Re:Ask HN: What are your favourite programming shortcuts by KomoD on Friday March 29, 2024 @04:25PM (#39868629)
ctrl+c, ctrl+v
Re:Ask HN: What are your favourite programming shortcuts by pwg on Friday March 29, 2024 @01:42PM (#39866880)
Ctrl+[ - 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.

Re:Ask HN: What are your favourite programming shortcuts by yen223 on Friday March 29, 2024 @06:12PM (#39869557)
"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.

Re:Ask HN: What are your favourite programming shortcuts by anonthrow on Friday March 29, 2024 @11:06PM (#39871486)
this is now possible in every IDE thanks to tree-sitter.
Re:Ask HN: What are your favourite programming shortcuts by joehx2 on Friday March 29, 2024 @06:20PM (#39869618)
I'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 -
Re:Ask HN: What are your favourite programming shortcuts by yen223 on Friday March 29, 2024 @06:25PM (#39869659)
For those who may not know, `cd -` brings you to the previous directory.
Re:Ask HN: What are your favourite programming shortcuts by sethammons on Monday April 01, 2024 @05:07AM (#39892070)
Unfamiliar with 'switch'; i do 'git checkout -' all the time to toggle back and forth
Re:Ask HN: What are your favourite programming shortcuts by jytechdevops on Friday March 29, 2024 @06:20PM (#39869619)
pushd popd
Re:Ask HN: What are your favourite programming shortcuts by fragmede on Friday March 29, 2024 @06:30PM (#39869704)
command-shift-3 in bash comments out the current line and hits enter.
Re:Ask HN: What are your favourite programming shortcuts by khrbtxyz on Saturday March 30, 2024 @12:06AM (#39871746)
Is 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

Re:Ask HN: What are your favourite programming shortcuts by khrbtxyz on Saturday March 30, 2024 @03:46AM (#39872733)
Found it in the readline manual

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.

Re:Ask HN: What are your favourite programming shortcuts by interbased on Friday March 29, 2024 @07:26PM (#39870176)
Not a shortcut persay but I love setting alias’s in my .zshrc file to make all my common commands a few key strokes.
Re:Ask HN: What are your favourite programming shortcuts by khaledh on Sunday March 31, 2024 @05:30AM (#39882732)
In JetBrains IDEs: pressing shift twice while some text is selected opens the Find in Files dialog with the selected text already populated.
Re:Ask HN: What are your favourite programming shortcuts by solardev on Sunday March 31, 2024 @10:25AM (#39884562)
In 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#_renam.... It's cute that they kept the F2 shortcut key from the Windows (3.1?) days.

Re:Ask HN: What are your favourite programming shortcuts by kebsup on Sunday March 31, 2024 @02:20PM (#39886631)
After more than 5yrs of coding in jetbrains, I've recently started using F2 to go to the next error.
Re:Ask HN: What are your favourite programming shortcuts by az09mugen on Sunday March 31, 2024 @07:21PM (#39889180)
In 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
Re:Ask HN: What are your favourite programming shortcuts by fuzztester on Monday April 01, 2024 @12:37AM (#39890958)
If 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.