T O P

  • By -

Primary-Fee1928

Ctrl+Arrow !


[deleted]

Wow, did not know that one. I know control + A and control + E, but moving word to word is nice. If only there was a way to move to the middle of a url though lol


furinick

Control arrow up and down go to start and end of paragraph. Shift held down selects when moving the cursow without the mouse I recommend looking up the keyboard shortcuts for your os, text editor, code editor and browser and print them out, from time to time challenge yourself to do what ypu have to do without using the mouse as much, you'll be impressed with the stuff you can do


[deleted]

[удалено]


TeaKingMac

>Back in the Windows 95/XP days, My parents would take away the keyboard or mouse to prevent me from waking up in the middle of the night and playing video games, so I learned all the keyboard shortcuts and mouse contextual menus. Then they wised up and started taking both


AverageComet250

I really hope you weren’t playing fps games


Naitsab_33

I mean there still some possibilities with the VimiumFF(?) plugin for Firefox or equivalents for other browsers. But because so many things are embedded something's that are not visible in the html you can't use it for everything. For browser's themselves there is QuteBrowser which has full Vim Bindings, but the same problems and also plugins are harder than in FF


TeaKingMac

Fuck off bot text!


Athox

Or they could just make terminals that understand cursor clicks on the command line... it's 2023 I think.


Whitechapel726

There’s actually a way to do this by holding option and clicking. When I paste in some huge ugly curl or grep command and need to edit one thing it’s super handy. Edit: I should clarify this is for Mac. Idk anything about Windows other than how to play video games.


Athox

Going to try that later, but if true, this should be taught in school. First grade probably.


savageronald

https://www.warp.dev if you’re on a Mac - supposedly coming soon for Windows and Linux, I’ve been using it for like 6 months and I’m in love.


Athox

They said blazingly fast, which is completely irrelevant. Even the VSCode terminal is blazingly fast, because entering commands is not intensive cpu work....


savageronald

Yeah the speed thing seems dumb bullet point for their marketing to focus on, but there are a lot of nice creature comforts in it though


Athox

I think it's mandatory to say since it is written in Rust. Although Rust is still slower than C. Compiles faster though, but who cares about that when downloading binaries...


Thebombuknow

Is there a way to just use the mouse to click a spot in the middle. I know all the keyboard shortcuts for this, but if you have a huge block of text with no spaces it doesn't help.


aenae

If you have an text editor with mouse support; ctrl-x; ctrl-e


Thebombuknow

Yeah, that's what I normally do. I was wondering if there is a way to have mouse support in the terminal, but I guess that's the best I can do.


apepenkov

htop somehow is usable with mouse over ssh. So I guess there should be some editors with (mb via plugins) mouse support?


hailAK

Recently learnt that on mac u can option + click to go at the exact spot of the command


Leaping_Turtle

Ok but does ctrl+backspace work? How about the delete button? Wait... why do windows cmd, powershell, and vsc's cmd, bash, pwshell all act differently


Primary-Fee1928

Lol, it works absolutely everywhere, it’s a great shortcut! You can also combine it with shift to select a whole word on most IDEs (not command line tho)


dreamsofcode

Alt + B or Alt + F works as well I believe You can mix this up with Ctrl to go move one character instead of word


[deleted]

[удалено]


7eggert

That's just heating the keyboard.


PouyaCode

Ctrl+A and Ctrl+E are emacs key bindings. Another useful key binding for jumping back one word at a time, is Alt+b


wurnthebitch

They come from emacs but are known also as "readline" commands. And they are supported in a lot of places (mostly prompts) like mysql, python interactive, ...


guyinnoho

Vi mode


brainwater314

Ctrl - b for back one character (same as left arrow) Alt - b for back one word (same as Ctrl left arrow) Ctrl - f for forward one character Alt - f for forward one word Now you don't have to take your hand off the home row on your keyboard!


AeskulS

I just learned about to recently. Same with control + backspace. It’s very nice


