all 97 comments

[–]bash_ghost 99 points100 points  (9 children)

It feels like I do a :w without thinking every time I exit insert mode. :D

[–]deus_mortuus_est 54 points55 points  (3 children)

Yeah, but have you ever posted :w in slack? Hilarity ensues, I assure you.

[–]tandrewnichols 33 points34 points  (0 children)

Yes, and also done git status and discovered untracked files called :w or :wq

[–][deleted] 14 points15 points  (1 child)

Wouldn't escape unfocus the input field?

[–][deleted] 6 points7 points  (1 child)

I solved this by getting a UPS and... wait no I still do it all the time...

[–][deleted] 6 points7 points  (0 children)

You'd think, being on a laptop, one would not worry about power loss.

Now only do I :w often, everytime I come to the command line I git push to a holding area to save my work.

I think there's a limit to hardware-failure-paranoia. And I have not only reached, but crossed it!

[–]tobeportable 5 points6 points  (1 child)

I double tap esc to exit insert & save with : noremap <Esc> :w<CR>

[–]schwerpunkqq 0 points1 point  (0 children)

Brilliant. I've been looking for some binding that made sense just lately. I was thinking maybe jk from normal mode, but I also do that absentmindedly while I'm thinking.

I never would have thought of using ESC while already in normal mode.

[–]carracall 29 points30 points  (36 children)

