Purpose
本文主要為了記錄個人的日常使用軟件配置, 以在切換設備時根據(jù)本文快速配置自己習慣的配置, 所以不涉及任何的操作教程, 以下所有配置主要針對在Ubuntu上操作
Vim
安裝 vundle
# 先從 github 中下載 vundle 放到.vim目錄中
git clone http://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
# 接下來配置 vimrc 文件, 添加下列配置信息
filetype off
set rtp+=~/.vim/bundle/vundle
call vundle#rc()
Bundle 'gmarik/vundle'
filetype plugin indent on
" Below here to add the vundle what I want
# 配置好 vimrc 文件后保存退出, 重新打開 vim, 并在 vim 中執(zhí)行 ex 命令
BundleInstall
# vundle 常用命令
BundleList -列舉列表(也就是.vimrc)中配置的所有插件
BundleInstall -安裝列表中的全部插件
BundleInstall! -更新列表中的全部插件
BundleSearch foo -查找foo插件
BundleSearch! foo -刷新foo插件緩存
BundleClean -清除列表中沒有的插件
BundleClean! -清除列表中沒有的插件
最終配置
" All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by
" the call to :runtime you can find below. If you wish to change any of those
" settings, you should do it in this file (/etc/vim/vimrc), since debian.vim
" will be overwritten everytime an upgrade of the vim packages is performed.
" It is recommended to make changes after sourcing debian.vim since it alters
" the value of the 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim
" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
if has("syntax")
syntax on
endif
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark
" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
" au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"endif
" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"if has("autocmd")
" filetype plugin indent on
"endif
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
"set showcmd " Show (partial) command in status line.
"set showmatch " Show matching brackets.
"set ignorecase " Do case insensitive matching
"set smartcase " Do smart case matching
`代碼`"set incsearch " Incremental search
"set autowrite " Automatically save before commands like :next and :make
"set hidden " Hide buffers when they are abandoned
"set mouse=a " Enable mouse usage (all modes)
" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
set fileencodings=utf-8
set termencoding=utf-8
" 解決和tmux的顏色沖突問題
colorscheme pablo
set rnu
set nu
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set autoindent
inoremap ( ()<Esc>i
inoremap [ []<Esc>i
inoremap { {}<Esc>i
inoremap ) <c-r>=ClosePair(')')<CR>
inoremap ] <c-r>=ClosePair(']')<CR>
inoremap } <c-r>=ClosePair('}')<CR>
inoremap " <c-r>=QuoteDelim('"')<CR>
inoremap ' <c-r>=QuoteDelim("'")<CR>
inoremap <TAB> <c-r>=SkipPair()<CR>
nmap <F5> :!python3 %<CR>
nmap <F2> :!ici <C-R><C-W><CR> " 翻譯當前光標下的單詞
" 自動補全括號
function ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf
" 自動補全引號
function QuoteDelim(char)
let line = getline('.')
let col = col('.')
if line[col - 2] == "\\"
return a:char
elseif line[col - 1] == a:char
return "\<Right>"
else
return a:char.a:char."\<Esc>i"
endif
endf
" 按 Tab 跳出括號和引號
function SkipPair()
if getline('.')[col('.') - 1] == ')' || getline('.')[col('.') - 1] == ']' || getline('.')[col('.') - 1] == '"' || getline('.')[col('.') - 1] == "'"
return "\<ESC>la"
else
return "\t"
endif
endf
filetype off
set rtp+=~/.vim/bundle/vundle
call vundle#rc()
Bundle 'gmarik/vundle'
filetype plugin indent on
" Below here to add the vundle what I want
" Emmet html標簽快速生成
Plugin 'mattn/emmet-vim'
let g:user_emmet_mode = 'i'
let g:user_emmet_expandabbr_key = '<C-b>'
let g:user_emmet_next_key = '<C-d>'
let g:user_emmet_prev_key = '<C-t>'
let g:user_emmet_install_global = 1
" autocmd Filetype html,css,php,tpl,python,javascript,ruby EmmetInstall
let g:user_emmet_settings = {
\ 'php' : {
\ 'extends' : 'html',
\ 'filters' : 'c',
\ },
\ 'xml' : {
\ 'extends' : 'html',
\ },
\ 'haml' : {
\ 'extends' : 'html',
\ },
\}
" NERDTree目錄樹插件
Plugin 'scrooloose/nerdtree'
nmap <F4> :NERDTree <CR>
let g:NERDTreeWinPos="left"
let g:NERDTreeWinSize=20
let g:NERDTreeShowLineNumbers=1
" NERDCommenter快速注釋插件
Plugin 'scrooloose/nerdcommenter'
" 變量函數(shù)樹
" Plugin 'vim-scripts/taglist.vim'
" 快速添加符號
Plugin 'tpope/vim-surround'
" 使surround可重復
Plugin 'tpope/vim-repeat'
" 多行光標
Plugin 'terryma/vim-multiple-cursors'
" JS
Plugin 'chemzqm/vim-jsx-improve'
Plugin 'maxmellon/vim-jsx-pretty'
Plugin 'pangloss/vim-javascript'
" Rails
Plugin 'tpope/vim-rails'
" 代碼對齊
Plugin 'godlygeek/tabular'
" YouCompleteMe補全
Plugin 'Valloric/YouCompleteMe'
" YouCompleteMe補全配置
let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_global_ycm_extra_conf'
" 修改ycm按鍵
let g:ycm_key_list_select_completion = ['<c-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<Up>']
" let g:ycm_key_list_previous_completion = ['<c-p>', '<Up>']
" 配置成像一樣IDE
set completeopt=longest,menu
" 退出insert模式后自動隱藏補全提示框
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
" 回車鍵選擇補全項
inoremap <expr> <CR> pumvisible() ? "\<C-y>\<C-o>:pclose\<CR>\<C-o>l" : "\<CR>"
" 禁用補全
nnoremap <leader>y :let g:ycm_auto_trigger=1<CR>
" 注釋和字符串中的文字也會被收入補全
let g:ycm_collect_identifiers_from_comments_and_strings = 1
" 重命名文件
Plugin 'danro/rename.vim'
" 語法檢查
" Plugin 'vim-syntastic/syntastic'
" Ctrlp 文件模糊查找
Plugin 'ctrlpvim/ctrlp.vim'
Zsh
安裝 zsh
sudo apt-get install zsh
將 zsh 設置成默認的 shell
chsh -s /bin/zsh
配置 oh-my-zsh
# 通過 curl 安裝
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh
# 通過 wget 安裝
wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O - | sh
# 手動安裝
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh # 克隆 oh-my-zsh 項目文件
# 備份自己的配置
cp ~/.zshrc ~/.zshrc.bk
# 將 oh-my-zsh 的模板配置拷貝出來
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
Tmux
安裝 tmux
sudo apt-get install tmux
配置tmux
為了配合 vim 使用, 配置成類似于 IDE 的下方或右方顯示終端輸出結果, 在 Home 目錄下添加布局配置文件
右方布局 ~/.tmux/horizontal_split_layout
selectp -t 0 # 選中第0個窗格
splitw -h -p 20 -c "#{pane_current_path}" # 垂直分屏
下方布局 ~/.tmux/horizontal_split_layout
selectp -t 0 # 選中第0個窗格
splitw -v -p 15 -c "#{pane_current_path}" # 將其分成左右兩個
然后在 tmux 配置文件中引用布局并綁定對應按鍵, 并添加上自己習慣的按鍵操作配置, 最終 tmux 配置如下
# 加載布局文件
bind q source-file ~/.tmux/horizontal_split_layout
bind z source-file ~/.tmux/vertical_split_layout
# 重新加載配置文件
bind C-r source-file ~/.tmux.conf \; display "Refleshed Configure!"
# 設置成vim模式
setw -g mode-keys vi
# 將面板切換設置成hjkl
bind-key k select-pane -U # up
bind-key j select-pane -D # down
bind-key h select-pane -L # left
bind-key l select-pane -R # right
# 設置鼠標滾動
# set-window-option -g mode-mouse on # (setw其實是set-window-option的別名)
# 將觸發(fā)鍵改成C-a
set -g prefix C-a
unbind C-b
# 將復制模式設置成vim的復制模式
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
# 設置終端顏色
# set -g default-terminal "screen-256color"
# set -g default-terminal "linux"