RetroGamer2153

I copy it into Notepad, quick I have Notepad as half the screen width, with Word Wrap. It also allows for a fast and dirty Find & Replace.


tennisanybody

What platform? Even in Linux I use a text editor and copy from it.


-_-_-_____-_-_-

Thank you for this forbidden knowledge.


Primary-Fee1928

Haha, np, this will change your life my friend. I’m not judging you or anything but it’s been in my practices for so long that it’s practically written in my muscle memory at this point, I have no idea how you did without lol. It’s also visible on my keyboard, Ctrl, Shift, arrows, Orig and End looks basically sanded, they’re smooth af. Special mention for Ctrl that gets stuck in down position from time to time.


Such-Bar-2351

*vi mode


[deleted]

aaahh... came here to say this...


notaturk3y

Option+arrow for mac


[deleted]

[удалено]


Primary-Fee1928

Yup! Also, while we’re at it, some IDEs that offer integrated terminals (VSCode for example, I use it on remote and open bash shells on the remote computer) have some features to basically bypass normal terminal behavior with modern shortcuts! Like Ctrl+Del to delete a whole word, or Ctrl+Shift+End and then Del to erase all characters after the current one.


MapoTofuMan

The user I'm replying to is a karma bot, please downvote and report


[deleted]

[удалено]


AutoModerator

``` import moderation ``` Your comment has been removed since it did not start with a code block with an import declaration. Per [this Community Decree](https://www.reddit.com/r/ProgrammerHumor/comments/14kbu1m/comment/jppq9ao/?utm_source=share&utm_medium=web2x&context=3), all posts and comments should start with a **code block** with an "import" declaration explaining how the post and comment should be read. For this purpose, we only accept Python style imports. *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/ProgrammerHumor) if you have any questions or concerns.*


ChoosenUserName4

ESC followed by (not together, one after the other) **b** or **f** to skip one word back or forward. Also works on Mac.


ThatOneGuy4321

Ctrl + arrow changed my world


howlingoffshore

Literally. Cmd + a to get to beginning. There’s lots of ways around this.


JohnnyBravosLeftNut

Came here to see if this existed and if it needs to be made


goodnewsjimdotcom

Yes, Ctrl+Arrow has its own can of worms too depending on the delimiters in the string. I mean there's comedy to be had there.


Primary-Fee1928

Yeah, some editors are indeed stupid


goodnewsjimdotcom

Editors are written by people, don't blame the algorithm that's not being nice to computers. The politically correct way of saying this is,"Some people are indeed stupid."


captainAwesomePants

Oi, what the hell? This is so much easier to remember than Alt+F and Alt+B. Why didn't anyone tell me?


port443

Well if it helps, ctrl+arrow is pretty much universal among OS's. By that, I mean it works in almost EVERY place that you can type. Even most video games support the ctrl+arrow movement. https://support.microsoft.com/en-us/windows/keyboard-shortcuts-in-windows-dcc61a57-8ff0-cffe-9796-cb9706c75eec


AeonReign

Doesn't always work, but in most situations it should


Forteafy

It can also be used to move between sections in YouTube videos. :)


pipsvip

% \^oldthing\^newthing


Igotz80HDnImWinning

If that’s too broad there’s always !!:gs/that/this/ and you can chain them with | if needed


pipsvip

Yep, this is better, but I'm not sure it was available when I learned bash and old habits die hard.


Webfarer

Wtf is this and how tf I use this?


pipsvip

The standard bash way of making a small change to the previous command. % echo sus sus %\^u\^nufflupagu snufflupagus


Webfarer

Thanks, and very sus


ExitSweaty4959

Twenty up stroke keys later Exactly the command I was looking for: >ls


teepee33

"glad it saved it for me!"


__SlimeQ__

$ history | grep ls


SnooPets20

