Vim: basic configurations


Configured in the .vimrc file.


  • Set the current directory as the working dir
    set autochdir
  • Spell check
    set spell spelllang=en_us
  • Use 4 spaces auto-indent
    set smartindent
    set tabstop=4
    set shiftwidth=4
    set expandtab
  • Show the ruler on status bar
    set ruler
  • Use Ctrl-v and Ctrl-c for copy and paste
    :inoremap <C-v> <ESC>"+pa
    :vnoremap <C-c> "+y
  • Set the width of line number as 7
    set numberwidth=7
    set number
  • Set space as the leader key
    let mapleader=" "
    nnoremap <SPACE> <Nop>
  • Use <leader>p to replace the selected text with the register without yanking it
    vnoremap <leader>p "_dP
  • Use <leader>d to delete the selected text without yanking it
    nnoremap <leader>d "_d
    vnoremap <leader>d "_d
  • Use <leader>w to toggle line wrapping
    nmap <leader>w :set nowrap!<CR>
  • Use <leader>r to toggle relative line number
    nmap <leader>r :set number relativenumber!<CR>
  • Use <leader>i to toggle indent lines
    nmap <leader>i :IndentLinesToggle<CR>

Back to Memo