+++ /dev/null
-.netrwhist
-viminfo*
+++ /dev/null
-" Commenting of lines! Stolen & modified from vim.org's ToggleCommentify
-map <C-_> :call ToggleCommentify()<CR>j
-imap <C-_> <ESC>:call ToggleCommentify()<CR>j
-" The nice thing about these mapping is that you don't have to select a visual
-" block to comment ... just keep the CTRL-key pressed down and tap on 'c' as
-" often as you need.
-
-function! ToggleCommentify()
- let lineString = getline(".")
- if strlen(lineString) == 0
- " don't comment empty lines
- return
- endif
-
- let isCommented = strpart(lineString,0,3)
- let commentSymbol = ''
-
- let commentMapping = {
- \'###': [
- \'conf',
- \'debsources',
- \'exports',
- \'fstab',
- \'make',
- \'mplayerconf',
- \'muttrc',
- \'perl',
- \'procmail',
- \'python',
- \'readline',
- \'ruby',
- \'screen',
- \'sh',
- \'sshconfig',
- \'sudoers',
- \'terminfo',
- \'vrml',
- \'xf86conf',
- \],
-\
- \'///': [
- \'c',
- \'cpp',
- \'java',
- \'javascript',
- \'objc',
- \'ox',
- \'php',
- \'groovy',
- \],
-\
- \'"""': [
- \'vim',
- \],
-\
- \'!!!': [
- \'xdefaults',
- \],
-\
- \'%%%': [
- \'matlab',
- \'tex',
- \],
-\
- \'---': [
- \'sql',
- \'haskell',
- \]
- \}
-
- for commentChar in keys(commentMapping)
- for name in commentMapping[commentChar]
- if &filetype == name
- let commentSymbol = commentChar
- endif
- endfor
- endfor
-
- if commentSymbol == ''
- execute 'echo "ToggleCommentify has not (yet) been implemented for the file-type " . &filetype'
- else
- if isCommented == commentSymbol
- " if the line is already commented, uncomment
- call UnCommentify(commentSymbol)
- else
- " if the line is uncommented, comment
- call Commentify(commentSymbol)
- endif
- endif
-endfunction
-
-function! Commentify(commentSymbol)
- execute ':s+^+'.a:commentSymbol.'+'
- nohlsearch
-endfunction
-
-function! UnCommentify(commentSymbol)
- execute ':s+'.a:commentSymbol.'++'
- nohlsearch
-endfunction
-
+++ /dev/null
-" Pretty syntax highlighting
-syntax on
-
-" Show the line/column positions at the bottom
-set ruler
-
-" Display as much as possible of the last line of text
-" (instead of displaying an @ character)
-set display+=lastline
-
-" Wrapping is annoying
-set nowrap
-
-" If wordwrap is on, don't split words across lines
-set linebreak
-
-" String to put at the start of lines that have been wrapped
-"set showbreak=+
-set showbreak=
-
-" Display current mode and partially typed commands
-set showmode
-set showcmd
-
-" When a bracket is inserted, briefly jump to the matching one (
-set showmatch
-
-" Show the filename title in xterms
-set title
-set t_ts=\e]0;
-set t_fs=\a
-
-" Make the autocompletion of filenames,etc behave like bash
-set wildmode=longest,list
-
-" Allow splits to have 0 height (use C-W _)
-set wmh=0
-
-" Always keep one line of context around the cursor
-set scrolloff=1
-
-" Match search results as you type
-set incsearch
-
-" Ignore case when searching
-set ignorecase
-
-" Ignore the ignorecase character if search contains uppercase chars
-set smartcase
-
-" Highlight search terms
-set hlsearch
-
-" Mouse options
-set mouse=a
-set mousehide
-
+++ /dev/null
-" Make vim aware of filetypes, this loads files in
-" vimdir/{ftplugin,indent}/lang.vim
-" where vimdir is /usr/share/vim/vimXX/ or ~/.vim/
-" The intention is for vim to set up sensible indentation rules and other
-" settings depending on the filetype.
-filetype plugin indent on
-
-" Pick up some filetypes from their extensions
-autocmd BufNewFile,BufRead *.txt setlocal ft=text
-autocmd BufNewFile,BufRead mutt* setlocal ft=mail
-autocmd BufNewFile,BufRead *.tex setlocal ft=tex
-autocmd BufNewFile,BufRead CMakeLists.txt setlocal ft=cmake
-autocmd BufNewFile,BufRead buildfile setlocal ft=ruby
-autocmd BufNewFile,BufRead build.gradle setlocal ft=groovy
-
-" Set options based on filetypes, overriding the filetype plugin/indent options
-autocmd FileType text call WrapOn()
-autocmd FileType markdown call WrapOn()
-autocmd FileType bib setlocal textwidth=78 nocindent smartindent
-autocmd FileType mail setlocal textwidth=0
-autocmd FileType mail call WrapOn()
-autocmd FileType tex call WrapOn()
-autocmd FileType objc setlocal nocindent smartindent
-autocmd FileType cmake setlocal nowrap
-autocmd FileType vim setlocal formatoptions-=r
-
-" Don't allow syntax/sh.vim to change my iskeyword setting
-let g:sh_noisk=1
-
-" Who uses octal anyway?
-set nrformats-=octal
-
-" Don't automatically continue comments on new lines
-"""autocmd BufNewFile,BufRead * setlocal formatoptions-=r
-
-" Use space for indendation in some files
-" autocmd BufNewFile,BufRead /path/to/someproject setlocal expandtab tabstop=8 softtabstop=4 shiftwidth=4
-
+++ /dev/null
-" Indentation
-
-" Automatically continue indentation across lines
-set autoindent
-" Keep indentation structure (tabs, spaces, etc) when autoindenting.
-set copyindent
-
-" Expand tab to spaces
-set expandtab
-" Size of a \t
-set tabstop=8
-" Delete this many space chars when pressing backspace
-set softtabstop=4
-set shiftwidth=4
-
-" < and > will hit indentation levels instead of adding/subtracting shiftwidth
-set shiftround
-
-" Single indent for line continuations
-set cinoptions=+1s
-set cinoptions=(1s
-let g:pyindent_open_paren = &sw
-let g:pyindent_continue = &sw
-let g:vim_indent_cont = &sw
-
-" Single space after full stop
-set nojoinspaces
-
-" Use :retab to change the file to entirely space indents
-" Use :retab! to change the file to entirely tab indents
-
+++ /dev/null
-" Function key mappings
-map <F8> :call ToggleSpelling()<CR>
-imap <F8> <C-o>:call ToggleSpelling()<CR>
-map <F9> :call InvShow()<CR>
-imap <F9> <C-o>:call InvShow()<CR>
-map <F10> :call WrapToggle()<CR>
-imap <F10> <C-o>:call WrapToggle()<CR>
-map <F11> :call PasteToggle()<CR>
-imap <F11> <C-o>:call PasteToggle()<CR>
-
-" Unhighlight search results and redraw the screen
-nmap <C-l> :nohlsearch<CR>:redraw!<CR>
-
-" Map Y to be consistent with D, C, etc
-nmap Y y$
-
-" CTRL-n and CTRL-p to go forwards and backwards through files
-nmap <C-n> :next<CR>
-nmap <C-p> :prev<CR>
-
-" CTRL-J/K to move up and down, collapsing open windows
-map <C-J> <C-W>j<C-W>_
-map <C-K> <C-W>k<C-W>_
-
-" Press CTRL-z after pasting something to fix up formatting
-imap <C-z> <ESC>u:set paste<CR>.:set nopaste<CR>i
-
-" Tab to switch between split windows
-nmap <Tab> <C-w><C-w>
-nmap <Esc>[Z <C-w>W
-
-" Q to reformat paragraph. I never use ex mode anyway (default binding for Q)
-nmap Q gwip
-
-" Save using sudo
-command SudoWrite call SudoWriteFunction()
-
-" I frequently type :Q or :WQ, etc instead of :q, :wq
-command WQA :wqa
-command WqA :wqa
-command WQa :wqa
-command Wqa :wqa
-command WA :wa
-command Wa :wa
-command WQ :wq
-command Wq :wq
-command W :w
-command Wn :wn
-command WN :wn
-command Wp :wp
-command WP :wp
-command QA :qa
-command Qa :qa
-command Q :q
-
-" Make the number pad work
-map \eOX =
-imap \eOX =
-set t_KC=\eOp " 0
-set t_KD=\eOq " 1
-set t_KE=\eOr " 2
-set t_KF=\eOs " 3
-set t_KG=\eOt " 4
-set t_KH=\eOu " 5
-set t_KI=\eOv " 6
-set t_KJ=\eOw " 7
-set t_KK=\eOx " 8
-set t_KL=\eOy " 9
-
-" Toggle wordwrap
-function WrapToggle()
- if &wrap
- call WrapOff()
- echo "Word wrap off"
- else
- call WrapOn()
- echo "Word wrap on"
- endif
-endfunction
-
-" Turn word wrap off, reset arrows, home, end, etc to default bindings
-function WrapOff()
- setlocal nowrap
- " Go up and down by physical linebreaks when not wordwrapped
- iunmap <buffer> <End>
- iunmap <buffer> <Home>
- iunmap <buffer> <Down>
- iunmap <buffer> <Up>
- nunmap <buffer> <Down>
- nunmap <buffer> <Up>
- nunmap <buffer> <End>
- nunmap <buffer> <Home>
- nunmap <buffer> 0
- nunmap <buffer> ^
- nunmap <buffer> $
- vunmap <buffer> <Down>
- vunmap <buffer> <Up>
- vunmap <buffer> <End>
- vunmap <buffer> <Home>
- vunmap <buffer> 0
- vunmap <buffer> ^
- vunmap <buffer> $
- " Allow only backspace & space
- set whichwrap=b,s
-endfunction
-
-" Turn word wrapping on and bind arrows, home, end, etc to display lines
-function WrapOn()
- setlocal wrap
- " Go up and down by display lines, not linebreaks when wordwrapped
- imap <buffer> <End> <C-o>g$
- imap <buffer> <Home> <C-o>g0
- imap <buffer> <Down> <C-o>gj
- imap <buffer> <Up> <C-o>gk
- nmap <buffer> <Down> gj
- nmap <buffer> <Up> gk
- nmap <buffer> <End> g$
- nmap <buffer> <Home> g0
- nmap <buffer> 0 g0
- nmap <buffer> ^ g^
- nmap <buffer> $ g$
- vmap <buffer> <Down> gj
- vmap <buffer> <Up> gk
- vmap <buffer> <End> g$
- vmap <buffer> <Home> g0
- vmap <buffer> 0 g0
- vmap <buffer> ^ g^
- vmap <buffer> $ g$
- " Allow backspace, space, left/right keys to move across lines
- set whichwrap=b,s,<,>,[,]
-endfunction
-
-
-" Toggle show invisible characters
-function InvShow()
- if &list
- echo "Invisible characters off"
- set nolist
- else
- echo "Invisible characters on"
- set listchars=tab:.\ ,trail:!
- set list
- endif
-endfunction
-
-
-" Spell checking mode toggle
-function ToggleSpelling()
- if !exists("s:spell_check") || s:spell_check == 0
- echo "Spell check on"
- let s:spell_check = 1
- setlocal spell spelllang=en_au
- else
- echo "Spell check off"
- let s:spell_check = 0
- setlocal spell spelllang=
- endif
-endfunction
-
-
-" Save using sudo
-function SudoWriteFunction()
- :w !sudo tee %
- :e!
-endfunction
-
-" Toggle paste mode
-function PasteToggle()
- if &paste
- set nopaste
- echo "Paste mode disabled"
- else
- set paste
- echo "Paste mode enabled"
- endif
-endfunction
-
+++ /dev/null
-" Keep viminfo
-set viminfo=%,'100,\"100,:100,n~/.vim/viminfo
-
-" Vim jumps to the last position when reading a file
-au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g'\"" | endif
-
-" Keep history
-set history=100
-
-" Make a backup (i. e. 'file~') and save it.
-set backup
-" create ~/tmp/vimbak if it doesn't exist and use it to save the backups
-if has("unix")
- if !isdirectory(expand("~/tmp/vimbak/."))
- !mkdir -p ~/tmp/vimbak
- endif
- set backupdir=~/tmp/vimbak
-endif
-
-" Create backups by copying files to backup directory instead of renaming
-set backupcopy=yes
-
-" Use modelines
-set modelines=5
-
-" Don't try to be like vi
set nocompatible
+set backspace=indent,eol,start
-" Backspace should work across lines
-set bs=2
-
-" Read files from ~/.vim
-source ~/.vim/state.vim
-source ~/.vim/display.vim
-source ~/.vim/indent.vim
-source ~/.vim/macros.vim
-source ~/.vim/commenter.vim
-source ~/.vim/filetypes.vim
-if filereadable(expand("~/.vim/local.vim"))
- source ~/.vim/local.vim
-endif
+
+set backup
+set backupdir=~/tmp/vimbak
+set backupcopy=yes
+silent exec "!mkdir -p ~/tmp/vimbak"
+silent exec "!find ~/tmp/vimbak -type f -mtime +3 -delete"
+
+
+syntax on
+filetype plugin indent on
+
+" restore position when opening files
+autocmd BufReadPost *
+ \ if line("'\"") >= 1 && line("'\"") <= line("$") && &ft !~# 'commit'
+ \ | exe "normal! g`\""
+ \ | endif
+
+" don't automatically continue comments on new lines
+autocmd BufNewFile,BufRead * setlocal formatoptions-=r
+
+
+" xterm mouse
+set mouse=a
+
+" xterm titles
+set title
+set t_ts=\e]0;
+set t_fs=\a
+
+
+" show useful things on the status line
+set showmode
+set showcmd
+set ruler
+
+" display as much as possible of the last line, instead of @
+set display+=lastline
+
+" matching brackets
+set showmatch
+
+" auto-complete should work like bash
+set wildmode=longest,list
+
+" show one extra line when scrolling
+set scrolloff=1
+
+" decent searching
+set incsearch
+set ignorecase
+set smartcase
+set hlsearch
+
+
+" decent indentation
+set autoindent
+set copyindent
+set shiftround
+
+" spaces over tabs
+set expandtab
+set tabstop=8
+set softtabstop=4
+set shiftwidth=4
+
+" single indent for line continuations
+set cinoptions=+1s
+set cinoptions=(1s
+let g:pyindent_open_paren = &sw
+let g:pyindent_continue = &sw
+let g:vim_indent_cont = &sw
+
+" don't allow syntax/sh.vim to change my iskeyword setting
+let g:sh_noisk=1
+
+" single space after full stop
+set nojoinspaces
+
+" disable octal
+set nrformats-=octal
+
+
+nmap <C-n> :next<CR>
+nmap <C-p> :prev<CR>
+
+nmap <C-l> :nohlsearch<CR>:redraw!<CR>
+
+command SudoWrite call SudoWriteFunction()
+
+map <F8> :call ToggleSpelling()<CR>
+imap <F8> <C-o>:call ToggleSpelling()<CR>
+map <F9> :call InvShow()<CR>
+imap <F9> <C-o>:call InvShow()<CR>
+map <F10> :call WrapToggle()<CR>
+imap <F10> <C-o>:call WrapToggle()<CR>
+map <F11> :call PasteToggle()<CR>
+imap <F11> <C-o>:call PasteToggle()<CR>
+
+
+function ToggleSpelling()
+ if !exists("s:spell_check") || s:spell_check == 0
+ echo "Spell check on"
+ let s:spell_check = 1
+ setlocal spell spelllang=en_au
+ else
+ echo "Spell check off"
+ let s:spell_check = 0
+ setlocal spell spelllang=
+ endif
+endfunction
+
+function WrapToggle()
+ if &wrap
+ set nowrap
+ echo "Word wrap off"
+ else
+ set wrap
+ echo "Word wrap on"
+ endif
+endfunction
+
+function InvShow()
+ if &list
+ echo "Invisible characters off"
+ set nolist
+ else
+ echo "Invisible characters on"
+ set listchars=tab:.\ ,trail:!
+ set list
+ endif
+endfunction
+
+function SudoWriteFunction()
+ :w !sudo tee %
+ :e!
+endfunction
+
+function PasteToggle()
+ if &paste
+ set nopaste
+ echo "Paste mode disabled"
+ else
+ set paste
+ echo "Paste mode enabled"
+ endif
+endfunction
+
+
+" typos
+command WQA :wqa
+command WqA :wqa
+command WQa :wqa
+command Wqa :wqa
+command WA :wa
+command Wa :wa
+command WQ :wq
+command Wq :wq
+command W :w
+command Wn :wn
+command WN :wn
+command Wp :wp
+command WP :wp
+command QA :qa
+command Qa :qa
+command Q :q
```
cd
mkdir -p backup
-mv .bash .bash_profile .bashrc .gitconfig .inputrc .pythonrc.py .screenrc .vim .vimrc backup/
+mv .bash .bash_profile .bashrc .gitconfig .inputrc .pythonrc.py .screenrc .vimrc backup/
```
Symlink the config files into your home directory:
```
-ln -sf ~/.dotfiles/{.bash,.bash_profile,.bashrc,.gitconfig,.inputrc,.pythonrc.py,.screenrc,.vim,.vimrc} ~/
+ln -sf ~/.dotfiles/{.bash,.bash_profile,.bashrc,.gitconfig,.inputrc,.pythonrc.py,.screenrc,.vimrc} ~/
ln -sf ~/.dotfiles/.gitignore_global ~/.gitignore
ln -sf ~/.dotfiles/.ssh/config ~/.ssh/
```