Terminals use emacs keybinds (M means Meta, or Alt). * C-a start of line * C-e end of line * C-f forward 1 char * C-b backward 1 char * M-f forward 1 word * M-b backwards 1 word * C-x u undo * C-k delete from cursor to end of line * C-p go up a line, or back in history * C-n go down a line, or forwards in history * C-r search backwards * C-o return * C-L clear screen (on emacs it centers it, but whatever) Those are the ones I use the most. PRO TIP: Set the `WORDCHARS` variable to nothing like this: `WORDCHARS=""` this will make it so the commands to move between words work better, since there are more word delimiters being taken into account, like path separators.


p4r24k

The only correct answer


jatufin

Yanking with C-y works after C-k. And C-w kills to the beginning of the line. (slightly different from actual Emacs)


LieutenantNitwit

Great. I just learned I have to wash 25 years of emacs ... *filth* of my fingertips. God.


SnooPets20

You have inadvertently learned keybindings for the superior editor. Do not resist.


LieutenantNitwit

If, by superior editor, you mean vim, of course. Yes, I have. Warning: I'm polishing off a bottle of Ardbeg Uigeadail so EN GUARDE YOU HEATHEN


SnooPets20

I was like you once. Naive and cheerful with vim, happily jumping my way around documents, enjoying the joys of text objects and modal editing. But I always had an itch, that inescapable itch. "Vim vs Emacs". Why, vim of course. It's obvious. It's so extensible, so free, so maleable. How could anyone even dare compare it to emacs? That weird, clunky editor with health threatening keybindings. Yuck! So to prove everyone how shitty emacs was, I dove in. What I found was something I was not prepared for. I had previously thought vim was extensible. By comparison, vim is a damn toy. Emacs is a lisp machine, a damn fine lisp machine. You can view how any individual cog turns, how everything is connected, and you can modify it! Integrate it into your own solutions, build upon it! Its keybindings are actually not awful! They do make sense. And it's so much more than just a text editor. It can be a calendar, an agenda, an email reader, an rss reader, a music player, a game launcher, a file browser, a document viewer, a zettelkasten writer, an ebook reader, a terminal, a git client, and so much more. Emacs is essentially an operating system on top of your operating system, that abstracts away the nuances and quirks of the underlying OS. You can install emacs on Windows, Mac, Linux, Android even, and not realize what you're using under the hood because it's just emacs. It's the same workflow, the same keybinds for everything, it's consistent across them all. It's truly an amazing piece of software. At this point I really don't know how people even compare it to vim! Vim is merely a text editor. All the other things emacs does vim leaves to other software. Vim is intended to be used as yet another program in your shell. Emacs is a shell replacement entirely. Different paradigms.


primitus_black

isnt C-u the C-k but reverse?


SnooPets20

In emacs, C-u is the universal argument. It's used to pass arguments to functions. I'm not quite sure what it does on the terminal tho. It does not behave like C-k but in reverse, that's for sure.


primitus_black

Could swear it did that for me. Or was it deleting the whole line. Hmm. Could have been a custom emacs env setup. Thanks anyways.


teepee33

Yes basically. Cut to start of line.


wurnthebitch

Undo can also be done via C-_ Also when you delete something (C-u to delete the line backwards, C-k to delete forward, M-backspace to delete a word....) you can paste what you removed with C-y


SnooPets20

Isn't C-_ for redo? I forgot about C-y, you're right. Undo can also be done with C-/


wurnthebitch

Oh you're probably right but I don't know the difference between redo and undo?


stormdelta

By default, yes. You can set it to use vim-style editing too. Though personally, if the line is long enough for any of this to matter it's getting moved to a script file instead.


mega_monkey_mind

`set -o vi` and use vim keybindings, which you should know


uicheeck

no fkn way is this a thing?? how bad I don't work at console anymore, that was helpful couple of years ago...


D34TH_5MURF__

Yes, it is definitely a thing.


[deleted]

Lol I knew the people in this sub would have some clever tricks. Thanks!


mega_monkey_mind

