Vim+Zsh+Tmux完璧な組み合わせ

9584 ワード

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の下または右に端末出力結果を表示するように構成し、ホームディレクトリの下にレイアウトプロファイルを追加します.
右レイアウト~/.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"