Your Vim Tips!

:set number (Show line numbers)
number , Shift +G (Jump to specific line)
dd delete line
dw delete word
yy - yank line , to insert while in insert mode (i), use Ctrl +R When you see " hit 0.
yaw - yank word…

oh and

:colorscheme {tab} available color schemes, you can download or make your own as well.


That doesn’t work for me :thinking: I usually just do this to jump to a specific line:


if you go into vim, and hit 5 for example and then shift+g it should go to line 5 :wink: … Should do the same thing as :5 which I didn’t know about! Thanks.

1 Like

Oh it works now - wonder what I was doing last time :see_no_evil: :rofl: Thanks :blush:

1 Like

It will work in Vim, but won’t work in VSCode with the most famous Vim emulation plugin.
There is another Vim emulation plugin called Neo Vim which embeds Neovim’s instance as backend, so anything which works with Vim may work inside VSCode if Neo Vim plugin is installed and configured correctly.

1 Like

6 posts were split to a new topic: Off-topic posts from the Vim Tips thread

Insert mode: jj for escape
Normal mode: ; for :

Knowing text objects is <3

1 Like

That’s some good reasons for ‘Why VSCode’ and sounds like it would make a great blog post! I’m not sure if you do already, but if you don’t you should definitely consider blogging! :smiley:

Do you have to set anything up for those Mafinar? They don’t do anything for me other than output jj or ; :thinking:

1 Like

Yeah, you need to set it up yourself. I’m using jk instead but you set it up like:

inoremap jk <esc>

Ah yeah thanks @Hallski! It’s been a while since I edited my vimrc :see_no_evil:

Actually you’ve given me an idea for a new thread :nerd_face:

1 Like

I used to have it too, but I have type issues typing lol jk in my code comments.

1 Like

^[ is also a good alternative to escape key. I use it even on keyboards which have an escape key, because it’s nearer, and is available by default in Vim and Vim emulators.

Edit: I just practiced for a minute and jj/jk are more pleasant than ^[. I added settings for it to my vimrc as well as VSCode and I’m planning to use it instead of ^[ in future.

Thank you for this tip!

1 Like

I think I prefer jk too. I first heard it mentioned in the video here (well worth a watch):

Do you find there’s a trade-off? I stopped using things like jj in insert mode because then if I recall, my j key would hang while waiting for the next keypress. Does that match your experience? And then I think there were a few times when I actually wanted to write “jj”. (Nice quick variable name, for example.)

So now I’ve settled on Caps-Lock set to Control (Mac) but additionally Caps-Lock without a chord or simultaneous keypress I have set to return to normal. That seems to work alright.

Ha, in the goofyness of my dreams I’d like some kind of Vim toe ring, ah, or maybe a sensor on the nose-rests of my glasses so that I could just scrunch my sniffer and return to normal mode. Come to think of it, I believe we’ve found original itch that Elon Musk is desperate to scratch, leading to his infatuation the ultimate in Vim remappings: brain-computer interfaces. First principles or mere yak shaving? :face_with_monocle:

As for Vim tips, I’m not a power user (and mostly use Vim bindings outside of Vim) but I’ve been enjoying getting familiar with registers.

At the same time I’m advancing very slowly because I fear being (again) like a kid at the procrastination playground of editor configuration, playing with productivity tools instead of being productive…

1 Like

Just ran into my first ever issue with using jk when I tried to write Dijkstra in a comment :slight_smile:

1 Like

Haha… hopefully it’s not a word you’ll need to type often? :upside_down_face:

1 Like

:3,4co. copies lines 3 to 4, where . (full stop) means below your cursor


:3,4co14 pastes it below line 14. quite handy instead of manually yank


Ah that’s awesome @jaeyson!! I’ve not seen that one before but it’s super handy :sunglasses:

Here is one of them. When in insert mode pressing ctrl+r allows you to insert your register contents. For example Ctrl+r 0 allows you to paste recently yanked text. Also "0 register holds only yanked text and not deleted texts. So you can dd all those blank lines and still be able to paste the copied text.


Helpful tip. Also works with "0p in command mode.
No need to check the register, to see where the yanked text went after deleting those blank lines.
Thank you!

1 Like