Your Vim Tips!

Please share your favourite Vim tips here :nerd_face:

4 Likes

Vim search from bottom

I use Vim when remotely connected to servers - I often need to look through the log files and a great way to search from the bottom up is:

G (Shift + g) to go to the bottom
$ to go to the end of the line
? to start a search from the bottom up
search_term - whatever you want to search for
n for next item
N for previous

For example:

G $ tag

:+1:

3 Likes

Corresponding tweet for this thread:

Share link for this tweet.


Related portals:

1 Like

* search for word under the cursor.

Follow https://www.vimgolf.com/ :slight_smile:

2 Likes

Nice one Miki that’s new to me!

Here’s another:

To go to a specific line simply type : the line number, then enter. EG:

: 10 Enter

1 Like

My tip is to actually use HJKL. No end of people I know continue to use arrow keys!!! Vim puts them on your home row for very good reason—so that you don’t have to keep moving away from your home ro.w

1 Like

I am guilty of not using them :speak_no_evil: but this is part of the reason I want to get a 40% Ortho - because it will force me to use things like that (and also to fully embrace touch typing).

1 Like
  • % for jumping from an opening round, curly or angular bracket to the corresponding closing bracket and vice versa. Sadly, it doesn’t work with dos and ends.

  • Turning relative line numbers on, makes jumping to a specific line easier.
    For Vim read this post.
    For setting relative line numbers inside VSCode, add the following to your settings.json,
    "editor.lineNumbers": "relative",

2 Likes

Could this Ruby plugin be used for that?

https://www.vim.org/scripts/script.php?script_id=290

1 Like

: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.

2 Likes

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

Nice!

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>
2 Likes

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