5 ms·
What's the deal with Ctrl+Left and Ctrl+Right?
- Piskvorrr 9y agoI don't want consistent behavior everywhere; I want contextual behavior. In an English text, cursor should stop at different locations than in a programming language. In other words, the default algorithm used by a all-purpose editor (Notepad) is "don't offend too many users too much", not "we know that users are using this editing control for code, hence movement to underscores".
- monsieurbanana 9y agoI think I'd prefer consistent behavior. Contextual behavior would be more efficient, but it would also take longer to internalize. I use ctrl+left/right all the time (well actually ctrl+f/b because I use emacs), and I can't actually tell you where the cursor would stop, but my fingers do... It's become muscle memory. It would take longer for my fingers to understand contextual behavior.
- monocasa 9y agoAlso, what happens when you mix the two, ala comments.
- chipperyman573 9y agoIsn't the point of contextual behavior to consider things like that? So it would act differently in comments.
- monocasa 9y agoSo my editor starts applying different keyboard shortcuts as I scroll through the same file? Yeah, I want distinctly none of that.
- richardwhiuk 9y agoThe same shortcut 'move on a bit more than right arrow'
- Piskvorrr 9y agoAnd that's the exact reason there are so many text editors to choose from ;)
- Spivak 9y agoAbsolutely, simple examples would be automatically wrapping comments to 80 characters, adding the comment sigil on the next line when you press enter, enabling spell checking, turning on syntax highlighting if it detects a docstring, changing the semantics for what qualifies as a word, statement, paragraph/block.
- kqr 9y agoNot to mention that it's impossible to write a general contextual solution, so in some contexts it would not behave properly. I would rather have a solution that works consistently across all contexts than one that's perfectly contextual in some contexts. (Also the reason I prefer Vim/Emacs over language-specific IDEs. I like to use the same editor tools for all sorts of writing – and good tools are general enough to work that way.)
- oftenwrong 9y agoThis is discussed a bit in "Why Don't We Have a General-Purpose Tree Editor? (2014)" https://news.ycombinator.com/item?id=13578256 https://news.ycombinator.com/item?id=13578256 https://news.ycombinator.com/item?id=7511979 https://news.ycombinator.com/item?id=7511979
- ldp01 9y agoThis is where I just gave up and just started using Vim plugins wherever possible. Edit: He calls out IDEs as a place you can't use Vim. But I think most widely used IDEs tend to have Vim plugins...
- ge0rg 9y agoIronically, Vim IDE plugins often have slightly different behavior on seemingly identical key buildings...
- Rotareti 9y agoSame here. I'm really happy about the plugins. They allow me to stay with vi-style of editing almost entirely. I use them for JetBrains IDEs, Atom, zsh, Firefox, Chromium and Emacs.
- Spivak 9y agoI just wish that Vim plug-ins meant that the IDE would actually embed Vim inside the IDE and do some vimscript magic to do integration. Vim plug-ins that just simulate the default Vim keybindings are just sad.
- yoz-y 9y agoBut some editors do vim integration really well. I was quite amazed when I discovered that the VS Code vim plugin is actually fully compatible with multiple cursors.
- kqr 9y agoI'm guessing these plugins have improved in the last couple of years? Every time I've tested them, I've been somewhat disappointed. Part of it is probably that I expect the Vim experience to include 1. The full command set, like :set paste and :set foldmethod=indent; and 2. Some basic plugins, like EasyMotion and surround.vim. Not even evil-mode gets this completely right, but it's close enough to be worth it.
- whipoodle 9y agoI like how Sublime does this. On the Mac, if you use Ctrl instead of Option, it gives you the ability to delete individual words in a camelCase or snake_case identifier.
- robin_reala 9y agoI did not know that, mostly because I had ctrl+arrows uselessly bound to Mission Control. Thanks!
- stinos 9y agoFor the sake of completeness: on Windows and Unix Ctrl goes over entire words while Alt considers camelCase and under_score.
- woodrowbarlow 9y agosublime has a configuration option ("word_separators") that lets you set which characters are considered to separate words. you can add the underscore to this option.
- gbrown_ 9y agoI'm at the point we're if I'm typing anything more than a few sentences I'll write it in Vim and just copy/ paste.
- deerpig 9y ago"Some of you might be thinking, just use vim or emacs and you don't have to worry about using Ctrl+Left and Ctrl+Right because there are better ways of navigation. But you are not always in vim or emacs, sometimes you are in a browser or an IDE." Uh, no. I'm pretty much always in Emacs. Except when I'm posting a comment on HN :)
- nemoniac 9y agoAnd even then you could be in emacs: https://www.emacswiki.org/emacs/Edit_with_Emacs https://www.emacswiki.org/emacs/Edit_with_Emacs or https://addons.mozilla.org/en-US/firefox/addon/its-all-text/ https://addons.mozilla.org/en-US/firefox/addon/its-all-text/
- dangom 9y agoNot to be forgotten: https://addons.mozilla.org/nl/firefox/addon/firemacs/ https://addons.mozilla.org/nl/firefox/addon/firemacs/ Because even for things that are not text, there is no reason not to stick to Emacs.
- jwilk 9y agoNon-Dutch link: https://addons.mozilla.org/firefox/addon/firemacs/ https://addons.mozilla.org/firefox/addon/firemacs/
- DanHulton 9y agoWhat about when you're in shell?
- Spivak 9y agoThere is never a reason to leave Emacs. M-x eshell M-x term
- jacobsenscott 9y agoI wish. Every now and then I try and use emacs term. It is slow, doesn't handle screen resizes well, and God forbid you try and use tmux within emacs term. You'll be sorry.
- stillbourne 9y agoWhat? Are they out of control?...
- felipellrocha 9y agoMaybe we should rebind them to Alt+left, and Alt+Right.
- FLGMwt 9y agoThis is one of the most infuriating things about Macs for me. Maybe Vim/Emacs aside, I've found word jumping and Home/End operations to be absolutely consistent on Windows, but just about every OSX app seems to have a different shortcut. As the author points out, the exact cursor position in some apps is different on Windows, but he shortcut is always CTRL+{direction}
- m12k 9y agoReally? On Mac I've found it very consistent that alt+left/right jumps forward/back one word, alt+up/down jumps to start/end of paragraph, cmd+left/right jumps to end of line, cmd+up/down goes to beginning or end of all text (like Home/End). This is the case for me in Sublime, RubyMine, Xcode, Firefox, Chrome and any other app I've used in recent years - which apps are you using that don't follow these conventions?
- colanderman 9y agoIn Chrome on OS X it differs whether I'm casting my screen or not, whether Ctrl+←/→ move me to the start/end of a line or document. (I can't figure out how to move to the end of a line while Chromecasting. It is beyond frustrating.)
- tlb 9y ago^e for end-of-line, ^a for beginning-of-line. ^p for previous-line, ^n for next-line. All far more ergonomic than arrow keys.
- d--b 9y agoOh, I thought this was a political article with a geeky pun on alt-right and alt-left...
- jcranberry 9y agoI'm mildly suspicious that this article is satire. It's not that I don't sympathize--I have a personal laptop on Ubuntu, work computer on OSX from which I sometimes VN into a machine with CentOS, and using spacemacs means I often context switch between a set of shortcuts which takes from both emacs and vim. However, I feel that, of the things which need to be standardized across platforms, the CTRL+* shortcuts really is low priority.
- mattmanser 9y agoIf it's one of your primary tools of navigating code without using the mouse, it's going to be a concern. For example, in Visual Studio ctrl-x with nothing selected will cut the whole line, but very few other programs support that. As well as using to move code around, I use it to delete lines (ctrl-l is better supported, but you can still do ctrl-x with your hand on the mouse). So when it doesn't work in Notepad++, it's quite annoying as it breaks your flow. I'm using a plugin to simulate it, but it's not quite right still. One of the another thing that can catch you out is that the various MS code editors behave differently depending on the language you're using, SQL Management Studio will treat anything wrapped with []s as a single string, but while in text strings of SQL in Visual Studio it will stop on each bracket. It end up being quite annoying you can't mark a string in VS as a sql string when you want to make a small tweak or add an extra column. It's muscle memory, and so it's going to annoy you when it doesn't work, it makes you feel clumsy in the new environment.
- deleted 9y ago[deleted]
- rodorgas 9y agoI've always thought that Ctrl+Left and Ctrl+Right were borrowed from Emacs M-b and M-f. Isn't it true? Are there older programs using these key bindings?
- tomatsu 9y agoKomodo Edit/IDE had some command for selecting the word which is touched by the cursor (|foo, f|oo, foo| -> would select "foo"). It's similar to double-clicking a word. I used Ctrl + Shift + Down to activate it. Too bad it isn't a standard thing. I liked it a lot.
- stringham 9y agoI had the same problem with vscode. I filed this issue: https://github.com/Microsoft/vscode/issues/32246 https://github.com/Microsoft/vscode/issues/32246 Rather than wait, I ended up creating this extension last weekend to do it the way I wanted it to: https://marketplace.visualstudio.com/items?itemName=stringham.cursor-move https://marketplace.visualstudio.com/items?itemName=stringha...