Cấu hình Vim trên Ubuntu 14.04

Cách cài đặt nhanh:

Mở terminal và thực thi lệnh sau:

wget -qO- https://raw.github.com/ma6174/vim/master/setup.sh | sh -x

Cấu hình thủ công

Sau khi thử nghiệm nhiều phương pháp không hiệu quả, tác giả tìm thấy cấu hình xuất sắc từ nguồn:

https://github.com/ma6174/vim

Phương án 1: Cấu hình cơ bản cho Python

" Cấu hình tab và định dạng
set tabstop=4
set softtabstop=4
set nu
set shiftwidth=4
set textwidth=100
set expandtab
set autoindent
set fileformat=unix

" Mã hóa UTF-8
set encoding=utf-8

" Bật đánh dấu cú pháp
let python_highlight_all=1
syntax on

" Tự động thụt lề
autocmd FileType python set autoindent
set backspace=indent,eol,start

set noswapfile

Phương án 2: Sử dụng Vundle quản lý plugin

  1. Cài đặt Vundle:

    git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
  2. Cấu hình plugin trong .vimrc:

    " Cấu hình Vundle
    set nocompatible
    filetype off
    
    set rtp+=~/.vim/bundle/Vundle.vim
    call vundle#begin()
    
    Plugin 'VundleVim/Vundle.vim'
    Plugin 'tpope/vim-fugitive'
    Plugin 'scrooloose/nerdtree'
    Plugin 'jistr/vim-nerdtree-tabs'
    Plugin 'kien/ctrlp.vim' 
    
    " Plugin cho Markdown
    Plugin 'isnowfy/python-vim-instant-markdown'
    Plugin 'jtratner/vim-flavored-markdown'
    Plugin 'suan/vim-instant-markdown'
    Plugin 'nelstrom/vim-markdown-preview'
    
    " Kiểm tra cú pháp Python
    Plugin 'nvie/vim-flake8'
    Plugin 'vim-scripts/Pydiction'
    Plugin 'vim-scripts/indentpython.vim'
    Plugin 'scrooloose/syntastic'
    
    " Tự động hoàn thành
    Plugin 'Valloric/YouCompleteMe'
    Plugin 'ervandew/supertab'
    
    " Gập code
    Plugin 'tmhedberg/SimpylFold'
    
    " Giao diện
    Plugin 'altercation/vim-colors-solarized'
    Plugin 'jnurmine/Zenburn'
    
    call vundle#end()
    filetype plugin indent on
    
    " Cấu hình riêng biệt
    let g:SimpylFold_docstring_preview = 1
    let g:ycm_autoclose_preview_window_after_completion=1
    let mapleader=" "
    map <leader>g  :YcmCompleter GoToDefinitionElseDeclaration<CR>
    

Cài đặt plugin

Mở Vim và chạy lệnh:

:PluginInstall

Tham khảo thêm

Thẻ: Vim vundle python Ubuntu

Đăng vào ngày 24 tháng 6 lúc 16:19