sourpit /index

Getting started with Vim

For first starter you need to know the basic mappings for it. I'm only covering QWERTY keyboard, because that's the only thing I got in hand. The trick to get better in Vim is just by using it daily.

Movement

Mode

Vim has mode for doing specific task like moving through text is called Normal Mode, Insert Mode for typing or editing text, Visual Mode to high light text that you can do copy or edit with it. These are mappings for in Normal Mode

Word Movement

Editing

These works in Insert Mode

Macros

Makes repetitive task much simpler. To start it press q with whatever alphabet you like in Normal Mode and then do the first task then close it with q. By pressing @ + whatever alphabet you chose Vim will reply the movement or edit you made. With the macro setup, you can repeat it with adding numbers before the macro, e.g 10@u this will repeat macro that I recorded in u 10 times.

Config

These are basic option that Vim user always use according to some stackoverflow's user.

      
" number the lines.
set number

" turn on syntax hightlighting.
set syntax=on
        
" show auto complete menus.
set wildmenu

" Make wildmenu behave like bash completion. Finding commands are so easy now.
set wildmode=list:longest

" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile

" Enable filetype plugins
filetype plugin on
filetype indent on

" Set to auto read when a file is changed from the outside
set autoread

" Always show current position
set ruler

" Ignore case when searching
set ignorecase

" When searching try to be smart about cases 
set smartcase

" Highlight search results
set hlsearch

" Show matching brackets when text indicator is over them
set showmatch
      
    

And as for me, I like using space instead of tab

      
" Use spaces instead of tabs
set expandtab

" Be smart when using tabs ;)
set smarttab

" 1 tab == 2 spaces
set shiftwidth=2
set tabstop=2
      
    

Mapping Escape to different key

I mapped it to capslock. Some map it to jj or don't mapped it at all and just use the builtin bindings to escape Insert Mode like C-c