Last active
April 14, 2016 14:46
-
-
Save do3cc/4de070dfa15e945a21ea4e54c6247790 to your computer and use it in GitHub Desktop.
How to run isort only for specific projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.vimrc | |
" Allow project specific vimrc files | |
set exrc | |
set secure " Prevent potentially malicious vimrc files from breaking stuff | |
" Isort | |
function! Isort() | |
let cursor_pos = getpos('.') | |
%!isort - | |
call setpos('.', cursor_pos) | |
endfunction | |
command! -range=% Isort :<line1>,<line2>! :Isort() | |
... | |
# ~/projects/some_project/.vimrc | |
" This project has an ISort configuration | |
" So automatically sort imports according to its config | |
autocmd FileType python autocmd BufWritePre <buffer> :call Isort() | |
################################# | |
# Bonus for better buildout files | |
################################# | |
# ~/.vimrc | |
" Allow project specific vimrc files | |
set exrc | |
set secure " Prevent potentially malicious vimrc files from breaking stuff | |
" normalize buildout | |
function Normalizebuildout() | |
let cursor_pos = getpos('.') | |
%!normalize_buildout - | |
call setpos('.', cursor_pos) | |
endfunction | |
command! -range=% Normalizebuildout :Normalizebuildout() | |
$ cd $project | |
$ source bin/activate | |
$ pip install buildout_helpers | |
# ~/projects/some_project/.vimrc | |
" This project has an ISort configuration | |
" So automatically sort imports according to its config | |
autocmd BufWritePre *.cfg :call Normalizebuildout() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment