Editors and configs

I’ve been using vim for a number of years (I wish I had known about it in college!) and would love to know more about @jeremy’s .vimrc config file (along with anybody else who wants to share). I don’t know if it’s posted anywhere or if there’s some other content about his config. Or his jupyter config for that matter.

I wrote a blog post about mine a while back, but that was when I was mostly doing Ruby/Rails exclusively. I’m interested in modifying my setup for python. I modified my setup as per this StackOverflow answer so I can push/pull my config into a new server quickly and love it.

Also, if you use an editor/config/plugin that you really like, I’d love to hear about it.

Are there any python coders using emacs (or any other ‘classic’ editor like vim)?

2 Likes

I hardly do any vimrc hackery. I basically just use it as-is, after enabling syntax highlighting and setting up suitable tab behavior for python.

1 Like

I’m in love with spacemacs, basically emacs with good defaults and evil (vim) mode :slightly_smiling_face:

sublime text through and through, with occasional nano

1 Like

Hi @bhollan,

My vim is configured for working with Python.
Here’s my .vimrc:

set nocompatible
filetype off

source /usr/local/lib/python2.7/site-packages/powerline/bindings/vim/plugin/powerline.vim

" Always show statusline
set laststatus=2

" Always show line numbers
set number

"Deadly-Sin
set mouse=a

set t_Co=256
syntax enable
colorscheme mustang
set encoding=utf-8

set rtp+=~/.vim/bundle/Vundle.vim/
call vundle#rc()

" let Vundle manage Vundle
" required! 
Bundle 'gmarik/vundle'

" The bundles you install will be listed here

filetype plugin indent on

" The rest of your config follows here

augroup vimrc_autocmds
	autocmd!
	" highlight characters past column 120
    autocmd FileType python hi Normal guifg=White guibg=Black 
	autocmd FileType python match Normal /\%120v.*/
	autocmd FileType python set nowrap
	augroup END

"Powerline
Bundle 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}

" Powerline setup
set guifont=Ubuntu\ Mono\ for\ VimPowerline\ 11.5
set laststatus=2

".json highlighting
autocmd BufNewFile,BufRead *.json set ft=javascript

"Fugitive
Bundle 'tpope/vim-fugitive'

"NerdTree
Bundle 'scrooloose/nerdtree'

"Python-mode
Bundle 'klen/python-mode'

"Jedi-vim
Bundle 'davidhalter/jedi-vim'

"Color-scheme
Bundle 'flazz/vim-colorschemes'

"YouCompleteMe
Bundle 'Valloric/YouCompleteMe'

"Indent-guide
"Bundle 'Yggdroot/indentLine'

"Scala
Bundle 'derekwyatt/vim-scala'

"Scala sbt
Bundle 'ktvoelker/sbt-vim'

"Javascript syntax
Plugin 'jelera/vim-javascript-syntax'
Plugin 'pangloss/vim-javascript'
Plugin 'Raimondi/delimitMate'
Plugin 'marijnh/tern_for_vim'

" Python-mode
" Activate rope
" Keys:
" K             Show python docs
" <Ctrl-Space>  Rope autocomplete
" <Ctrl-c>g     Rope goto definition
" <Ctrl-c>d     Rope show documentation
" <Ctrl-c>f     Rope find occurrences
" <Leader>b     Set, unset breakpoint (g:pymode_breakpoint enabled)
" [[            Jump on previous class or function (normal, visual, operator modes)
" ]]            Jump on next class or function (normal, visual, operator modes)
" [M            Jump on previous class or method (normal, visual, operator modes)
" ]M            Jump on next class or method (normal, visual, operator modes)
map <<F3>> :NERDTreeToggle<CR>

let g:pymode_rope = 0

" Documentation
let g:pymode_doc = 1
let g:pymode_doc_key = 'K'

"Linting
let g:pymode_lint = 1
let g:pymode_lint_checker = "pyflakes,pep8"
" Auto check on save
let g:pymode_lint_write = 1

" Support virtualenv
let g:pymode_virtualenv = 1

" Enable breakpoints plugin
let g:pymode_breakpoint = 1
let g:pymode_breakpoint_key = '<leader>b'

" syntax highlighting
let g:pymode_syntax = 1
let g:pymode_syntax_all = 1
let g:pymode_syntax_indent_errors = g:pymode_syntax_all
"let g:pymode_syntax_space_errors = g:pymode_syntax_all
let g:pymode_options_colorcolumn = 0

" Don't autofold code
let g:pymode_folding = 0

"Powerline
let g:Powerline_symbols = 'fancy'

"IndentLine char
"let g:indentLine_char = ''

" Use <leader>l to toggle display of whitespace
nmap <leader>l :set list!<CR>
" automatically change window's cwd to file's dir
set autochdir

" I prefer spaces to tabs
set tabstop=4
set shiftwidth=4
set expandtab
set pastetoggle=<F2>
set backspace=indent,eol,start

" more subtle popup colors 
if has ('gui_running')
    highlight Pmenu guibg=#cccccc gui=bold    
endif

It includes plugins for syntax highlighting, auto-completion, pylint etc.

3 Likes

(Update at the bottom how to solve it)
Tried to replicate what Jeremy is doing, with plain Vim

set foldmethod=indent
syntax on
colorscheme desert
nnoremap <space> za
vnoremap <space> zf

Remove the last two lines if you don’t like function folding with space.
Inspired by: What is the recommended way to use Vim folding for Python code

Have not found out how to fold on functions like Jeremy, only on the indent. Tried to read up on the docs and found that there are Regex methods, but not tried those yet.

Jeremy vs. my sub-optimal version:

Solution

Seems that Jeremy is using the Python-Mode module for Vim.

Installation:

cd ~/.vim/pack/foo/start
git clone https://github.com/python-mode/python-mode.git
cd python-mode
git submodule update --init --recursive

Could be that you have to create all the folders in ~/.vim/pack/foo/start

My result:

3 Likes