Vote Charlie!

Distracted learning Vim

Posted at age 29.
Edited .

I spent some time today reading Vim documentation and a handful of blog posts. I learned the extreme basics of Vim many years ago, but I have not graduated much past cut-paste and search-replace until this year. In my mission to memorize more things I never bothered to for lack of a process, I added many common Vim commands to my Anki decks. Since those flashcards have been coming into my rotation, I realized now is the time to make a concerted effort fixing the unclear cards and inconsistencies that are a result of my not understanding Vim. I had been gradually making fixes but avoiding spending much time… priorities.

I almost bought the Kindle version of Learning the vi and Vim Editors, but decided to wait till I am actually about to read it. I tend to buy books immediately, which obviously does not make much sense when they are instantly downloadable. Sometimes I justify it by wanting to support the authors. I am good at rationalizing.

A StackOverflow question mentioned the blog post Coming Home to Vim by Steve Losh. I like his blog’s simple design, and I was thinking about simplifying mine while reading his post. His introduction was pretty good and relatable to my situation. His discussion of the “language” framework for thinking about Vim was not totally new to me but still made me think more about restructuring my flashcards in that way. I was already struggling with tradeoffs between having cards for samples of specific combinations of commands versus having a single card of the most basic form of a command, such as deleting. Part of my struggle is not yet knowing exactly where commands can take a number or other modifier or how they can be combined. That’s why I decided to learn more now, before spending too much time redoing the flashcards.

Once I got to Losh’s suggestions for a .vimrc file, I started thinking him and I are not so aligned afterall. Granted I have not yet read the documentation for all of his suggestions, but overall they sound a bit unnecessary or dangerous. Here are a few examples, mostly for my reference, so I can see later if I still agree or if I am being naïve:

  • set nocompatible is implied by existence of a .vimrc file according to the docs. Not a big deal to list it just in case, but I am listing this here because Losh listed it as an “absolutely must have”.
  • I won’t be using the tabs to spaces settings. Understandable, but maybe we aren’t a match…
  • I initially thought set relativenumber was dumb as it would screw up ability to use ranges in commands, but he claims this is easier with the relative numbers. I assume there is more to range syntax than I am aware of right now.
  • He suggests using set ignorecase and set smartcase to make searching smarter and using set gdefault to make searches global automatically. The former pair seems to reduce functionality (How to search for only lower case of a string that is all lower case? Maybe I works for forcing case sensitivity?) and the latter seems presumptuous and confusing. I don’t want s/OLD/NEW/g to not be global! With his way, g gets reversed but I does not and gets required? I think I will stick with tacking on an i for case insensitivity and g for global, as in every other PCRE context.
  • He seems to use text wrapping (set wrap) and then want motion to apply to the wrapped lines individually (nnoremap j gj and nnoremap k gk). I’m not sure how I feel about that. I tend not to use wrapping.
  • nnoremap ; : to enter commands like :wq as ;wq instead? Sure, it saves a keystroke, but I’d rather stick with the visually pleasing syntax.
  • au FocusLost * :wa to automatically save seems dangerous. What if I am editing a configuration file on a production server? Well, I guess I should fix my deployment process in that case anyway…

There’s a lot I need to learn before I can properly evaluate most of the suggestions. The above was enough to stop me from simply copying all his suggestions to my .vimrc file, though. As my former coworker David Phillips always said, make sure you completely understand what you are doing before you do it!

Update

Oh, God, I started peaking at plugins. I’ve added a few but am resolving to not learn them till I prove I need them. I did review the docs for all the config settings suggested in the above mentioned blog post and put together my Vim configuration, or a start!

Update 2, 10 hours later

Got sucked into researching Vim commands. Enjoyed reading Why, oh WHY, do those #?@! nutheads use vi? by Jon Beltran de Heredia and Why I use Vim by Pascal Precht, especially his depiction of the learning curve. And Why Atom Can’t Replace Vim: Learning the lesson of vi.

Update 3, 10 days later

I have yet to extensively use Vim, but I memorized a large number of commands thanks to Anki. I will start actually practicing tonight and tomorrow, while also practicing typing in Dvorak!

exiting-vim.png

exiting-vim.png

Join the movement!

Show your support by signing up to be among the lucky few notified when I manage to blog. This could be as often as once a day or as infrequently as yearly!

Help get me elected by purchasing products mentioned in this entry!

blog comments powered by Disqus