Purpose
本文主要为了记录个人的日常使用软件配置, 以在切换设备时根据本文快速配置自己习惯的配置, 所以不涉及任何的操作教程, 以下所有配置主要针对在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 中执行 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 ( ()i
inoremap [ []i
inoremap { {}i
inoremap ) =ClosePair(')')
inoremap ] =ClosePair(']')
inoremap } =ClosePair('}')
inoremap " =QuoteDelim('"')
inoremap ' =QuoteDelim("'")
inoremap =SkipPair()
nmap :!python3 %
nmap :!ici " 翻译当前光标下的单词
" 自动补全括号
function ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\"
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 "\"
else
return a:char.a:char."\i"
endif
endf
" 按 Tab 跳出括号和引号
function SkipPair()
if getline('.')[col('.') - 1] == ')' || getline('.')[col('.') - 1] == ']' || getline('.')[col('.') - 1] == '"' || getline('.')[col('.') - 1] == "'"
return "\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 = ''
let g:user_emmet_next_key = ''
let g:user_emmet_prev_key = ''
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 :NERDTree
let g:NERDTreeWinPos="left"
let g:NERDTreeWinSize=20
let g:NERDTreeShowLineNumbers=1
" NERDCommenter快速注释插件
Plugin 'scrooloose/nerdcommenter'
" 变量函数树
" 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 = ['', '']
let g:ycm_key_list_previous_completion = ['']
" let g:ycm_key_list_previous_completion = ['', '']
" 配置成像一样IDE
set completeopt=longest,menu
" 退出insert模式后自动隐藏补全提示框
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
" 回车键选择补全项
inoremap pumvisible() ? "\\:pclose\\l" : "\"
" 禁用补全
nnoremap y :let g:ycm_auto_trigger=1
" 注释和字符串中的文字也会被收入补全
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的别名)
# 将触发键改成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"