Skip to content

Instantly share code, notes, and snippets.

@RomainEndelin
Last active August 29, 2015 14:20
Show Gist options
  • Save RomainEndelin/70e3863822e699edae40 to your computer and use it in GitHub Desktop.
Save RomainEndelin/70e3863822e699edae40 to your computer and use it in GitHub Desktop.
A basic vimrc & tmuxrc for python dev
# important for solarized color theme with vim
set -g default-terminal "screen-256color"
# Theme
if-shell "test -f $HOME/.tmux/theme.conf" "source $HOME/.tmux/theme.conf"
# Rebind the main key to Ctrl-a, rather than Ctrl-b
unbind C-b
set -g prefix C-a
# better handling of pane creating
unbind %
bind _ split-window -h
bind - split-window -v
# starting window numbering at 1
set-option -g base-index 1
set-window-option -g pane-base-index 1
# better handling in several windows
setw -g aggressive-resize on
# history
set-option -g history-limit 100000
# vim mode
setw -g mode-keys vi
# resize window
unbind-key j
unbind-key k
unbind-key h
unbind-key l
bind-key -r C-j resize-pane -D 5
bind-key -r C-k resize-pane -U 5
bind-key -r C-h resize-pane -L 20
bind-key -r C-l resize-pane -R 20
# handling mouse
#set-option -ga terminal-override ',rxtv-uni*:XT:Ms=\E]52;%p1%s;%p2%s\007'
set-window-option -g mode-mouse on
set -g mouse-select-pane on
set -g mouse-select-window on
# window switch
bind-key C-a last-window
# Set window notifications
setw -g monitor-activity on
set -g visual-activity on
# Automatically set window title
setw -g automatic-rename
# smart pane switching with awareness of vim splits
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
bind -n C-\ run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys 'C-\\') || tmux select-pane -l"
## COLORS
# Solarized theme
# default statusbar colors
set-option -g status-bg white #base2
set-option -g status-fg yellow #yellow
set-option -g status-attr default
# default window title colors
set-window-option -g window-status-fg brightyellow #base00
set-window-option -g window-status-bg default
#set-window-option -g window-status-attr dim
# active window title colors
set-window-option -g window-status-current-fg brightred #orange
set-window-option -g window-status-current-bg default
#set-window-option -g window-status-current-attr bright
# pane border
set-option -g pane-border-fg white #base2
set-option -g pane-active-border-fg brightcyan #base1
set-option -g pane-border-bg white #base2
set-option -g pane-active-border-bg brightcyan #base1
# message text
set-option -g message-bg white #base2
set-option -g message-fg brightred #orange
# pane number display
set-option -g display-panes-active-colour blue #blue
set-option -g display-panes-colour brightred #orange
# clock
set-window-option -g clock-mode-colour green #green
set -g @yank_selection "primary"
" vim:fdm=marker
"
" INSTALLATION INSTRUCTIONS:
"
" First, place this file in ~/.vimrc
" Then,before to start vim the first time, run the following command:
" (without the " character, that is the mark for comment)
"$ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
" It will install your plugin manager.
" Then run `mkdir -p ~/.vim/{backup,tmp}`
" Finally, when running vim for the first time, type :PlugInstall
filetype off
" Authors: http://vim.wikia.com/wiki/Vim_on_Freenode, Romain Endelin
" Description: A minimal, but feature rich, example .vimrc.
"------------------------------------------------------------
" Plugin {{{1
"
" These options and commands enable some very useful features in Vim, that
" no user should have to live without.
" Set 'nocompatible' to ward off unexpected things that your distro might
" have made, as well as sanely reset options when re-sourcing .vimrc
set nocompatible
" Attempt to determine the type of a file based on its name and possibly its
" contents. Use this to allow intelligent auto-indenting for each filetype,
" and for plugins that are filetype specific.
call plug#begin('~/.vim/plugged')
" Plugins {{{1
" Smart line numbering
Plug 'myusuf3/numbers.vim'
" Beautiful status bar
Plug 'bling/vim-airline'
" Python mode
Plug 'klen/python-mode', {'for': 'python'}
" enables solarized colors on vim
Plug 'altercation/vim-colors-solarized'
" Improved commentaries
Plug 'tpope/vim-commentary'
" Enables custom repetition
Plug 'tpope/vim-repeat'
" git integration in vim
Plug 'tpope/vim-fugitive'
call plug#end()
filetype indent plugin on
" Enable syntax highlighting
syntax on
set backup
set backupdir=~/.vim/backup
set directory=~/.vim/tmp
"------------------------------------------------------------
" Must have options {{{1
"
" These are highly recommended options.
" Vim with default settings does not allow easy switching between multiple files
" in the same editor window. Users can use multiple split windows or multiple
" tab pages to edit multiple files, but it is still best to enable an option to
" allow easier switching between files.
"
" One such option is the 'hidden' option, which allows you to re-use the same
" window and switch from an unsaved buffer without saving it first. Also allows
" you to keep an undo history for multiple files when re-using the same window
" in this way. Note that using persistent undo also lets you undo in multiple
" files even in the same window, but is less efficient and is actually designed
" for keeping undo history after closing Vim entirely. Vim will complain if you
" try to quit without saving, and swap files will keep you safe if your computer
" crashes.
set hidden
" Note that not everyone likes working this way (with the hidden option).
" Alternatives include using tabs or split windows instead of re-using the same
" window as mentioned above, and/or either of the following options:
" set confirm
" set autowriteall
" Better command-line completion
set wildmenu
set wildignore+=*.swp,*.swo
set wildignore+=*.pdf
set wildignore+=*.pyc
set wildignore+=*.jpg,*.bmp,*.gif
set wildignore+=*.o,*.dll,*.obj,*.exe
" Show partial commands in the last line of the screen
set showcmd
" Highlight searches (use <C-L> to temporarily turn off highlighting; see the
" mapping of <C-L> below)
set hlsearch
set incsearch
set showmatch
" better copy and paste
set clipboard=unnamed
" fold by syntax
set foldmethod=syntax
" smarter split
set splitbelow
set splitright
" set encoding
set encoding=utf-8
" Modelines have historically been a source of security vulnerabilities. As
" such, it may be a good idea to disable them and use the securemodelines
" script, <http://www.vim.org/scripts/script.php?script_id=1876>.
" set nomodeline
"------------------------------------------------------------
" Usability options {{{1
"
" These are options that users frequently set in their .vimrc. Some of them
" change Vim's behaviour in ways which deviate from the true Vi way, but
" which are considered to add usability. Which, if any, of these options to
" use is very much a personal preference, but they are harmless.
" Use case insensitive search, except when using capital letters
set ignorecase
set smartcase
" Allow backspacing over autoindent, line breaks and start of insert action
set backspace=indent,eol,start
" When opening a new line and no filetype-specific indenting is enabled, keep
" the same indent as the line you're currently on. Useful for READMEs, etc.
set autoindent
" set 5 lines under the cursor, at the bottom of the screen, for easier
" reading
set scrolloff=5
" Stop certain movements from always going to the first character of a line.
" While this behaviour deviates from that of Vi, it does what most users
" coming from other editors would expect.
set nostartofline
" Display the cursor position on the last line of the screen or in the status
" line of a window
set ruler
" Always display the status line, even if only one window is displayed
set laststatus=2
" Instead of failing a command because of unsaved changes, instead raise a
" dialogue asking if you wish to save changed files.
set confirm
" Use visual bell instead of beeping when doing something wrong
set visualbell
" And reset the terminal code for the visual bell. If visualbell is set, and
" this line is also included, vim will neither flash nor beep. If visualbell
" is unset, this does nothing.
set t_vb=
" Enable use of the mouse for all modes
set mouse=a
" Set the command window height to 2 lines, to avoid many cases of having to
" "press <Enter> to continue"
set cmdheight=2
" Display line numbers on the left
set number
" Quickly time out on keycodes, but never time out on mappings
set notimeout ttimeout ttimeoutlen=200
" Use <F11> to toggle between 'paste' and 'nopaste'
set pastetoggle=<F11>
"------------------------------------------------------------
" Indentation options {{{1
"
" Indentation settings according to personal preference.
" Indentation settings for using 2 spaces instead of tabs.
" Do not change 'tabstop' from its default value of 8 with this setup.
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set shiftround
" Indentation settings for using hard tabs for indent. Display tabs as
" two characters wide.
"set shiftwidth=2
"set tabstop=2
" Help respect the 80 characters rule in python
au FileType python setlocal textwidth=80
au FileType python setlocal colorcolumn=80
"------------------------------------------------------------
" Mappings {{{1
"
" Useful mappings
" Map <C-L> (redraw screen) to also turn off search highlighting until the
" next search
nnoremap <C-L> :nohl<CR>
" Use jj as a shortcut to <ESC>
inoremap jj <ESC>
" wrap lines visually but not hard wrap
set wrap
" only smart break at break characters (.,:)
set linebreak
set nolist
" q: allow formatting of comments
" r: carry the current comment forward on next line
" n: smart indent on lists (when wrapping in an item)
" l: no automatic linebreak
set formatoptions=qrnl
" remap for better line wrapping
nnoremap j gj
vnoremap j gj
nnoremap k gk
vnoremap k gk
" reselect visual block after indent
vnoremap > >gv
vnoremap < <gv
vnoremap = =gv
" in case I use buffers
nnoremap <Leader><Leader> <C-^>
"------------------------------------------------------------
"Plugin config {{{1
" vim-airline
let g:airline_powerline_fonts=0
let g:airline_exclude_preview=1
let g:powerline_loaded=1
" Numbers.vim
nnoremap <F3> :NumbersToggle<CR>
" Python mode
let g:pymode_run = 0
let g:pymode_warnings = 0
let g:pymode_rope = 0
let g:pymode_lint_write = 0
let g:pymode_lint_ignore = "C0103"
let g:pymode_lint_cwindow = 0
" vim-solarized
set t_Co=256
let g:solarized_termcolors=256
set background=dark
colorscheme solarized
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment