.vimrc :
set nocompatible
"set lines=40 columns=100 " set font in linux set guifont=Monospace\ 14
" set font in windows
" set guifont=Consolas:h14
" for gvim
" set guioptions-=T set guioptions-=m colorscheme murphy " c coding indent, turn off when use python
" set cindent
syntax on
set nu
set autoindent
set shiftwidth=4
set tabstop=4
set softtabstop=4
set nobackup
set showcmd
set showmode
set showmatch
filetype on
" insert # as comment
map <C-I> I# <ESC>
map <silent> <F5> :call Compile()<CR>
function! Compile()
exec "w"
if &filetype == "python"
exec "!python %"
endif
if &filetype == "javascript"
exec "!node %"
endif
if &filetype == 'c'
exec "!g++ % -o %<"
exec "!g++ % -o test"
exec "!./test"
elseif &filetype == 'cpp'
exec "!g++ % -o test"
exec "!./test"
elseif &filetype == 'java'
exec "!javac %"
exec "!java %<"
elseif &filetype == 'sh'
exec "!./%"
elseif &filetype == 'php'
exec "!php -f %"
endif
endfunc
" Python default settings
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
" when save python file, then delete redundant space
fun! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
autocmd FileType c,cpp,java,go,php,javascript,puppet,python,rust,twig,xml,yml,perl autocmd BufWritePre <buffer> :call <SID>StripTrailingWhitespaces()
" automate insert the header of file
autocmd BufNewFile *.sh,*.py exec ":call AutoSetFileHead()"
"autocmd BufNewFile *.sh,*.py call AutoSetFileHead()
function! AutoSetFileHead()
if &filetype == 'sh'
call setline(1, "\#!/bin/bash")
endif
if &filetype == 'python'
call setline(1, "\#!/usr/bin/env python")
call append(1, "\# encoding: utf-8")
endif
normal G
normal o
normal o
endfunc
" when vimrc changed, thend auto load with windows
"autocmd! bufwritepost _vimrc source %
" when vimrc changed, thend auto load with linux
autocmd! bufwritepost .vimrc source %
"when vim exit, cat file content in terminal
"set t_ti = t_te=
" history account
set history=2000
call plug#begin('~/.vim/plugged')
" Make sure you use single quotes
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'
" Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
" Group dependencies, vim-snippets depends on ultisnips
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
" Using a non-master branch
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
" Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug 'fatih/vim-go', { 'tag': '*' }
" Plugin options
Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
" Plugin outside ~/.vim/plugged with post-update hook
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
" Unmanaged plugin (manually installed and updated)
Plug '~/my-prototype-plugin'
" Add plugins to &runtimepath
call plug#end()
" NERDTree config
map <F2> :NERDTreeToggle<CR>
"map :silent! NERDTreeToggle
"autocmd vimEnter * NERDTree
以前是好用的,创建 python 文件可以自动插入文件头,但是现在不知道怎么回事,就是无法插入成功,只是插入两行空行,没有任何文字,这是为什么呢?
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.