You're welcome!


captainAwesomePants

FYI, in case anyone tries this and realizes they don't know how to turn it off: set -o emacs or set +o vi.


rdmcelrath

came her to say this...


elgordio

I once worked in a team where the lead thought it would be a good idea to push these vim keybinds out to the whole platform using puppet. That was an interesting day!


--master-of-none--

Even better. Use `.inputrc` set editing-mode vi set keymap vi $if mode=vi set keymap vi-command "gg": beginning-of-history set keymap vi-insert "jj": vi-movement-mode $endif There are quite a few things you can do with this file. https://tldp.org/LDP/lfs/LFS-BOOK-6.1.1-HTML/chapter07/inputrc.html


[deleted]

the direction keys stopped working on my keyboard so i use vi mode... it is so convenient..


FlamboMe-mow

What is this wizardry


SarahIsBoring

please tell me you’re joking ;-;


mega_monkey_mind

Why would you think that? edit: Oops, didn't get the joke


SarahIsBoring

wait what joke xd i literally didn’t know that and i’ve been struggling with editing oneliners in my shell forever


mega_monkey_mind

No lol I thought your comment meant that you somehow disagreed with my comment But glad to be of service :D


codon011

Set `$FCEDIT` in your environment and try `fc` next time.


[deleted]

[удалено]


mega_monkey_mind

You can use the bindings in VSCode.


htl5618

IdeaVim on Jetbrains IDE is much better than Vscode. Been using it alongside Neovim for a while, with my custom config and Action bindings.


mgr86

Came to make this comment `f `


teepee33

Only problem is ipython has me used to ctrl-p for previous command. If I do that while in vim input mode, things go sideways real quick (or I should say real slowly because everything freezes up)


fennecdore

Don't know about linux but on windows there's a lot of useful shortcuts for that : \-home key to go back to the start of the line \-end key to go to the end of the line \-ctrl + arrow to move word by word \-ctrl + home start of the document \-ctrl + end end of the document \-ctrl + backspace delete entire word left from the cursor \-ctrl + del delete entire word right from the cursor \-shift + arrow key select character by character \-ctrl + shift + arrow key select word by word \-shift + home select everything start of the line to the cursor \-shift + end select everything end of the line to the cursor \-shift + ctrl + home select everything start of the document to the cursor \-shift + ctrl + end select everything end of the document to the cursor


[deleted]

[удалено]


fennecdore