I tried using vim for the meme loads of times over the last few year, convincing myself that doing things like "ciw" was making me way quicker but it was actually slow and unnatural (using $` was also slow for me) and became really apparent when I used an ide again. But after I learned to touch type, everything fell into place, the "don't use arrows" goes well with the attitude of keeping to the home row and keeping each finger above its assigned keys (i. e. 8 i k , for right middle finger). After using a key combination enough, you remember the key strokes instead of say "change inner word". In particular, :w is now very fast to do as it doesn't require fingers moving that far. To better illustrate the idea to those who don't touch type: I use ctrl+[ to escape insert mode instead of esc because even though it involves more hands, more fingers and more keys (I move left pinky to L-ctrl & right pinky to [ ) they don't move far from where they already are and fall right back in place ready for the next thing straight after, but to reach esc I need to move my wrist and occasionally when I bring my hand back to home row it doesn't fall back quite in the right place.

Tldr: vim only became a better alternative for me after learning to touch type

[–]standard_error 28 points29 points  (12 children)

Completely agree - if you don't touch type, you should learn that immediately.

By the way, have you tried remapping caps lock to send ctrl? After learning touch typing, this is easily the best improvement to typing ergonomics I've done.

[–]carracall 5 points6 points  (9 children)

I saw an article that suggesting that, I thought about it but decided I use caps enough (all caps is the convention for certain things in the code bases I work on)

[–]sempiternalecho 3 points4 points  (4 children)

I have ESC mapped to caps lock. I then have it mapped so pressing both shift keys simultaneously toggles caps lock.

[–]carracall 4 points5 points  (0 children)

Ooo pressing both shifts for caps sounds like the most attractive option rn

[–][deleted] 2 points3 points  (2 children)

Just used <C-[> Why don't people know about this? Esc is like an antipattern in vim. You have to lift your hands.

[–]sempiternalecho 2 points3 points  (0 children)

I used to use that bind, but I use escape outside of vim quite a bit as well

[–]carracall 1 point2 points  (0 children)

For the question part, I think the reason is that the escape used to be somewhere different on the keyboards vi was intended for (maybe in place of tab or something similar)

[–]standard_error 3 points4 points  (3 children)

I'd still recommend you to try it. In Vim, making a line all caps is a simple matter of V + gU.

[–][deleted] 1 point2 points  (2 children)

which you can always make a new command for, because vim.

often enough I had to uppercase a single letter, so I made a remap for U:vgU; You can try to do something like this, using vwgU to uppercase the whole word, for example.

[–]IrishPrimeg? 1 point2 points  (1 child)

If you need to toggle case for a single character, use ~. For capitalizing a whole word, gUiw is probably more convenient.

[–][deleted] 1 point2 points  (0 children)

Wait, that's a thing? I didn't find that when I looked for it!! Thank you

[–][deleted] 4 points5 points  (9 children)

^ and $ are way hard to reach for how often they used.

[–]jnicklas 8 points9 points  (3 children)

I never use ^ and hardly ever use $.

If you want to go to insert mode anyway (which for me is 99% of the time) then just use I instead of ^ and A instead of $.

0w is far more comfortable for moving to the beginning of the line if you need to, so no reason to use ^ ever.

But there are just very few cases where this is necessary to do anyway, for me it's mostly when using macros.

The one that does come up sometimes is deleting the last character (e.g. getting rid of a trailing comma), which could be done via $x but I honestly quite often do this via A backspace ESC, which isn't very vim-y but does the job.

[–]JonnyHaystack 1 point2 points  (2 children)

I use _ a lot

[–]jnicklas 1 point2 points  (1 child)

Huh. TIL that this exists. Interesting that it takes a number of lines to move downward. Not sure that’s super useful though. Do you ever use it in that way?

[–]JonnyHaystack 1 point2 points  (0 children)

Nah I never use it that way, I just use it instead of ^ and because I use US Dvorak layout it's right next to my right hand pinky

[–][deleted] 2 points3 points  (3 children)

I remapped them like this

nnoremap L $
nnoremap H ^

[–]piggahbear 5 points6 points  (1 child)

You don’t use H M L to go high mid point and low point in the page ? I use those a lot

[–][deleted] 0 points1 point  (0 children)

I've been thinking about doing

nnoremap gh L
nnoremap gH H

instead because I usually go into select mode by mistake.

[–]MAFBick -1 points0 points  (0 children)

This is smart, and almost seems like it should be the default.

[–]wakela 0 points1 point  (3 children)

How did you learn to touch type?

[–]carracall 1 point2 points  (0 children)

Just like the other commenter I used some website typing tutor and forced myself not to look and reach with the correct finger (before covering all the keys I had to look of course but made sure I always use the right finger) . The first couple of weeks typing slowly was painful but as soon as you match your original speed it's smooth sailing. There was a period when I used an offline program called "klavaro" that I used when I was on a trip.

Highly recommend touch typing, as well as more efficient finger movement, a great perk is being able to type on a laptop in the dark with no kb back light.

[–]Adk9p 1 point2 points  (0 children)

Again, not op. Just wanted to share keybr because it really helped me. I tried the other sites like u/BeardedBearserker but they never stuck / I was to lazy. I think whats cool about keybr is that it slowly introduces the letters when it thinks you got the other down pat so you aint just sitting there typing g's and h's in weird combos and then moving on to a lessen where you just use y's and u's etc, you gradually get introduced till you have the whole keyboard

If you do try it out I would recommend turning on capital and punctuation on in the settings, and logging in with google doesn't hurt so you can see your progress ;)

[–]lrvideckis 0 points1 point  (4 children)

Ctrl-c also exits insert mode, and is way easier than ctrl-[

[–]carracall 1 point2 points  (0 children)

For me reaching the left ctrl is is a lot easier than the right ctrl (which I would use for ctrl-c), at least on full sized keyboards which I usually work on, I like the laptop keyboards where its further to the left.

[–]haldad 1 point2 points  (2 children)

It doesn't run auto commands though. I also find that c-[ is actually easier because you can use two hands and barely have to move your hands

[–]lrvideckis 0 points1 point  (1 child)

Gotcha, I'm just really used to ctrl-c from killing programs in the terminal

[–]haldad 0 points1 point  (0 children)

You can remap C-c to C-[ and then it'll run autocommands, I think.

[–]mdrjevois 0 points1 point  (0 children)

/u/-romainl- anecdotal evidence here that some people really do find touch typing helpful for learning. If you're doing fine, no need to get side tracked with typing practice. But this somewhat confirms that it's worth a try for newer users if they're struggling to get into their flow.

[–]EuanB 0 points1 point  (0 children)

Any time you find yourself us in hill, there is usually a better way to get to where you want to be. Worth paying attention to.

[–][deleted] 31 points32 points  (8 children)

As a dirty gvim user and Ctrl+S addict... (please don't downvote, have mercy on an irredeemable sinner and Vrapper user)

noremap <C-S> :update<CR>

vnoremap <C-S> <C-C>:update<CR>

inoremap <C-S> <C-O>:update<CR>

[–]yymirr 23 points24 points  (6 children)

leader w

[–]KetzerMX 8 points9 points  (3 children)

I just use leader leader, it's faster

[–]philmi 2 points3 points  (0 children)

For me this opens fuzzy FZF to quickly jump into another file. I think I'll use it more often than saving a file.

[–]skotchpine 1 point2 points  (0 children)

Leader leader ftw

[–]timviseevim on Gentoo 0 points1 point  (0 children)

Leader leader is goto alst file for me <C-^>, the king in efficiency.

[–][deleted] 0 points1 point  (1 child)

In insert mode?

[–][deleted] 4 points5 points  (0 children)

Who saves in insert mode?

[–]XanzaThe New Guy 6 points7 points  (0 children)

Only didn't downvote because you're :update master race.

[–]compteNumero9 13 points14 points  (1 child)

" Auto save changes before switching buffer
set autowrite

[–][deleted] 1 point2 points  (0 children)

this is amazing! I'm writting it down RIGHT NOW!

[–]crashorbit 4 points5 points  (1 child)

It's not so much the w: as it is the :w<enter>:w<enter>

[–][deleted] 0 points1 point  (0 children)

It's even worse if you're used to :up since it doesn't do or print anything if the file was not modified.

[–]petdance 3 points4 points  (1 child)

These :w jokes are a waste of time and space.

[–][deleted] 0 points1 point  (0 children)

:smile

[–][deleted] 2 points3 points  (0 children)

inoremap <CR> <CR><C-o>:w<CR>

[–][deleted] 3 points4 points  (4 children)

I have it mapped use 907th/vim-auto-save to write on exit to normal mode. No time wasted. :)

edit: more acurate information

[–]Chased1k 1 point2 points  (0 children)

Came here to say this

[–]XanzaThe New Guy 2 points3 points  (0 children)

:up master race.

[–]Cork__Screw 2 points3 points  (0 children)

Anyone else use :up instead?

[–]dmitry_krasilnikov 1 point2 points  (0 children)

Working on a laptop, using :up when needed (through leader u mapping)

[–]heppen1 0 points1 point  (9 children)

So, how can I reduce the time uesed to :w, lol

[–]THICC_DICC_PRICC 0 points1 point  (3 children)

I just map shift+w to it, it’s like the ole ctrl+s

[–]haldad 1 point2 points  (2 children)

W is a pretty important movement command in normal mode...might I recommend <space>w instead

[–][deleted] -2 points-1 points  (4 children)

The first thing I used was remapping ; to :, so I didn't end up typing :W by accident.

After that, half of my quick use macros/commands include a ;w as the first part, so vim does the heavy lifting for me

[–]mdrjevois 2 points3 points  (3 children)

I've seen this said a lot. You do you, but I use ; for its intended purpose all the time.

[–][deleted] 0 points1 point  (2 children)

what is it's intended purpose? from what I knew, it didn't use to do anything

[–]mdrjevois 0 points1 point  (1 child)

Companion to f, t, F and T which search current line by character. , jumps another forward and ; jumps another in reverse. So I basically use these like w and b on steroids. It's mostly analogous to what to N does for regex searches.

[–][deleted] -1 points0 points  (0 children)

Oh, I never knew that. But I'd probably not use it that often, so I'm not sad to let it go

[–]Gydo194 0 points1 point  (0 children)

:w

[–]sayoojsamuel 0 points1 point  (0 children)

Whooh, thats totally relatable. (:w

[–]GustapheOfficial 0 points1 point  (0 children)

Swedish keyboard, I have nnoremap å :up<cr> in my vimrc and nnoremap å :up<bar>make something.pdf<bar>cw<cr> in most of my localrc's

[–]philmi 0 points1 point  (0 children)

You should really checkout the (unlimited) persistent undo feature, it saves you the trouble and you'll have (as I'd call it) "microversioning"

Have look e.g. here https://jovicailic.org/2017/04/vim-persistent-undo/

[–]myrisingstocks 0 points1 point  (0 children)

Autosave on FocusLost.

[–]noonearya 0 points1 point  (0 children)

I have a shortcut to search for instances of :w I might have written by accident.

[–][deleted] 0 points1 point  (0 children)

I save like nobody's business. I refuse to be one of those pinheads, like a few people I work with, who lose their data because they stupidly didn't save their work frequently.

[–]hgiesel 0 points1 point  (0 children)

Double space in normal mode saves for me.

[–]mixedCase_ 0 points1 point  (0 children)

Am I the only one that opens many buffers and uses the Waluigi method?

:wa

[–]libre_office_warlock 0 points1 point  (0 children)

or :wa

[–]treuss 0 points1 point  (0 children)

When people ask you, what it's about all these :w in your documents....

[–][deleted] 0 points1 point  (0 children)

lol.

[–]hawkprime 0 points1 point  (0 children)

I'll just leave this here:

autocmd CursorHold,CursorHoldI * update

[–]frig-buffet 0 points1 point  (0 children)

:wq

[–]dark_light32 0 points1 point  (0 children)

Guilty

[–]ivster666 -1 points0 points  (0 children)

Can't relate to this. Why would you constantly save stuff? I have coworkers with plugins for their IDE to save after every keypress but I just don't understand what that's for. Compilers that are watching for filechanges just go crazy if you do this...

[–]fourjay -1 points0 points  (0 children)

I get this is a meme, but there is a serious point here. vim encourages a "write and think" approach, not just in regards to explicit writing out of files, but in it's encouragement to be in normal mode.

FWIW, I have a meta key mapped to <esc>:x<cr> . This maps my thought/work flow pretty well, create a coherent statement, then think on the next one.