by fokinsean · 5y ago · 0 comments
I've been using vim as my daily driver via the intellij plugin for a few years. I mostly just navigate and never do anything complicated, it gets the job done.
For example I mostly use w, d, o, hjkl, y, p, w, b, t and recently discovered the `c+i` combo which is awesome.
But I feel like there's still a side of vim I haven't conquered.
Any tips?
The idea was that by forcing myself to write about Vim consistently, I would learn and absorb more and boy has it worked.
Never can seem to get vim selections and deletions right though, because it deletes the character after the cursor as well so the mouse comes clutch there.
- Playing some vimgolf and seeing what neat tricks people used. This is where I learned about “.”
- Going into the deep-end of just using vim (or just vim in IntelliJ without the mouse) will make you notice all the issues that make you unproductive with only vim e.g getting around with only hjkl is really slow so you might investigate other ways to navigate or deleting a word always involves getting to the end of the word and using lots of backspace may make you wonder if there are more efficient ways to do the same thing
- if you decide not to go into the deep-end, just being more picky about how much you’re spamming certain keys may help you gradually incorporate new commands into your flow
I would recommend using vim in the console without the mouse because your editor will always give you a way out of learning.
Every time you get stuck or feel inefficient, do a web search and learn one thing.
Learn to use and love :help.
I think a few plugins can really improve the experience such as coc, ultisnips, vim-surround. Also set some settings like relative number and highlighted yank.
Some other stuff to investigate... zz and scrolling, folding, G, macros, registers, f, $ and ^ and 0, %, }, ctrl-o, ctrl-] and ctags, formatting gq = etc
Edit: also remembered enable set hidden and use buffers and splits (eg :sbp). Use markers. Also I like the fzf plugin for quickly opening files etc.
Start with `:h user-manual` and go from there!
In addition to these, I've found (my personal experience, ymmv):
1) f/F to jump to next/previous occurrence of character to help navigating within a line very effectively, in conjunction with ; and , to jump around within these occurences. 2) use relative line numbers in conjunction with your hjkl.
E.g. jump up 5 lines and go to the start of a bracket is '5kf('. If it's a nested bracket you want, then '5kf(;'.
1. how to delete text inside a double quote and go to insert mode? - c+i+"
2. how to move to the end of line? - $
3. how to delete everything before "x" character and go insert mode" - c+t+x
...
EDIT: updated mistakes.
ciw will change inner word, ci" will change inside quotes
> 2. how to move to the end of line? - "g_"
$ is generally used as the noun object to represent "end of the current line"
> 3. how to delete everything before "x" character" - "ctx"
dtx would delete everything before the next x. ctx would delete and then put you in insert mode :)