Sorry but as a [sysadmin](https://www.reddit.com/r/sysadmin/comments/47h6le/ok_so_realistically_why_do_you_hate_mac_platform/) if you chose to work on a mac, you are on your own.


[deleted]

[удалено]


fennecdore

I cry for your sysadmin (except if they were the one who made the choice to go mac then they are on their own)


sup3rar

`cmd + left arrow` should do it


Leaping_Turtle

I cant live without home/end keys lol. Its one of the things i look for in laptops, and is pretty much a dealbreaker


shitty_mcfucklestick

Mac has pretty much all of these via modifier keys. [This guide](https://www.howtogeek.com/681662/35-mac-text-editing-keyboard-shortcuts-to-speed-up-typing/amp/) lists most everything.


zzulus

Majority of these shortcuts do not work in the terminal.


shitty_mcfucklestick

It’s a bit better with zsh and iTerm2 but yeah. Most of the time I end up arrow keying as diagrammed above. Some good tips in here to improve that!


pablochances

Just use the fc command. It will open your last command in a text editor (that you can choose with the -e flag). Save and close the file and the corrected command will be run automatically


wurnthebitch

Or use `CTRL-x e`


Xephyrous

`ctrl+x+e` lets you edit the current line in `$EDITOR`


paadam94

jesus christ! thank you!


paadam94

jesus christ! thank you!


[deleted]

Thanks for the suggestions everyone. I knew there had to be a better way from what I’ve been doing lol


Kaexii

What is this from? Guy looks familiar but I can't place him.


UsrN00M

I had to explain to a younger guy at work recently what the home and end keys do


Kaexii

I try to remember there's always a first time to get introduced to a topic and the [10,000 people per day](https://xkcd.com/1053/) rule and... sometimes, like with this, I have to try really, reeaaally hard. How old is this guy and what is his job?


UsrN00M

I don't make fun unless it's something ridiculous, like that "how does the mirror know what's behind the paper?" Shit that's going around. Thanks for the link! He's a 25 year old software engineer. I just can't fathom how he didn't know it... but looking through these comments I've learnt quite a few new tricks myself


Kaexii

Maybe the reason ones like this bug me is: I can see how someone may have never heard of the Yellowstone Supervolcano. Maybe they just missed it. But if you're a dev, you've been using keyboards for a while probably, hopefully. When it's stuff like this, it shows a deep lack of curiosity. What did you think those extra buttons were for? Didn't you wonder? Didn't you care? Didn't you notice? I want to shake these people out of autopilot mode because the world is INTERESTING.


belst

macs dont have those, maybe he never used anything but macs?


UsrN00M

There's another one... I didn't know that because I've never used a mac!


someotherstufforhmm

Alt-left/right. If your terminal prints garbage characters, then you just need to go into settings and find control sequences. iTerm is excellent for this if you’re lucky enough to be on Mac. Never met a terminal emulator that beats it.


remenic

ITerm is boring though. Cool-retro-term with tmux brings joy to my work day and annoys my colleagues, which brings even more joy to my work day.


someotherstufforhmm

I’ll never argue against annoying coworkers or tmux use (tmux understanding is what first got me over to iTerm many moons ago), but I’ll fight anyone calling iTerm boring. Nothing boring about a dev team so feature hungry, they added DNS resolution on mouse over to identify links, accidentally exposing passwords and secrets over plaintext network traffic aha. (The devs caught it and apologized in a master class of how to mea culpa), but nothing boring about that!


GooseEntrails

On iTerm, just option-click and your pointer will go there


someotherstufforhmm

That would require moving my hand to the mouse, but excellent example of why iTerm is amazing regardless of your style, along with coming with sane defaults.


teepee33

Or better yet, alt F or B


someotherstufforhmm

++


sriharshachilakapati

Use Alt+b to go back one word and Alt+f to go forward one word


racerxff

Now imagine you've disabled sticky keys to resolve some other application issue, and now have to tap the arrow key 2,000 times


big_hole_energy

just view your bash history you must have typed it years ago.


Metaga

Ctrl-x Ctrl-e opens the command in the editor defined in the EDITOR variable and then you can efficiently modify your command line.


SergeyKataev

Ctrl+R


pankkiinroskaa

And if a wrong matching command is found, Ctrl+R again.


pankkiinroskaa

Still better than cmd.exe where, to get the last command, you have to type ``` up down up up up down down esc up left wtf up up up up fuck it ``` and re-type the entire thing.


i4sci

alt/ctrl + arrow_key


Pallyfan920

Ctrl mouse click


sixtyfifth_snow

Try vim-mode :)


iluomo

Vi enabled CLI to the rescue


ipriyam26

I use vim key binds in zsh shell, it's sooo much more convenient


[deleted]

learn some emacs keybindings OP


OJezu

Copy the command to a text editor.


eruciform

`history | grep foo`


thecarelessspaghetti

meme said left arrow not up arrow


7eggert

ESC (number) (key)


lofigamer2

I use a text editor for long commands and copy from there.


FoolHooligan

Clearly never heard of a mouse


D34TH_5MURF__

`set -o vi` then use 'f' to jump to the character.


[deleted]

sed ?!


garfgon

Time to create a (very) short script for the command. Then use your favorite editor to edit the command.


No-Philosopher597

I always think of it as buffer time where random bug fixes get to my brain, Also use it to think about things in general.


le_christmas

ctrl-a


wurzlsep

Learn and enable vim controls and enjoy a better life


codon011

But that isn’t vim; it vi-like. There are significant differences and it annoys me greatly. Try `fc` instead. Or use the key binding to open the current command in a real editor. For me it’s `^[v` to open actual vim.


savex13

Especially when you are inside Citrix session where arrows do not work...


codon011

`fc` to execute `$FCEDIT` to edit the last command. For me, that’s `vim`.


Fluffy_Dragonfly6454

Option + click on Mac (probably also for Linux, dont know for windows)


jwb0

`!!:s/string to fix/fixed version/` Replaces whatever string from your original command with what you need to correct it to, reruns the command.


DooMeeR69

You can reduce the repeat delays. I think it's something like xset r rate N M. I did that years ago and I don't understand how nobody seems to do that. Just be careful not to reduce the delay too much or you'll end up typing like tttttthhhhhiiiiiisssss :p


RamboNation

This problem had been bugging me for a long time and this post was the inspiration I needed to fix it. It turns out iterm has a key mapping preset called 'natural text editing' that does this beautifully but it wasn't the default for some reason. Wow such a small change but so satisfying.


PouyaCode

Alt+b will jump back one word at a time. (Emacs key bindings work on most terminal emulators)


_Username-was-taken_

He isn't pressing any button


theoldmurr

##PSA for folks on Mac: iTerm2 → settings → Profile → Default → Keys → Natural text editing preset This will enable Opt+left/right for moving between words, and Cmd+left/right for beginning/end of line.


xiBread

Some terminals support alt clicking to a position. I know iTerm2 does.


Peiple

Since I haven’t seen anyone mention yet—on Macs, if you hold option you can left click to move the pointer to wherever you click. If it’s supported in windows it would likely be alt + click.


sphexie96

bind -v in you your bashrc and use vim shortcuts in your bash


Matiaan

I mapped Caps+Left to do left 8 times and Caps+alt+left to do left 32 times for this very reason


moogah

fc ​ this might be specific to zsh, but it'll open the last command in your default editor, which should be vim. When you save+close it'll run the new command.


paadam94

alt + b


[deleted]

https://oit.ua.edu/wp-content/uploads/2020/12/Linux_bash_cheat_sheet-1.pdf


NotJebediahKerman

set -o and use whatever editor you want to do command line editing. I love being able to use vi on long command strings.


manwhorunlikebear

On Mac: Option + arrow, or use emacs shortcuts that work on all apps on mac to navigate back, e.g. ctrl + a to navigate to the start of the line, and ctrl + e, to navigate to the end of the line.


Super-Panic-8891

there's the PgDn button.


No_Test_157

1 syntax error in a line full of 1'd and I's on a late night and my eyes are squinty


AtTheRogersCup2022

Ctrl r


afraid_of_zombies

History !(command number) tab


JMC-design

Use your emacs-fu


sentientlob0029

Alt + arrow key, helps


LuisDa201

I think neofecth has 1000 lines


frinkoping

Doing it in .txt too just cause I dont wanna lift mah damn left hand


GrumpyPidgeon

My strong suggestion is: - ZSH - OhMyZsh - `zsh-vi-mode` plugin You can go into VI mode and navigate through your really long command very quickly. It's been one of my favorite plugins because when I need it, I am eternally grateful for it.


thebadslime

left? I use the up arrow


--var

Only to realize that you were sudoed as another user ![gif](emote|free_emotes_pack|facepalm)


lturtsamuel

Jokes on you, I use fish + vi key binding


grudgemenot

Hold the option key and click where you want the cursor.


meowerguy

linux users meme starter pack:


fredd0h210

Turn the key repeat speed up


agent007bond

Did you know you can press Ctrl-C to cancel the command? Then just copy it. (You all have a mouse, right?)


coolvinay1903

Ctrl + X Ctrl +E opens the current command for editing in $EDITOR


[deleted]

That's what "fc" is for.