"========================================== " some commands " Use :q! : tells vim to execute command q " save: w " :help ! : help " shift + O : insert mode (im) , exit im - " set im / : set noim " " ln -s ~/bin/.vimrc ~/.vimrc " " Vimrc: clone: " curl https://raw.githubusercontent.com/wklken/vim-for-server/master/vimrc > ~/.vimrc " Project: https://github.com/wklken/vim-for-server " Author: wklken " Version: 0.2 " Email: wklken@yeah.net " BlogPost: http://www.wklken.me " Donation: http://www.wklken.me/pages/donation.html " ReadMe: README.md " Last_modify: 2015-07-07 " Desc: simple vim config for server, without any plugins. "========================================== " leader let mapleader = ',' let g:mapleader = ',' " syntax syntax on " history : how many lines of history VIM has to remember set history=2000 " filetype filetype on " Enable filetype plugins filetype plugin on filetype indent on " base set nocompatible " don't bother with vi compatibility set autoread " reload files when changed on disk, i.e. via `git checkout` set shortmess=atI set magic " For regular expressions turn magic on set title " change the terminal's title " set nobackup " do not keep a backup file set novisualbell " turn off visual bell set noerrorbells " don't beep set visualbell t_vb= " turn off error beep/flash set t_vb= set tm=500 " show location " set cursorcolumn set cursorline " movement set scrolloff=7 " keep 3 lines when scrolling " show set ruler " show the current row and column set number " show line numbers set nowrap set showcmd " display incomplete commands set showmode " display current modes set showmatch " jump to matches when entering parentheses set matchtime=2 " tenths of a second to show the matching parenthesis " search set hlsearch " highlight searches set incsearch " do incremental searching, search as you type set ignorecase " ignore case when searching set smartcase " no ignorecase if Uppercase char present " tab set expandtab " expand tabs to spaces set smarttab set shiftround " indent set autoindent smartindent shiftround set shiftwidth=4 set tabstop=4 set softtabstop=4 " insert mode tab and backspace use 4 spaces " NOT SUPPORT " fold " # set foldenable set foldmethod=indent set foldlevel=99 "let g:FoldMethod = 0 "map zz :call ToggleFold() "fun! ToggleFold() " if g:FoldMethod == 0 " exe "normal! zM" " let g:FoldMethod = 1 " else " exe "normal! zR" " let g:FoldMethod = 0 " endif "endfun " encoding ============================= " set encoding=utf-8 set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1 set termencoding=utf-8 set ffs=unix,dos,mac set formatoptions+=m set formatoptions+=B " select & complete set selection=inclusive set selectmode=mouse,key set completeopt=longest,menu set wildmenu " show a navigable menu for tab completion" set wildmode=longest,list,full set wildignore=*.o,*~,*.pyc,*.class " others set backspace=indent,eol,start " make that backspace key work the way it should set whichwrap+=<,>,h,l " if this not work ,make sure .viminfo is writable for you if has("autocmd") au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif endif " NOT SUPPORT " Enable basic mouse behavior such as resizing buffers. set mouse=a " ============================ theme and status line ============================ " theme set background=dark colorscheme desert " set mark column color hi! link SignColumn LineNr hi! link ShowMarksHLl DiffAdd hi! link ShowMarksHLu DiffChange " status line set statusline=%<%f\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",BOM\":\"\")}]\ %-14.(%l,%c%V%)\ %P set laststatus=2 " Always show the status line - use 2 lines for the status bar " ============================ specific file type =========================== autocmd FileType python set tabstop=4 shiftwidth=4 expandtab ai autocmd FileType ruby set tabstop=2 shiftwidth=2 softtabstop=2 expandtab ai autocmd BufRead,BufNew *.md,*.mkd,*.markdown set filetype=markdown.mkd autocmd BufNewFile *.sh,*.py exec ":call AutoSetFileHead()" function! AutoSetFileHead() " .sh if &filetype == 'sh' call setline(1, "\#!/bin/bash") endif " python if &filetype == 'python' call setline(1, "\#!/usr/bin/env python") call append(1, "\# encoding: utf-8") endif normal G normal o normal o endfunc autocmd FileType c,cpp,java,go,php,javascript,puppet,python,rust,twig,xml,yml,perl autocmd BufWritePre :call StripTrailingWhitespaces() fun! StripTrailingWhitespaces() let l = line(".") let c = col(".") %s/\s\+$//e call cursor(l, c) endfun " # ============== keys 1 =========================== " =================================================== map mouse " # http://vim.wikia.com/wiki/Start_in_insert_mode_without_losing_your_escape_key " alias vim='vim -c start' imap imap imap { imap } " imap " inoremap jj nnoremap :set im! nnoremap :set im! " nnoremap :set im! " :echo nnoremap : nnoremap : inoremap : inoremap :InsertLeave inoremap :InsertLeave " Insert imap ===================================================== " inoremap h " inoremap j imap dd imap :set noim " Window splits ================================================== " Cltr+W + Cltr+W moves between :vplit map w map v map - s " j " inoremap k " inoremap l " make files ================================================= " map :make "set makeprg ?? " ============================ key map ============================ " nnoremap k gk nnoremap gk k nnoremap j gj nnoremap gj j " map j " map k " map h " map l " nnoremap :set nu! nu? " nnoremap :set list! list? nnoremap :set wrap! wrap? set pastetoggle= " when in insert mode, press to go to " paste mode, where you can paste mass data " that won't be autoindented au InsertLeave * set nopaste nnoremap :exec exists('syntax_on') ? 'syn off' : 'syn on' " HELP: :vert help " kj - Esc ========================================================= " kj - Esc " inoremap kj " Quickly close the current window nnoremap q :q " Quickly save the current file nnoremap w :w " select all map sa ggVG" " remap U to for easier redo nnoremap U " Swap implementations of ` and ' jump to markers " By default, ' jumps to the marked line, ` jumps to the marked line and " column, so swap them nnoremap ' ` nnoremap ` ' " switch # * " nnoremap # * " nnoremap * # "Keep search pattern at the center of the screen." nnoremap n nzz nnoremap N Nzz nnoremap * *zz nnoremap # #zz nnoremap g* g*zz " remove highlight noremap / :nohls " Reselect visual block after indent/outdent. vnoremap < >gv " y$ -> Y Make Y behave like other capitalS " map Y y$ " Map ; to : and save a million keystrokes " ex mode commands made easy " nnoremap ; : " save cmap w!! w !sudo tee >/dev/null % " command mode, ctrl-a to head, ctrl-e to tail cnoremap cnoremap cnoremap cnoremap