Please share your favourite Vim tips here
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
*
search for word under the cursor.
Follow https://www.vimgolf.com/
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
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
I am guilty of not using them 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).
-
%
for jumping from an opening round, curly or angular bracket to the corresponding closing bracket and vice versa. Sadly, it doesn’t work withdo
s andend
s. -
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 yoursettings.json
,
"editor.lineNumbers": "relative",
Could this Ruby plugin be used for that?
: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 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 … Should do the same thing as :5 which I didn’t know about! Thanks.
Oh it works now - wonder what I was doing last time Thanks
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.
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
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!
Do you have to set anything up for those Mafinar? They don’t do anything for me other than output jj
or ;
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
Actually you’ve given me an idea for a new thread
I used to have it too, but I have type issues typing lol jk
in my code comments.