├── README.md └── vimrc /README.md: -------------------------------------------------------------------------------- 1 | vim-for-server 2 | ============== 3 | 4 | .vimrc, simple configures for server, without plugins. 5 | 6 | # Introduction 7 | 8 | This repository is a simplified version of [k-vim](https://github.com/wklken/k-vim) 9 | 10 | Just remove all plugins, keep basic config. 11 | 12 | # Screenshot 13 | 14 | ![screenshot](https://raw.githubusercontent.com/wklken/gallery/master/vim/vim-for-server.png) 15 | 16 | # Install 17 | 18 | #### 1. backup your old .vimrc if it is necessary 19 | 20 | ``` 21 | cp ~/.vimrc ~/.vimrc_bak 22 | ``` 23 | 24 | #### 2. just get the file 25 | 26 | recommend 27 | ``` 28 | curl https://raw.githubusercontent.com/wklken/vim-for-server/master/vimrc > ~/.vimrc 29 | ``` 30 | or use git 31 | 32 | ``` 33 | git clone https://github.com/wklken/vim-for-server.git 34 | ln -s vim-for-server/vimrc ~/.vimrc 35 | ``` 36 | 37 | #### 3. Done, enjoy it 38 | 39 | 40 | # Donation 41 | 42 | You can Buy me a coffee:) [link](http://www.wklken.me/pages/donation.html) 43 | 44 | 45 | ------------------------ 46 | ------------------------ 47 | 48 | wklken 49 | 50 | Email: wklken@yeah.net 51 | 52 | Github: https://github.com/wklken 53 | 54 | Blog: [http://www.wklken.me](http://www.wklken.me) 55 | 56 | 2014-10-26 ShenZhen 57 | -------------------------------------------------------------------------------- /vimrc: -------------------------------------------------------------------------------- 1 | "========================================== 2 | " ProjectLink: https://github.com/wklken/vim-for-server 3 | " Author: wklken 4 | " Version: 0.2 5 | " Email: wklken@yeah.net 6 | " BlogPost: http://www.wklken.me 7 | " Donation: http://www.wklken.me/pages/donation.html 8 | " ReadMe: README.md 9 | " Last_modify: 2015-07-07 10 | " Desc: simple vim config for server, without any plugins. 11 | "========================================== 12 | 13 | " leader 14 | let mapleader = ',' 15 | let g:mapleader = ',' 16 | 17 | " syntax 18 | syntax on 19 | 20 | " history : how many lines of history VIM has to remember 21 | set history=2000 22 | 23 | " filetype 24 | filetype on 25 | " Enable filetype plugins 26 | filetype plugin on 27 | filetype indent on 28 | 29 | 30 | " base 31 | set nocompatible " don't bother with vi compatibility 32 | set autoread " reload files when changed on disk, i.e. via `git checkout` 33 | set shortmess=atI 34 | 35 | set magic " For regular expressions turn magic on 36 | set title " change the terminal's title 37 | set nobackup " do not keep a backup file 38 | 39 | set novisualbell " turn off visual bell 40 | set noerrorbells " don't beep 41 | set visualbell t_vb= " turn off error beep/flash 42 | set t_vb= 43 | set tm=500 44 | 45 | 46 | " show location 47 | set cursorcolumn 48 | set cursorline 49 | 50 | 51 | " movement 52 | set scrolloff=7 " keep 3 lines when scrolling 53 | 54 | 55 | " show 56 | set ruler " show the current row and column 57 | set number " show line numbers 58 | set nowrap 59 | set showcmd " display incomplete commands 60 | set showmode " display current modes 61 | set showmatch " jump to matches when entering parentheses 62 | set matchtime=2 " tenths of a second to show the matching parenthesis 63 | 64 | 65 | " search 66 | set hlsearch " highlight searches 67 | set incsearch " do incremental searching, search as you type 68 | set ignorecase " ignore case when searching 69 | set smartcase " no ignorecase if Uppercase char present 70 | 71 | 72 | " tab 73 | set expandtab " expand tabs to spaces 74 | set smarttab 75 | set shiftround 76 | 77 | " indent 78 | set autoindent smartindent shiftround 79 | set shiftwidth=4 80 | set tabstop=4 81 | set softtabstop=4 " insert mode tab and backspace use 4 spaces 82 | 83 | " NOT SUPPORT 84 | " fold 85 | set foldenable 86 | set foldmethod=indent 87 | set foldlevel=99 88 | let g:FoldMethod = 0 89 | map zz :call ToggleFold() 90 | fun! ToggleFold() 91 | if g:FoldMethod == 0 92 | exe "normal! zM" 93 | let g:FoldMethod = 1 94 | else 95 | exe "normal! zR" 96 | let g:FoldMethod = 0 97 | endif 98 | endfun 99 | 100 | " encoding 101 | set encoding=utf-8 102 | set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1 103 | set termencoding=utf-8 104 | set ffs=unix,dos,mac 105 | set formatoptions+=m 106 | set formatoptions+=B 107 | 108 | " select & complete 109 | set selection=inclusive 110 | set selectmode=mouse,key 111 | 112 | set completeopt=longest,menu 113 | set wildmenu " show a navigable menu for tab completion" 114 | set wildmode=longest,list,full 115 | set wildignore=*.o,*~,*.pyc,*.class 116 | 117 | " others 118 | set backspace=indent,eol,start " make that backspace key work the way it should 119 | set whichwrap+=<,>,h,l 120 | 121 | " if this not work ,make sure .viminfo is writable for you 122 | if has("autocmd") 123 | au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif 124 | endif 125 | 126 | " NOT SUPPORT 127 | " Enable basic mouse behavior such as resizing buffers. 128 | " set mouse=a 129 | 130 | 131 | " ============================ theme and status line ============================ 132 | 133 | " theme 134 | set background=dark 135 | colorscheme desert 136 | 137 | " set mark column color 138 | hi! link SignColumn LineNr 139 | hi! link ShowMarksHLl DiffAdd 140 | hi! link ShowMarksHLu DiffChange 141 | 142 | " status line 143 | set statusline=%<%f\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",BOM\":\"\")}]\ %-14.(%l,%c%V%)\ %P 144 | set laststatus=2 " Always show the status line - use 2 lines for the status bar 145 | 146 | 147 | " ============================ specific file type =========================== 148 | 149 | autocmd FileType python set tabstop=4 shiftwidth=4 expandtab ai 150 | autocmd FileType ruby set tabstop=2 shiftwidth=2 softtabstop=2 expandtab ai 151 | autocmd BufRead,BufNew *.md,*.mkd,*.markdown set filetype=markdown.mkd 152 | 153 | autocmd BufNewFile *.sh,*.py exec ":call AutoSetFileHead()" 154 | function! AutoSetFileHead() 155 | " .sh 156 | if &filetype == 'sh' 157 | call setline(1, "\#!/bin/bash") 158 | endif 159 | 160 | " python 161 | if &filetype == 'python' 162 | call setline(1, "\#!/usr/bin/env python") 163 | call append(1, "\# encoding: utf-8") 164 | endif 165 | 166 | normal G 167 | normal o 168 | normal o 169 | endfunc 170 | 171 | autocmd FileType c,cpp,java,go,php,javascript,puppet,python,rust,twig,xml,yml,perl autocmd BufWritePre :call StripTrailingWhitespaces() 172 | fun! StripTrailingWhitespaces() 173 | let l = line(".") 174 | let c = col(".") 175 | %s/\s\+$//e 176 | call cursor(l, c) 177 | endfun 178 | 179 | " ============================ key map ============================ 180 | 181 | nnoremap k gk 182 | nnoremap gk k 183 | nnoremap j gj 184 | nnoremap gj j 185 | 186 | map j 187 | map k 188 | map h 189 | map l 190 | 191 | nnoremap :set nu! nu? 192 | nnoremap :set list! list? 193 | nnoremap :set wrap! wrap? 194 | set pastetoggle= " when in insert mode, press to go to 195 | " paste mode, where you can paste mass data 196 | " that won't be autoindented 197 | au InsertLeave * set nopaste 198 | nnoremap :exec exists('syntax_on') ? 'syn off' : 'syn on' 199 | 200 | " kj 替换 Esc 201 | inoremap kj 202 | 203 | " Quickly close the current window 204 | nnoremap q :q 205 | " Quickly save the current file 206 | nnoremap w :w 207 | 208 | " select all 209 | map sa ggVG" 210 | 211 | " remap U to for easier redo 212 | nnoremap U 213 | 214 | " Swap implementations of ` and ' jump to markers 215 | " By default, ' jumps to the marked line, ` jumps to the marked line and 216 | " column, so swap them 217 | nnoremap ' ` 218 | nnoremap ` ' 219 | 220 | " switch # * 221 | " nnoremap # * 222 | " nnoremap * # 223 | 224 | "Keep search pattern at the center of the screen." 225 | nnoremap n nzz 226 | nnoremap N Nzz 227 | nnoremap * *zz 228 | nnoremap # #zz 229 | nnoremap g* g*zz 230 | 231 | " remove highlight 232 | noremap / :nohls 233 | 234 | "Reselect visual block after indent/outdent.调整缩进后自动选中,方便再次操作 235 | vnoremap < >gv 237 | 238 | " y$ -> Y Make Y behave like other capitals 239 | map Y y$ 240 | 241 | "Map ; to : and save a million keystrokes 242 | " ex mode commands made easy 用于快速进入命令行 243 | nnoremap ; : 244 | 245 | " Shift+H goto head of the line, Shift+L goto end of the line 246 | nnoremap H ^ 247 | nnoremap L $ 248 | 249 | " save 250 | cmap w!! w !sudo tee >/dev/null % 251 | 252 | " command mode, ctrl-a to head, ctrl-e to tail 253 | cnoremap 254 | cnoremap 255 | cnoremap 256 | cnoremap 257 | --------------------------------------------------------------------------------