cengizhan-konus-92187

把自己吃飯的工具紀錄一下啊! 我想vim & gcc在 mac & linux環境下安裝都不是問題, 所以就不特別提了.

這邊主要紀錄.vimrc裡面的設定以及我常用的plugin "AutoComplPop"

homebrew

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

environment

$ brew install python
$ brew linkapps python
$ brew install macvim --with-python --override-system-vim
$ brew linkapps macvim

install cmake

$ brew install cmake

vimrc

基本常用的vimrc檔如下

  • vimrc path: "/usr/share/vim"
syntax on         " 語法上色顯示
set t_Co=256

set expandtab     " 用 space 代替 tab
set shiftwidth=4  " 設定縮排寬度 = 4
set tabstop=4     " tab 的字元數
set softtabstop=4
set ic            " 設定搜尋忽略大小寫
set ru            " 第幾行第幾個字
set ai            " 自動縮排
set enc=utf8      " 文字編碼加入 utf8
set history=700
set cursorline
set smartindent   " 設定 smartindent
set confirm       " 操作過程有衝突時,以明確的文字來詢問
set pastetoggle=<F2>

let &t_SI .= "\<Esc>[?2004h"
let &t_EI .= "\<Esc>[?2004l"

inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()

function! XTermPasteBegin()
    set pastetoggle=<Esc>[201~
    set paste
    return ""
endfunction

Autocomplpop

到這邊下載 autocomplpop plugin

http://www.vim.org/scripts/script.php?script_id=1879

下載完解壓縮到 ~/.vim 就可以了

unzip -d ~/.vim vim-autocomplpop.zip

VIM 常用指令

instructions	Explanation
gg	          移到第一行
G	           移到最後一行
0	           移動到該行最前面
$	           移動到該行最後面
/(string)	   向下搜尋字串
?(string)	   向上搜尋字串
dd	          刪除游標行
n	           跳到下一個符合的字串(next)
N	           跳到上一個符合的字串
[Ctrl]-R	    重做指令

Install YouCompleteMe

on mac

# use Vundle
$ git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
$ brew install CMake

on Ubuntu

# use Vundle
$ git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
$ sudo apt-get install build-essential cmake

modify vimrc

Add this snippet at the begin of the file

set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
    " alternatively, pass a path where Vundle should install plugins
    "let path = '~/some/path/here'
    "call vundle#rc(path)

    " let Vundle manage Vundle, required
    Plugin 'gmarik/vundle'

    Plugin 'Valloric/YouCompleteMe'

Install Plugin and run script

$ vim +PluginInstall +qall

# move to YouCompleteMe folder
$ cd ~/.vim/bundle/YouCompleteMe
# run install.sh with C family
$ ./install.sh --clang-completer