Craft By Zen

📖 4 min read

🔖 vim   learning

vim

Initial Setup

I got into vim from a co-worker. I thought it’s that clunky text editor in your terminal you must use when you have ssh into the linux server. However, I’ve grown to understand vim is much more than a text editor. It can also be an IDE.

When I first used vim, it just looked plain an boring. The black screen with hard to understand shortcuts. There weren’t any line numbers. I didn’t even know how to exit the damn program for a good 5 minutes.

Then I started figuring it out slowly. Vim has different modes. Vim can do macros. Vim can find things with the same grep commands. And it’s quite expandable with the limitless plugins. Vim is an endless rabbithole where you will get sucked in hours just setting it up. But it’s your customization. And that’s the beauty of vim.

Best advice - configure vim, and for that matter dotfiles, on your own. Don’t blindly copy and paste configurations, because you’ll never understand them all.

Quoted from Nick Nisi

Change the meaning of the keys in each mode of operation

  • Normal mode - navigate the structure of the file
  • Insert Mode - editing the file
  • Visual mode - highlighting portions of the file to manipulate at once
  • Ex mode - command mode

Line Numbers

Where are my line numbers? Simply type the following.

:set number

To remove the numbers, you can use this command.

:set nonumber

Configuration

If you’re sick and tired of setting everything up every time you boot up vim, simply place the configuration in your configuration file. You can find the configuration file at this location. ~/.vimrc

Here’s a truncated version of my general settings.

syntax enable     " Enable syntax highlighting
set tabstop=2     " set the tab stop at 2 spaces
set shiftwidth=2  " set the shift width by 2 spaces
set noexpandtab   " do not expand tab
set number        " show line numbers

For all of my settings, please view my dotfiles.

Useful Shortcuts

All of the shortcuts can be found on the Vim Wiki Website

Word Manipulation

Yanking Words

Line Manipulation

Moving lines

Vim as a Language

Operations and thing you want to do the operation to. :

Editing

Many times, you’ll want to know how to copy and paste.

Colon Commands

Plugins

Vim, like other text editors, has an ecosystem of plugins.

Packages

Colorize

I’m currently using Monokai, mainly because it was a default I had with Ruby on sublime. I set it up using vim-monokai, which I actually want to go back and figure out how to hook it up with vundle and have it linked to the repo.

I want to figure out how to do this better, so I placed a todo with the wiki from the vim wikia.

You can change the color scheme within normal mode. Heres how.

:colorscheme <name>
" short version
:colo <name>
" autocomplete
:colo <press tab>

Macros

Repeat last change

. command repeats the last change made in normal mode. It’s like oh my gosh amaze balls.

Recording

q{register} (do the things) q

Registers

WIP

More Research to go through

Helpful Resources


Written by Jeremy Wong and published on .