Re:Vim Anywhere
by jxy on Friday February 16, 2018 @03:52PM
(#16396090)
I have an Automator workflow script, which uses emacsclient to edit any text, in my `~/Library/Services`. The service receives selected text in any application and output replaces the selected text. It consists of two parts: Run AppleScript, and Run Shell Script.
The AppleScript part is:
on run {input, parameters}
tell application "EmacsMac" to activate
tell application "System Events"
repeat until visible of process "Emacs" is true
delay 0.5
end repeat
end tell
return input
end run
and the Shell Script part (pass input to stdin) is:
tmp=$(mktemp "$HOME/tmp/EditTextinEmacsXXXXXXXX")
ec=/Applications/MacPorts/EmacsMac.app/Contents/MacOS/bin/emacsclient
cat > "$tmp"
until [ $($ec -q -e '(server-running-p)' 2>/dev/null) == t ]; do
sleep 1
done
$ec -q -c "$tmp"
rv="$?"
cat "$tmp"
if [ $rv -ne 0 ]; then
echo "Something went wrong. Please find your text in"
echo "$tmp"
else
rm "$tmp"
fi
Getting it to work with any editor should be straightforward.
Re:Vim Anywhere
by ulkesh on Friday February 16, 2018 @10:39PM
(#16398819)
Maybe I'm just not _getting it_ and am too old for this, but why would I ever want to have my computer open a completely different program simply to input text into a text box when it already has focus and I can simply type at that point?
I understand using vim for development, or editing files while already at a command prompt; I just don't see the point in this use case other than to feel clever.
I am willing to be enlightened if I'm missing something.
Re:Vim Anywhere
by eadmund on Friday February 16, 2018 @11:16PM
(#16398962)
I don't know if it's as applicable for a vim user, but as an emacs user I really appreciate having access to the same tools I use to edit all of my other text: the same search, the same dictionary, the same completion engine, the same Org-mode keybindings (so that I can save myself a note or TODO as I'm in the middle of writing), the same … everything.
Honestly, every programme other than emacs is a distraction.
Re:Vim Anywhere
by Lio on Saturday February 17, 2018 @05:10AM
(#16400003)
I’m a Vim user but this exactly nails the point. I mostly use the terminal for everything I can because I know the shortcuts and they’re consistent across operating systems.
For all its faults, readline is a godsend for Vi users.
Re:Vim Anywhere
by gschier on Saturday February 17, 2018 @12:30AM
(#16399233)
If you're not a heavy Vim user you may not understand but the only way I can describe it is that Vim is different enough that it makes you forget how to edit text the "normal" way. One example is that Vim doesn't require arrow keys, so having to use arrows to navigate text in a normal editor is a huge pain.
Re:Vim Anywhere
by lucb1e on Saturday February 17, 2018 @07:23AM
(#16400377)
And hjkl is not the arrow keys' replacement, as many non-users think.
There are a hundred other ways to move around a file, each of which are more efficient than hitting a button ten times. Those kinds of things are what makes Vim convenient (though not having to move your hand to the arrow keys for going one line down is pretty convenient, too).
Re:Vim Anywhere
by djsumdog on Saturday February 17, 2018 @02:02AM
(#16399456)
I probably wouldn't use this either, but I can see how it can be helpful. If you do a lot of posts on Stackoverflow, you can get some markdown+code highlighting. People use to Vim can use all it's fancy searching and jumping to specific points of text. You can do regex replaces.
Basically if you want a powerful editor just in case when you're filling out a form or something else, here you go?
Re:Vim Anywhere
by tempay on Saturday February 17, 2018 @01:59AM
(#16399450)
I'm a sublime user but I find myself accidentally using keyboard shortcuts when doing things such as:
- Writing emails in gmail
- Replying to instant messages
- Writing answers on stack overflow
- Filling out web forms
This is mostly for multiple cursors which are now ingrained in how I type. I'll often copy text to sublime and then copy it back so having a automated way of doing this doesn't seem crazy to me anymore (it would have done 5 years ago).
Re:Vim Anywhere
by gkya on Saturday February 17, 2018 @05:32AM
(#16400064)
Some keybindings are ingrained. I use Quail and Electric quotes all the time in Emacs (modes which modify the letters you input), and I write lots of prose in Emacs, so using Ctrl-q <char> to "quote" a character to input it literally is something I frequently do. It happens that sometimes I do that out of muscle memory in Firefox, and Ctrl-q quits in Firefox. Or you press Ctrl-n for next line a couple times but you get some new blank windows instead. I confuse Ctrl-f and Ctrl-s all the time. Many other bindings are easily confusable.
I'd actually like Firefox to be customisable instead of a hack like this. I'll probably just switch to the Next browser [1] in the future though.
Re:Vim Anywhere
by bo1024 on Saturday February 17, 2018 @08:18AM
(#16400541)
The reason I don't see the benefit is that, if a piece of text is long enough that I prefer using vim over just typing in the text box, then I probably want to actually save a copy to disk in case clicking "submit" doesn't go through. So I might as well actually use vim at that point.
Re:Vim Anywhere
by dozzie on Saturday February 17, 2018 @09:31AM
(#16400797)
That's how it works (worked) with It's All Text! extension for Firefox: you
set an editor (`gvim -f' in my case) and on a keybinding it's started with
a file as its argument. Text area gets updated on write to the file.
Normally you don't need to see or worry about the intermediate files, but in
case anything goes awry, you still have the option.
Re:Vim Anywhere
by jacobmoe on Saturday February 17, 2018 @08:43AM
(#16400623)
I'm looking forward to using this for writing JIRA tickets. Their text boxes override some mac key bindings that are deep in my muscle memory. Want move back a space? Oops, ctrl-b in this text box makes text bold. Jump to the start of the line, well ctrl-a now inserts a link. There's something just so annoying about that, it makes me bristle at using jira in general.
Re:Vim Anywhere
by rasengan0 on Saturday February 17, 2018 @10:44PM
(#16404329)
>... simply to input text into a text box ...
Vim (and other editors) offer powerful editing macros that ease bulk text operations. Simple things like text substitution across hundreds of lines save so much time. I still use https://github.com/docwhat/itsalltext running on https://www.waterfoxproject.org/ which allows textarea editing from the terminal.
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.
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 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.
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 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.
Re:Vim Anywhere
by zipperhead on Saturday February 17, 2018 @10:34AM
(#16401105)
I use something like this but I initialize the file with the contents of the clipboard. I use xclip but I think xsel can do the same. Here's a snippet:
Re:Vim Anywhere
by davidbanham on Saturday February 17, 2018 @07:05AM
(#16400335)
I love the idea! I often open up vim to edit some stuff, save it in a temp file, then copy it. I never realised I needed a more streamlined version but after seeing this it hit me like a brick.
I don't think I need that much scaffolding, though. I just knocked this together:
Re:Vim Anywhere
by Theodores on Friday February 16, 2018 @05:25PM
(#16397047)
No Windows version, where I need it.
If you are used to Vim then regular editors are dangerous, you find things like '=aB' or 'jjjjj' or 'ZZ' or ':w!' embedded in one's files, breaking everythng.
On Windows you can't just copy and paste from something edited in a terminal, or copy paste to a terminal to do your editing/saving as there is no 'vi'.
I note this software could be upgraded to work with Windows now there is that Ubuntu subsystem in there somewhere. Perhaps a better way would be to modify the accessibility tools - StickyKeys etc. - to have vim be the universal text entry arrangement even for things like username text boxes, you ':wn' to get to the password field and then type 'i' to start entering a password. Much easier.
Re:Vim Anywhere
by dag11 on Friday February 16, 2018 @04:55PM
(#16396812)
Fun fact, Ctrl+[ also escapes. Had to retrain my muscle memory to use Ctrl+[ when I got my Touch Bar mac, but I think I actually prefer it to ESC. It's guaranteed to work on vim on any system (unlike caps lock), and it keeps my fingers closer to home row.
Re:Vim Anywhere
by spraak on Friday February 16, 2018 @08:36PM
(#16398306)
Hm... I was able to 'feel' the ESC key on my touch bar. But I then remapped it to Caps Lock using Karabiner. I also remapped it on my Ubuntu laptop (with Xmodmap) since it's so nice. What systems have you not been able to get it to work on?
Re:Vim Anywhere
by K0nserv on Saturday February 17, 2018 @09:02AM
(#16400696)
I stil use ESC for visual mode, but as @Pete_D points out you could use jk there too, however it's a much more common input in visual mode so it would probably not work as well.
Re:Vim Anywhere
by Lio on Saturday February 17, 2018 @05:30AM
(#16400058)
Personally I prefer to use Karabiner-Elements to remap the right alt-key to ctrl. Been doing that since the first MacBook Pro when the key in that position was
“Enter”.
I find I don’t really miss the right alt key at all.
Re:Vim Anywhere
by zcid on Friday February 16, 2018 @06:09PM
(#16397407)
And what a nightmare it is to jump on a macbook because of that. I go crazy when I need to use an Apple keyboard. I can't begin to understand that particular ui choice.
as the two other sibling posters said, I use karabiner elements when on os/x and xcape+xmodmap on Linux with this in my .xsession
xcape -e 'Control_L=Escape'
which is run after remapping caps lock to Control_L via xmodmap (just xmodmap -pke to create your xmodmap file, xev to figure out which keycode your caps is, and edit the file after to make that keycode Control_L.
For example my xmodmap file, which also sets up meta/super and other overrides is
Re:Vim Anywhere
by fencepost on Saturday February 17, 2018 @03:27PM
(#16402529)
Remapping CapsLock to Ctrl on Windows is easy with KeyTweak (what I have is 2.3.0 by Travis Krumsick), though I had to select the CapsLock key from the displayed keyboard rather than simply hitting the key. All it appears to be doing is updating the Registry's key mapping values based on the keyboard scan codes. Easily found with a simple search, and it does work on Windows 10 even though it hasn't been updated for 8+ years.
I suspect you'd have to switch to something like Autohotkey for the Esc/Ctrl mapping.
Re:Vim Anywhere
by derriz on Friday February 16, 2018 @04:59PM
(#16396852)
I've gotten used to typing CTRL-[ instead of reaching for the Escape key because of the inconsistencies in its size and placement on various keyboards I use. Yes it's two fingers but you have to use CTRL in vim to get any benefit anyway.
Re:Vim Anywhere
by fphilipe on Saturday February 17, 2018 @02:25AM
(#16399530)
Have been using a US keyboard and never looked back to the Swiss one. Much better for programming and accents and umlauts are still easy to type. As I also occasionally type in Portuguese, German, Spanish, and French, I find the US keyboard to be the neutral middle ground.
Re:Vim Anywhere
by oelmekki on Saturday February 17, 2018 @02:10PM
(#16402160)
On linux, I don't use ESC at all anymore, I just press alt + [a normal mode key], while in insert mode. Like `alt + j`, which will leave insert mode and move one line down.
Some alt based sequences are really useful:
* alt + e, a : leave current parenthesis and continue inserting (eg, while typing parameters for a function)
* alt + shift + a : insert mode at the end of current line
* alt + shift + i : insert mode at the beginning of current line, with indentation
* alt + p, a : paste before current position, and continue inserting
Maybe there's a modifier key with a similar behavior on macosx?
Re:Vim Anywhere
by vram22 on Tuesday February 20, 2018 @12:45PM
(#16422222)
>On linux, I don't use ESC at all anymore, I just press alt + [a normal mode key], while in insert mode. Like `alt + j`, which will leave insert mode and move one line down.
Why does that work? Is it because Alt + some_key combos generate an escape sequence starting with the actual ESC character? I know that happens with many function key combos, don't remember or not sure about Alt combos.
Re:Vim Anywhere
by oelmekki on Tuesday February 20, 2018 @01:42PM
(#16422741)
This sounds plausible, but I have really no idea of why it works :) I found it by doing a mistype (like it often happens in vim), and didn't see it mentioned in any article that would try to get to the bottom of it yet.
Re:Vim Anywhere
by vram22 on Tuesday February 20, 2018 @02:38PM
(#16423417)
>I found it by doing a mistype (like it often happens in vim)
Ha, I probably found it by some similar way, maybe in vim or maybe in DOS / Windows / Linux at the command prompt or in some curses or terminal application.
Re:Vim Anywhere
by vram22 on Tuesday February 20, 2018 @12:44PM
(#16422206)
>* alt + shift + a : insert mode at the end of current line
Is that different from just Shift-a or capital A, which puts you into append mode at the end of the current line (no matter where you are on the line when you press it)?
Re:Vim Anywhere
by oelmekki on Tuesday February 20, 2018 @01:39PM
(#16422718)
yep, it does a 'A' in normal mode, after leaving the insert mode (thanks to alt). The different thing is that you do it (alt+shift+a) in insert mode. So the equivalent would be `ESC, A`.
Re:Vim Anywhere
by vram22 on Tuesday February 20, 2018 @02:41PM
(#16423449)
Then I guess that the Alt key generates an ESC char (ASCII code 27 [1]). Seems to tie in with the fact that Emacs docs say that you can use either Alt or ESC for the Meta key -
which is used a lot in Emacs commands (IIRC - I am not an Emacs user, just had tried it out earlier and think I remember reading read that).
Re:Vim Anywhere
by eddyg on Saturday February 17, 2018 @06:32AM
(#16400254)
Just use Ctrl-C instead of Escape. Often less hand-motion than going all the way to the upper-left, and it works everywhere, without custom remapping of Caps Lock, etc.
Re:Vim Anywhere
by Lio on Saturday February 17, 2018 @05:37AM
(#16400082)
I love the idea of a mechanical keyboard but I worry about productivity when I’m on the move.
I find it easier to stick to the laptop keyboard and trackpad even when at a desk plugged into a big monitor.
Everytime I try to switch to a mechanical keyboard and mouse my wrists start hurting. I guess this would go if I got used to the position but then what would happen when I have to use the laptop keyboard?
(So far I’ve tried an IBM model-m and a Pok3r keyboard).
Re:Vim Anywhere
by imahorse on Saturday February 17, 2018 @07:30PM
(#16403684)
From my experience, my wrists start hurting if I don't use any wrist rests (despite the name, you're supposed to rest your palms on them)
Also, tilted or high profile keyboards are less ergonomic IMHO.
Don't worry about switching back to the laptop keyboard on the go. You won't be less productive, you will just enjoy it less :)
Re:Vim Anywhere
by ufo on Friday February 16, 2018 @07:18PM
(#16397904)
Is there a way to exit without using the ":" key?
I ask because the other day I saw a friend of mine legitimately get stuck inside vim because he coundn't type ":". The keyboard language was set to the wrong language and none of the keys would output ":" when pressed. We had to reboot the machine and find a different keyboard.
Re:Vim Anywhere
by vram22 on Tuesday February 20, 2018 @12:40PM
(#16422171)
Ha ha, I don't know about nowadays on Windows/Linux/MacOS (maybe someone else can comment for that), but on DOS, you could get around such issues (like a key damaged or not present) by holding down the Alt key while entering the 1- to 3-digit ASCII code for the key you wanted to enter (0-255). That was used for all kinds of tricks and jokes in those days, like entering a fake space kind of key - some ASCII code while pressing Alt - I forget which one, maybe 255. It would look like the space char on the screen - a blank - but was not the same char. Could be used to create "hidden" files that those not in the know could not access, although the file was otherwise in plain sight in DIR listings and so on :)
Re:Vim Anywhere
by Noumenon72 on Saturday February 17, 2018 @09:47AM
(#16400876)
Even after 1.5 years of using vi at work, I still constantly get stuck trying to exit. Like I hit Ctrl+C or something, or ZZ with caps lock off, I don't even know. Then it's like "Type :quit to exit" or "Entering video mode" or "Press Shift-something to capture" and I do this random button mashing of Escape and q and ZZ that eventually gets me out, but I never know what I did.
Re:Vim Anywhere
by vram22 on Tuesday February 20, 2018 @12:35PM
(#16422126)
:x is not only a short for :wq - the latter saves (unconditionally, even if you have saved earlier and not edited since), and then quits (the file). I was going to say that :x is also a shortcut for :q (just quit) but it is of course not a shortcut for that, since it is the same length :)
I can better describe it like this:
:x is a shortcut for telling vi/vim: save the file if not saved after last change, then quit (in either case, whether a save was needed and done just now or not) - IIRC.
Also, as others said, Shift-ZZ (when Caps Lock is off), also saves and quits (and saves one keystroke over :x - because you have to hit Enter after :x, but not after Shift-ZZ :) It is also (slightly) faster to type, since the (left) Shift key is just next to the Z key (at least on some keyboards, like mine at present).
I like the idea, as I also want to write everything in Vim. But I (obviously) always have Vim running, and can get to it from anywhere with one keystroke. Once there, opening a buffer and copying its contents after writing stuff is just a few more keystrokes; so I don't see the need for this, at least for my setup--and I'm thinking that other hardcore Vim lovers have things set up similarly.
Re:Vim Anywhere
by eadmund on Friday February 16, 2018 @11:19PM
(#16398976)
> But I (obviously) always have Vim running, and can get to it from anywhere with one keystroke. Once there, opening a buffer and copying its contents after writing stuff is just a few more keystrokes …
As an emacs user, I just love seeing vim-users discover the utility of an always-there, complete text-editing environment. If only theirs had an extension language worth its salt …
Re:Vim Anywhere
by lphnull on Friday February 16, 2018 @05:56PM
(#16397313)
i3 and ratpoison are tiled window managers for Linux that make your whole computer behave like vim does. If you really are interested in simplifying the amount of work you do- you should consider abandoning the normal "stacked cluttered windows" paradigm in exchange for something that requires less pointless mouse work to achieve the same amount of work faster.
Most monitors have enough real estate to where alt-tabbing is not only unecessary, but counter productive and distracting. Its like using your foot to operate the gas pedal 100% of the time instead of using cruise control to drive hours in a straight line.
Linux (ubuntu) using xfce. Always have one workspace devoted to a full-screen Vim window, so can get there with a keyboard shortcut. In my .vimrc, I have
set clipboard=unnamedplus
so that yanked text is copied to the X11 clipboard. Yank buffer, switch back to browser (or what have you), paste.
With Vimium, the whole procedure is mouseless.
Agreed. This is a clever little hack that I never would have thought of. But I usually have a "temp" or "scratch" buffer running for this kind of thing anyways.
It is cool that apple has the ability to script like this though. It's pretty handy.
Re:Vim Anywhere
by weinzierl on Saturday February 17, 2018 @02:07AM
(#16399473)
Similar but only for the browser there is the "It's All Text!" Firefox Add-on. I used it for years, but unfortunately it stopped working recently when I upgraded to Firefox Quantum, so "Vim Anywhere" is a welcome alternative. Certainly will try it.
Re:Vim Anywhere
by lucb1e on Saturday February 17, 2018 @07:28AM
(#16400394)
This is why I'm still on Firefox 55. Fuck quantum. I used it a little on a different system and the slight speedup (main bottleneck is still WiFi/uplink) is nowhere near worth breaking all addons without even providing APIs to make replacements.
A sort of similar effect can be achieved with iTerm's hotkey window.
I usually run an emacsclient inside tmux inside the hotkey window, with a scratch text-mode buffer active.
If I want to use emacs to work on some text from a non-emacs app, the steps are something like: select text, cmd-c, press hotkey (mine is option+space), ctrl-y, edit the text, select what I need, opt-w, press hotkey to switch back to the app, then cmd-v.
Since the hotkey window is running tmux, it's easy to create or switch to another tmux window and operate on the text with the help of pbpaste/pbcopy and good old pipe.
Does anybody know of a way to do something like this in X11? I appreciate that macs have very nice built-in automation framework, but I'm not abandoning Linux just for that. There's xdotool for typing, but I don't know of any way to grab text boxes.
Re:Vim Anywhere
by bch on Friday February 16, 2018 @04:14PM
(#16396359)
A different tact (for some cases) to the same end: use elinks[0] and in an active <textarea>, press shift-ctrl-T to pop up your favourite editor[1]. This works for gmail, for example.
Re:Vim Anywhere
by jamesgeck0 on Friday February 16, 2018 @04:43PM
(#16396682)
I can't recommend that. Elinks doesn't verify SSL certs when connecting to HTTPS sites. It hasn't had a release in five years. It also has worse support for web standards than IE6.
Re:Vim Anywhere
by shakna on Friday February 16, 2018 @06:35PM
(#16397596)
Lynx doesn't have as good standard support, but it is still semi-active (2017-07-10 (2.8.9dev.16)) over at InvisibleIsland[0], and can be compiled with OpenSSL support. (Windows installers require OpenSSL by default).
Re:Vim Anywhere
by smaddox on Friday February 16, 2018 @03:41PM
(#16395952)
I'm on mobile right now, so not able to test it, but if you start with selected text, does it fill the buffer with it? If not, perhaps this feature could be added? It would be helpful for quickly dropping into to vim for advanced editing.
Re:Vim Anywhere
by deecewan on Friday February 16, 2018 @09:45PM
(#16398597)
It's just become apparent to me that outstanding has two very different meanings depending on context, and this is one of the first times I've seen it used where it could be ambiguous.
Re:Vim Anywhere
by numbers on Friday February 16, 2018 @04:53PM
(#16396794)
does this work on High Sierra for anyone? I'm having trouble getting the shortcut to trigger when in a text input on Chrome. I tried a couple different shortcuts already :/
Re:Vim Anywhere
by gkya on Saturday February 17, 2018 @05:42AM
(#16400099)
Knowing both is not hard. Also if you don't change too much defaults it's not hard to downgrade to vanilla programs. My init.el is above 3000 lines, but I can easily use vanilla Emacs any time if I need to (or vi/vim/ex/ed for that matter). Same for bash, my .profile and .bashrc combined count ~300 lines, both POSIX compatible, and I'd hardly have a hard time at a foreign shell prompt. That's because I use configuration to extend, configure and personalise a program, instead of trying to recreate it.
The AppleScript part is:
and the Shell Script part (pass input to stdin) is: Getting it to work with any editor should be straightforward.Is there any way to make it work without selecting text? (default to all available text on the textarea)
BTW, I changed a few things: emacsclient path and the tmp folder:
I understand using vim for development, or editing files while already at a command prompt; I just don't see the point in this use case other than to feel clever.
I am willing to be enlightened if I'm missing something.
Honestly, every programme other than emacs is a distraction.
For all its faults, readline is a godsend for Vi users.
There are a hundred other ways to move around a file, each of which are more efficient than hitting a button ten times. Those kinds of things are what makes Vim convenient (though not having to move your hand to the arrow keys for going one line down is pretty convenient, too).
Ordinary text editors have ctrl-left and ctrl-right, which are equivalent to Vim's w and b. They also have Home/End and ctrl-f.
Combined with relative line numbers (to show how many lines to jump up / down) this has been a really big win for me to navigate around text.
Apparently in Visual Studio it's SHIFT+CTRL+HOME.
Basically if you want a powerful editor just in case when you're filling out a form or something else, here you go?
- Writing emails in gmail
- Replying to instant messages
- Writing answers on stack overflow
- Filling out web forms
This is mostly for multiple cursors which are now ingrained in how I type. I'll often copy text to sublime and then copy it back so having a automated way of doing this doesn't seem crazy to me anymore (it would have done 5 years ago).
I'd actually like Firefox to be customisable instead of a hack like this. I'll probably just switch to the Next browser [1] in the future though.
[1] https://github.com/nEXT-Browser/nEXT
I can easily see the benefits of using this to write a long blog/fb post.
Normally you don't need to see or worry about the intermediate files, but in case anything goes awry, you still have the option.
Vim (and other editors) offer powerful editing macros that ease bulk text operations. Simple things like text substitution across hundreds of lines save so much time. I still use https://github.com/docwhat/itsalltext running on https://www.waterfoxproject.org/ which allows textarea editing from the terminal.
[1] https://gist.github.com/gilbert/10fdd692799fc7269b50abbcfb2e...
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).
https://www.gnu.org/software/bash/manual/html_node/Readline-...
2. Five of your seven shortcuts are for emacs[0], not vim.
[0]: https://www.gnu.org/software/bash/manual/html_node/Command-L...
They are also the default in most shells (bash/zsh), which also have optional vi-based bindings.
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:"; }
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.
[1] https://github.com/tpope/vim-rsi
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)
Do you know anyway to get the same behaviour on Linux and Gnome at all?
Bonus: This works anywhere xorg is available.
https://github.com/GhostText/GhostText
I don't think I need that much scaffolding, though. I just knocked this together:
If you are used to Vim then regular editors are dangerous, you find things like '=aB' or 'jjjjj' or 'ZZ' or ':w!' embedded in one's files, breaking everythng.
On Windows you can't just copy and paste from something edited in a terminal, or copy paste to a terminal to do your editing/saving as there is no 'vi'.
I note this software could be upgraded to work with Windows now there is that Ubuntu subsystem in there somewhere. Perhaps a better way would be to modify the accessibility tools - StickyKeys etc. - to have vim be the universal text entry arrangement even for things like username text boxes, you ':wn' to get to the password field and then type 'i' to start entering a password. Much easier.
I find I don’t really miss the right alt key at all.
For example my xmodmap file, which also sets up meta/super and other overrides is
https://github.com/tekezo/Karabiner-Elements
I suspect you'd have to switch to something like Autohotkey for the Esc/Ctrl mapping.
Or there's always dual binding Caps Lock (tapped vs held) as tetraodonpuffer suggested but I've never been able to get used to that.
Oh, and on Mac CTRL+ALT+5 if I remember correctly.
Some alt based sequences are really useful:
* alt + e, a : leave current parenthesis and continue inserting (eg, while typing parameters for a function)
* alt + shift + a : insert mode at the end of current line
* alt + shift + i : insert mode at the beginning of current line, with indentation
* alt + p, a : paste before current position, and continue inserting
Maybe there's a modifier key with a similar behavior on macosx?
Why does that work? Is it because Alt + some_key combos generate an escape sequence starting with the actual ESC character? I know that happens with many function key combos, don't remember or not sure about Alt combos.
Ha, I probably found it by some similar way, maybe in vim or maybe in DOS / Windows / Linux at the command prompt or in some curses or terminal application.
Is that different from just Shift-a or capital A, which puts you into append mode at the end of the current line (no matter where you are on the line when you press it)?
https://en.wikipedia.org/wiki/Esc_key
I find it easier to stick to the laptop keyboard and trackpad even when at a desk plugged into a big monitor.
Everytime I try to switch to a mechanical keyboard and mouse my wrists start hurting. I guess this would go if I got used to the position but then what would happen when I have to use the laptop keyboard?
(So far I’ve tried an IBM model-m and a Pok3r keyboard).
Don't worry about switching back to the laptop keyboard on the go. You won't be less productive, you will just enjoy it less :)
exit
quit
exit()
ctrlC
ctrlx
stop
please exit
help exit
I ask because the other day I saw a friend of mine legitimately get stuck inside vim because he coundn't type ":". The keyboard language was set to the wrong language and none of the keys would output ":" when pressed. We had to reboot the machine and find a different keyboard.
I can better describe it like this:
:x is a shortcut for telling vi/vim: save the file if not saved after last change, then quit (in either case, whether a save was needed and done just now or not) - IIRC.
Also, as others said, Shift-ZZ (when Caps Lock is off), also saves and quits (and saves one keystroke over :x - because you have to hit Enter after :x, but not after Shift-ZZ :) It is also (slightly) faster to type, since the (left) Shift key is just next to the Z key (at least on some keyboards, like mine at present).
As an emacs user, I just love seeing vim-users discover the utility of an always-there, complete text-editing environment. If only theirs had an extension language worth its salt …
And vim launches in milliseconds, so no need to keep it running in the background as some text editing server.
Most monitors have enough real estate to where alt-tabbing is not only unecessary, but counter productive and distracting. Its like using your foot to operate the gas pedal 100% of the time instead of using cruise control to drive hours in a straight line.
pbcopy on Mac brings back memories.
It is cool that apple has the ability to script like this though. It's pretty handy.
I use it with Atomic Chrome for Emacs, but it supports Vim, Sublime, and Atom as well.
I usually run an emacsclient inside tmux inside the hotkey window, with a scratch text-mode buffer active.
If I want to use emacs to work on some text from a non-emacs app, the steps are something like: select text, cmd-c, press hotkey (mine is option+space), ctrl-y, edit the text, select what I need, opt-w, press hotkey to switch back to the app, then cmd-v.
Since the hotkey window is running tmux, it's easy to create or switch to another tmux window and operate on the text with the help of pbpaste/pbcopy and good old pipe.
[0] https://en.wikipedia.org/wiki/ELinks
[1] https://en.wikipedia.org/wiki/Nvi
[0] http://invisible-island.net/lynx/lynx-develop.html
> There's an outstanding PR that does preciesly that
Just to be clear, I believe that PR will fill the newly-opened Vim buffer with text from the clipboard - not selected text.
The comment about rlwrap is especially handy.
(Edit: 300 not 900)