DEV Community

Cover image for Accelerated Vim-Provement

Accelerated Vim-Provement

Ryan Palo on October 26, 2017

I'm currently working on practicing and learning to use Vim as an editor. After a few sorry attempts to learn it quickly by sitting down and doing...
Collapse
 
papey profile image
Jean Michel Functional Programming • Edited

This is also the setup I used. No arrow keys. After 6 years without it I used hjkl for my configs (zsh, xmonad, web browers, weechat etc...).

If you want to reduce finger travel here is another tip :

inoremap jj <esc>

Remap jj to is the second best thing i did in my vim life.

Collapse
 
maestromac profile image
Mac Siri

Can you tell me how you are using hjkl in terminal and on other applications?

Collapse
 
rpalo profile image
Ryan Palo

I found this post that has some good resources. Also, they link to their fork of oh-my-zsh that makes allowances for vi-mode while still letting you do history searching and stuff. Looks pretty legit, I'll have to check it out when I get home.

Thread Thread
 
maestromac profile image
Mac Siri

Thanks for that! I'll check that out.

Collapse
 
papey profile image
Jean Michel Functional Programming • Edited

I used personal keybinds, inspired by vim in my xmonad config and weechat config. For web browsers i recommend Vimium (For Firefox and Chrome/Chromium). For zsh there is a vim plugin available. A lot terminal apps works well out of the box with hjkl, so I always give it a try.

Collapse
 
eljayadobe profile image
Eljay-Adobe

I map CAPSLOCK to ESC. Not in Vim, but in the OS.

CAPSLOCK is a worthless key in a prime real estate location.

Collapse
 
maxdevjs profile image
maxdevjs

I do not remap CAPSLOCK only because I like to have this module active in polybar

long live to the capslock

Collapse
 
rossijonas profile image
Jonas B. R. • Edited

Well here is more tips on learning Vim, I hope it helps anyone:

First of all hit you terminal and type :vimtutor ...this is the first step! Take 30mins to 1 hr to practice relaxed, no rush! 👨‍💻

There's a nice book called Mastering Vim Quickly by Jovica Ilic, that is a pretty good one, and If you can't invest right now, you can subscribe to get chapters for free and newsletter tips.

vimcasts.org is a free good resource with videos and articles.

I started to write quick tips and tutorials for Vim beginners too, to help them deal with specific configs and get excited with tricks you can use.

You can check it on medium.com/vim-drops!

Duckduckgo.com has a cheatsheet embedded on the search bar... you can type vim cheatsheet and you get:
cheatsheet

Cheers!✌️👨‍💻⌨️👩‍💻✌️

Collapse
 
maestromac profile image
Mac Siri

This is a nice tip! What stopped me from doing this in the past is that I still rely on arrow keys when I'm in command-line mode (when you press : or /). My personal tip is to learn about leader keys and really make use of it 😃.

Collapse
 
rpalo profile image
Ryan Palo

Cool! What are some of your most frequently used leader commands?

Collapse
 
maestromac profile image
Mac Siri

My most used are saving, quiting, and save&quit in below. Reducing keystrokes are always a plus!

let mapleader = ","
noremap <leader>w :w<cr>
noremap <leader>q :q<cr>
noremap <leader><Tab> :wq<cr>
noremap <leader>f :tab split<CR>:Ack ""<Left>
noremap <leader>F :tab split<CR>:Ack <C-r><C-w><CR>
noremap <leader>3 :NERDTreeToggle<CR>
Thread Thread
 
rpalo profile image
Ryan Palo

Awesome. I'll definitely have to do more leader-ing. Thanks!

Collapse
 
awkravchuk profile image
Andrew Kravchuk

Neat! Here's the snippet I've just made for Spacemacs (which is mostly like Vim, but, erm, is in fact Emacs) to do the same thing: gist.github.com/lockie/6d74aa5ca2c...
I'm thrilled to start using it though, even writing this snippet in Spacemacs with half of rules activated made my brain tingle :D

Collapse
 
stsewd profile image
Santos Gallegos

I think this method is the best for stop using the arrow keys 😅

vim

Seriously, taked me a while to stop using them, I did it in this way:

  • Always keep my fingers on the home row
  • Navigate a lot of text using h, j, k, l (:tutorial is a good place).
  • Whenever I wanted to read some text/code I opened it on vim.
  • Keep doing that till feels natural, but be careful, you will try to use hjkl on everything!
Collapse
 
eljayadobe profile image
Eljay-Adobe

I've been using Vim for about 20 years. Before that I used Emacs for 2 years.

After a particularly interesting "my editor is better than your editor" flamewar with a coworker, we made a deal: I'd use Vim for 6 months, and he'd use Emacs for 6 months.

At the end of the 6 months, he switched back to Vim, and I never went back to Emacs. (I'm not saying Vim is better than Emacs. I'm saying that Vim is better for me.)

So for anyone thinking of using Vim my response is simply, "It's too late for me! Save yourself!" That's a "ha-ha only serious... well, only slightly serious."

Vim let's me become one with the keyboard. The editor gets out of the way. My fingers know it tacitly. I never have to reach for the mouse.

Bill Joy, the creator of vi, said that vi was made in the day of 300 baud modems and every character of very limited bandwidth was precious. These days, we have gigabit internet connections. The reason that vi is the way it is is no longer is a factor.

Yet I still use Vim, every day. I also use Visual Studio and Xcode... but when I want to do serious coding* I hop over to Vim.

* which is in C++... another "It's too late for me! Save yourself!"

Collapse
 
papey profile image
Jean Michel Functional Programming

Visual Studio Code vim plugin is awesome ! Even if I like VSCode, I can't get away from my neovim config and all the plugins I have.

Collapse
 
niorad profile image
Antonio Radovcic

The biggest eye-opener for me was embracing the difference between Tabs and Buffers.

joshldavis.com/2014/04/05/vim-tab-...

Coming from UI-Based editors like Sublime, learning the difference was an important step in understanding Vim (and also Emacs, similar principles).

Also, a more general tip for people considering Vim: Learn it anyways. The skillset you build by learning modular editing can be applied in any major editor/IDE via plugins.

Collapse
 
rpalo profile image
Ryan Palo

Cool, thanks for the tips! I’ll give that post a look.

Collapse
 
voyeg3r profile image
Sérgio Araújo

Talking about movements recently I discovered g_ to jump to the last non-blank char in the line and _ to jump to the first non-blank.

I also became amazed, long time ago with gf gi and gv

Collapse
 
andy profile image
Andy Zhao (he/him)

Obligatory @maestromac mention