News for hackers. Stuff that matters.
Re:Vim Anywhere by simplify on Friday February 16, 2018 @03:39PM (#16395941)
It's not vim, but many terminal-based keyboard shortcuts are already available across OS X without installing anything. For example:

    - ctrl+p - move cursor up one line
    - ctrl+n - move cursor down one line
    - ctrl+f - move cursor forward one character
    - ctrl+b - move cursor back one character

    - ctrl+a - move cursor to beginning of line
    - ctrl+e - move cursor to end of line
    - ctrl+k - delete all characters from cursor to end of line
There are a few missing useful ones (such as move by word), but you can fill them in by creating this file[1] in a specific place on your machine.

[1] https://gist.github.com/gilbert/10fdd692799fc7269b50abbcfb2e...

Re:Vim Anywhere by caymanjim on Friday February 16, 2018 @04:57PM (#16396831)
These are Emacs shortcuts, not Vim. They're available in bash (the default MacOS shell) because bash uses the readline library. You can also put readline into Vi mode and use Vi/Vim shortcuts, but none of this has anything to do with editing files.
Re:Vim Anywhere by simplify on Friday February 16, 2018 @05:15PM (#16396955)
> but none of this has anything to do with editing files.

Why not? You can use these shortcuts across OS X. That includes your web browser and any other GUI you have on your machine (I use them heavily in notational velocity).

Re:Vim Anywhere by saagarjha on Saturday February 17, 2018 @01:37AM (#16399396)
They work anywhere there's a system-provided text field.
Re:Vim Anywhere by fimdomeio on Friday February 16, 2018 @06:19PM (#16397483)
fish shell has a vim mode for anyone interested
Re:Vim Anywhere by xelxebar on Saturday February 17, 2018 @02:01AM (#16399451)
This is actually a readline thing, so you can edit your $HOME/.inputrc with

   set editing-mode vi
and get the vi bindings in everything that supports readline, e.g. the Python shell etc. There's tons more that can be customized here. You can even have it put the current vi mode in your prompt and stuff like that.

https://www.gnu.org/software/bash/manual/html_node/Readline-...

Re:Vim Anywhere by hnzix on Friday February 16, 2018 @07:31PM (#16397972)
Bash and zsh also have vim mode. The bash mode is more like vi though.
Re:Vim Anywhere by egwynn on Friday February 16, 2018 @07:39PM (#16398028)
Indeed, it’s in fact called “vi mode” in the bash/readline docs.
Re:Vim Anywhere by egwynn on Friday February 16, 2018 @03:46PM (#16396017)
1. I think this is for the people who want more than just a couple vi-like motion keys.

2. Five of your seven shortcuts are for emacs[0], not vim.

[0]: https://www.gnu.org/software/bash/manual/html_node/Command-L...

Re:Vim Anywhere by simplify on Friday February 16, 2018 @03:57PM (#16396151)
Right, I just thought it was interesting enough to point out how there are many navigation shortcuts that are built into OS X. Useful even when you're using someone else's computer.
Re:Vim Anywhere by omaranto on Friday February 16, 2018 @05:38PM (#16397161)
All seven are default keybindings in Emacs. Which two did you believe weren't?
Re:Vim Anywhere by egwynn on Friday February 16, 2018 @05:57PM (#16397316)
I believe ctrl-n and ctrl-p work in vim
Re:Vim Anywhere by omaranto on Friday February 16, 2018 @06:03PM (#16397360)
Oh, I see. I had forgotten that. They do also work in Emacs and I wouldn't be surprised to learn that their use in Emacs predates Vim.
Re:Vim Anywhere by egwynn on Friday February 16, 2018 @07:38PM (#16398020)
I’m not sure when Vi[m] got ctrl n/p, but it looks like emacs got it WAY early on: http://ergoemacs.org/emacs/emacs_kb_shortcuts_pain.html
Re:Vim Anywhere by gumby on Saturday February 17, 2018 @11:26AM (#16401329)
I've been using those commands in Emacs since the late 70s
Re:Vim Anywhere by thomastjeffery on Friday February 16, 2018 @04:50PM (#16396751)
Those are emacs-based shortcuts.

They are also the default in most shells (bash/zsh), which also have optional vi-based bindings.

Re:Vim Anywhere by omaranto on Friday February 16, 2018 @05:00PM (#16396865)
Those OS X keybindings come from Emacs! I bet some vimmers would refuse to use them just on principle. :)
Re:Vim Anywhere by sodapopcan on Friday February 16, 2018 @05:45PM (#16397217)
I'm a vimmer and always use readline bindings in "insert" mode context. I find using vim bindings on the commandline to be infuriating.

On macOS, you need to add the following to $HOME/Library/KeyBindings/DefaultKeyBinding.dict to get ctrl-w and ctrl-u to work everywhere in macOS.

{ "^w" = "deleteWordBackward:"; "^u" = "deleteToBeginningOfLine:"; }

Re:Vim Anywhere by eadmund on Friday February 16, 2018 @11:18PM (#16398967)
> I find using vim bindings on the commandline to be infuriating.

Some folks find vim bindings to be just as bad to edit text grin

I don't actually agree: I think that vim's text-editing language is actually nicer than emacs's is. But I use emacs — with its bindings, not vim's — because after almost thirty years it's what I'm used to.

Re:Vim Anywhere by sodapopcan on Friday February 16, 2018 @11:34PM (#16399030)
Haha, I've never been interested in the whole vim vs. emacs thing. I just started with vim and a little too invested in it now. It definitely drives me nuts that it loads entire files into memory and that is the one thing that has made me tempted to switch. It rarely affects me but every once in a while when I accidentally open a massive file in vim and have to wait, I dream of emacs. I would use evil mode, OF COURSE :)
Re:Vim Anywhere by omaranto on Friday February 16, 2018 @05:58PM (#16397327)
Oh, if you like those bindings in insert mode, you are probably already aware of Tim Pope's vim-rsi [1] plugin. If not, check it out, it might have some interesting bindings you aren't using yet.

[1] https://github.com/tpope/vim-rsi

Re:Vim Anywhere by sodapopcan on Friday February 16, 2018 @06:04PM (#16397369)
I'm absolutely aware of it and was gonna mention it but figured I'd said enough :)

When I said "insert" I meant like, "insert mode" everywhere else but vim :)

But yes, RSI is a great plugin (as are most of tpope's plugins)

Re:Vim Anywhere by sodapopcan on Friday February 16, 2018 @06:09PM (#16397406)
Also, you mentioning it made me realize I never starred the repo, so thanks, haha!
Re:Vim Anywhere by Lio on Saturday February 17, 2018 @05:20AM (#16400029)
Thanks so much for this. I usually use Karabiner for the same thing.

Do you know anyway to get the same behaviour on Linux and Gnome at all?

Re:Vim Anywhere by jsjohnst on Sunday February 18, 2018 @12:45PM (#16407154)
I’m a heavy vim user and yet I add bindings to vim for Control-A and Control-E.
Re:Vim Anywhere by jaequery on Friday February 16, 2018 @05:29PM (#16397075)
now that’s funny
Re:Vim Anywhere by girvo on Friday February 16, 2018 @06:44PM (#16397665)
Doesn’t Option-(Arrow Left|Arrow Right) move around per word?
Re:Vim Anywhere by simplify on Friday February 16, 2018 @08:12PM (#16398200)
You're right, but option+(f/b) is handier when combined with ctrl+(f/b)