Thursday, September 09, 2010

tmux and vim configuration

I’ve now been on tmux for quite a few months since migrating from screen.

aterm + tmux + zsh + vim makes a super command-line combination.

But there can be certain issues with the key bindings with vim. Since moving to tmux I’ve avoided using vim tabs since I couldn’t figure out the right key bindings to switch them using C-PgUp and C-PgDn when in tmux. But today with a little help on #tmux and kerneltrap I finally got things working. So here are my .tmux and .vimrc files for posterity.

# start a new session on tmux att if no existing session is running new  # screen prefix key set -g prefix C-a  # large history set-option -g history-limit 100000  # swap on C-a C-a bind-key C-a last-window bind-key k confirm-before kill-window bind-key r source-file ~/.tmux.conf bind-key v split-window -h #similar to vim's vsplit bind-key h split-window  set-option -g default-terminal "screen-256color"  # status bar customisation set-option -g status-bg default set-option -g status-fg green  # highlight status bar on activity set -g visual-activity on  # change foreground-background for the current window setw -g window-status-current-attr reverse setw -g monitor-activity on  # for vim setw -g xterm-keys on  # load average, battery, and date + time set -g status-right "#[fg=magenta] #(cat /proc/loadavg|awk '{print

$1 \“ \” $2 \“ \” $3}‘) #(acpi|awk ’{print $4;}‘) #[fg=cyan]%d-%m


# put the programs to start by default here # one $SHELL is always started at 0  # todo/bugtracker neww -n yokadi -t 10 yokadi  # focus on first window select-window -t 0  set status-left-attr reverse


syntax enable filetype on filetype indent on filetype plugin on  " Fast editing of the .vimrc map e :e! ~/.vim_runtime/vimrc  " When vimrc is edited, reload it autocmd! bufwritepost .vimrc source ~/.vimrc  " indent related set backspace=indent,eol,start set smarttab set expandtab set sw=4 set tabstop=4 set softtabstop=4  " other view settings, some redundant set t_Co=256 set number set autoindent set smartindent set showcmd set showmatch set ruler set tw=0 set hlsearch set incsearch set magic  " I don't like swap files set noswapfile :highlight Pmenu ctermbg=238 ctermfg=white gui=bold  " for tmux set mouse=a set ttymouse=xterm  " following taken from set hidden runtime macros/matchit.vim set wildmenu set wildmode=list:longest set title set visualbell  "mappings " fast saves " fast quit " and tag/tree toggling :nmap  :w :nmap  :wall :map  :qall :map  :TlistToggle :map  :NERDTreeToggle :map  :FuzzyFinderFile  :let NERDTreeQuitOnOpen = 1  " ignore case when searching :set ignorecase " but if any character is typed uppercase, respect the case :set smartcase  :set wildignore=*.o,*.pyc set completeopt=menuone,menu,longest,preview  :set scrolloff=8  :set wm=4  " use ack instead of grep for vimgrep :set grepprg=ack  " abbreviations " useful iab xauthor Nikhil Marathe <> iab xdate =strftime("%d/%m/%y %H:%M:%S")  let g:GetLatestVimScripts_allowautoinstall=1  " Tell vim to remember certain things when we exit "  '10 : marks will be remembered for up to 10 previously edited files "  "100 : will save up to 100 lines for each register "  :20 : up to 20 lines of command-line history will be remembered "  % : saves and restores the buffer list "  n... : where to save the viminfo files set viminfo='10,\"100,:20,%,n~/.viminfo  " when we reload, tell vim to restore the cursor to the saved position augroup JumpCursorOnEdit au! autocmd BufReadPost * \ if expand(":p:h") !=? $TEMP | \ if line("'\"") > 1 && line("'\"") <= line("$") | \ let JumpCursorOnEdit_foo = line("'\"") | \ let b:doopenfold = 1 | \ if (foldlevel(JumpCursorOnEdit_foo) >

foldlevel(JumpCursorOnEdit_foo – 1)) |

\ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 | \ let b:doopenfold = 2 | \ endif | \ exe JumpCursorOnEdit_foo | \ endif | \ endif " Need to postpone using "zv" until after reading the modelines. autocmd BufWinEnter * \ if exists("b:doopenfold") | \ exe "normal zv" | \ if(b:doopenfold > 1) | \ exe "+".1 | \ endif | \ unlet b:doopenfold | \ endif augroup END  :runtime! ftplugin/man.vim  vnoremap  * :call VisualSearch('f') vnoremap  # :call VisualSearch('b')  " Smart way to move btw. windows map  j map  k map  h map  l  " Allow Ctrl+PgUp/PgDn in tmux set t_kN=[6;*~ set t_kP=[5;*~  " reduce vi compatibility for more usefult stuff set nocp

Posted via email from nikhil's posterous

No comments:

Post a Comment