Skip to content

Instantly share code, notes, and snippets.

@valdergallo
Last active January 4, 2017 14:12
Show Gist options
  • Save valdergallo/2979412 to your computer and use it in GitHub Desktop.
Save valdergallo/2979412 to your computer and use it in GitHub Desktop.
vimrc for server
" Reference:
" http://sontek.net/turning-vim-into-a-modern-python-ide
" https://github.com/amix/vimrc
" Enable filetype plugins
filetype on
filetype plugin on
filetype indent off
let g:pyflakes_use_quickfix = 0
let g:pep8_map='<leader>8'
""""""""""""""""""""""""""""""
" => Status line
""""""""""""""""""""""""""""""
" Always show the status line
set laststatus=2
" Color (light bg)
set background=light
colorscheme delek
" General settings
set history=50 " number of actions to remembered in a history
set encoding=utf8 " set encoding by default with utf8
set t_Co=256 " number of colors
set sm " Magic substitute
set smarttab " delete white spaces from tab if line is empty
set shiftwidth=4 " Number of spaces to use for each step
set tabstop=4 " set tab with 4 spaces
set autoindent " auto indent files
set backspace=indent,eol,start " more powerful backspacing
set modeline " use vim settings in beginning/end of files
set modelines=5 " number of lines to look for modeline
set laststatus=2
set nocompatible " disable compatible mode
set ruler " show line,col in status bar
set hidden " hide buffers with closed files
set incsearch " use incremental search
set autowrite " auto save file before some commands
set showcmd " show command/mode in at bottom
set showmatch " show match (), [] and {}
set nohlsearch " no highlight search results
set noignorecase " case sensitive search
set nojoinspaces " don't add space when joining line
set nobackup " no backups
set textwidth=0 nowrap " infinite lines with no wrap
set completeopt=menu,preview " configure drop-down menu when completing with ctrl-n
set wildmode=list:longest " bash like command line tab completion
set wildignore=*.o,*.obj,*~,*.swp,*.pyc " ignore when tab completing:
set writeany " Allow writing readonly files
set visualbell " Set visual bell
set smartcase " When searching try to be smart about cases
" Allow index folder
try
set foldmethod=indent " Folding method: indent
set foldlevel=99 " Initial Fold Level
catch
endtry
" Allow select with mouse
set mousemodel=popup
set selection=exclusive
let mapleader="," " <Leader> == ,
" CTRL+[hjkl] navigation between buffers
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
" Doh... you know what this does... ;-)
syntax on
" Some useful abbreviations to common mistyped commands
cab W w | cab Q q | cab Wq wq | cab wQ wq | cab WQ wq | cab X x
" Comment/Uncomment for different languages
au FileType haskell,vhdl,ada let comment = '-- '
au FileType sh,make,python,ruby let comment = '# '
au FileType c,cpp,java,javascript let comment = '// '
au FileType tex let comment = '% '
au FileType vim let comment = '" '
" Comment Blocks
" ,c -> comment selected
" ,u -> uncomment selected
noremap <silent> ,c :s,^,<C-R>=comment<CR>,<CR>:noh<CR>
noremap <silent> ,u :s,^\V<C-R>=comment<CR>,,e<CR>:noh<CR>
" Highlight trailing whitespaces
highlight WhitespaceEOL ctermbg=red guibg=red
au ColorScheme * highlight WhitespaceEOL ctermbg=red guibg=red
match WhitespaceEOL /\s\+$/
" ,a -> clean all trailing spaces
noremap <silent> ,a :call DeleteTrailingWS()<CR>
" Language specifics
let python_highlight_all = 1
au FileType python set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class,with
au FileType python set omnifunc=pythoncomplete#Complete
au FileType python set expandtab smarttab autoindent smartindent shiftwidth=4 tabstop=4 softtabstop=4
" Terminal.app keyboard settings
map <Esc>[H <Home>
imap <Esc>[H <Home>
map <Esc>[F <End>
imap <Esc>[F <End>
map <Esc>[5~ <PageUp>
imap <Esc>[5~ <PageUp>
map <Esc>[6~ <PageDown>
imap <Esc>[6~ <PageDown>
" Moving .swp files away
set backupdir=~/.vim
set directory=~/.vim
" Useful mappings for managing tabs
map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove<cr>
" Opens a new tab with the current buffer's path
" Super useful when editing files in the same directory
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>
" Switch CWD to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>:pwd<cr>
" Delete trailing white space on save, useful for Python and CoffeeScript ;)
autocmd BufWrite :call DeleteTrailingWS()
" Specify the behavior when switching between buffers
try
set switchbuf=useopen,usetab,newtab
set stal=2
catch
endtry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment