Author Topic: Post your .vimrc file.  (Read 4302 times)

0 Members and 1 Guest are viewing this topic.

Offline Amarok

  • Thread Starter
  • Posts: 206
  • Location: Phoenix, AZ
Post your .vimrc file.
« on: Wed, 13 March 2013, 23:24:01 »
I know a lot of people here use VIM for many different things, so I thought it might be kind of cool to see how everybody has it set up. There's so many neat things you can have in a .vimrc file, so I'm constantly finding and adding new things to mine. Post yours!

Code: [Select]
" Necessary for lots of cool Vim things
set nocompatible

" Show what you're typing as a command
set showcmd

" Necessary for syntax highlightling
filetype on
filetype plugin on
syntax enable

" Autoindent
set autoindent

" Set tab widths
set shiftwidth=4
set softtabstop=4
set tabstop=4

" Tab completion stuff
set wildmenu
set wildmode=list:longest,full

" Enable mouse support in the console
set mouse=a

" Display line numbers
set number

" Set smartcase
set smartcase

" Highlight things found using search
set hlsearch

" Remove buffer when a tab is closed
set nohidden

" Decide which colorscheme to use based on if in GUI vs console
if has("gui_running")
colorscheme jellybeans
" Hide the toolbar in GUI mode
set guioptions-=T
" Set the font
set guifont=Inconsolata\ 11
else
colorscheme default
endif

" Show matching brackets blocks
set showmatch

" Do smart case matching
set smartcase

" Show the line number on the status bar
set ruler

" Don't redraw when it's not necessary
set lazyredraw

" Keep 5 lines above and below the cursor
set scrolloff=5

" Keep at least 3 lines to the left and right of the cursor
set sidescrolloff=3

" Allow up to 1000 undos
set undolevels=1000

" Automatically cd into the directory that the file is in
autocmd BufEnter * execute "chdir ".escape(expand("%:p:h"), ' ')

" Remove any trailing whitespace that is in the file
autocmd BufRead,BufWrite * if ! &bin | silent! %s/\s\+$//ge | endif

" Restore cursor position to where it was before
augroup JumpCursorOnEdit
   au!
   autocmd BufReadPost *
            \ if expand("<afile>: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
Realforce 87u 55g

Offline quickcrx702

  • Posts: 214
  • Location: Hell
  • Ready to bomb with Vietnam tatted on my back
Re: Post your .vimrc file.
« Reply #1 on: Thu, 14 March 2013, 00:13:21 »
Maybe I'm just lazy, but I use nano(crappy I know) for console editing, and geany for a full featured gui app in Linux.  With Windows I just use notepad++.  I tried to get into vim and emacs, but it seems like you have to dedicate way too much time learning to use properly.  In your opinion, is it worth the time to learn vs just using geany or notepad++?  Just curious if I'm really missing out because of my laziness LOL.

Offline hashbaz

  • Grand Ancient One
  • * Moderator Emeritus
  • Posts: 5057
  • Location: SF Bae Area
Re: Post your .vimrc file.
« Reply #2 on: Thu, 14 March 2013, 00:57:29 »
If you edit text for a living then it's absolutely worth putting the time into optimizing your workflow.  That said a lot of people love notepad++, so *shrug*.  I would suggest giving vim or emacs two weeks of daily use and see how you feel at that point.  They both have excellent tutorials that will get you used to the basics quickly.

As for my vim config ... it is a hopelessly janky mess so I'll spare you guys.  I do love the following plugins though:

* CamelCase motion (provides text objects for deleting/copying/correcting parts of camelCaseText)
* buff explorer (fast and helpful buffer list)
* alternate files (jump from .h to .cpp, etc.)
* vimacs (many of emacs' keybindings for insert and ex modes -- don't hate)

Offline daerid

  • Posts: 4276
  • Location: Denver, CO
    • Rossipedia
Re: Post your .vimrc file.
« Reply #3 on: Thu, 14 March 2013, 13:59:22 »
Oh man, I dunno.. it's pretty big.

Offline daerid

  • Posts: 4276
  • Location: Denver, CO
    • Rossipedia
Re: Post your .vimrc file.
« Reply #4 on: Thu, 14 March 2013, 14:02:33 »
This doesn't include the 32 bundles I have installed in ~/.vim/bundle either.

Code: [Select]
" My Personal Vim settings
" Maintainer: Bryan Ross <bryanjamesross@gmail.com>
"

"
" Who wants compatible? Yuck...
"
set nocompatible

"
" Some default settings
"
set shiftwidth=2
set tabstop=2
set smarttab
set showtabline=1
set number
set cursorline
set encoding=utf-8
set scrolloff=5
set cindent
set smartindent
set autoindent
set expandtab
set nolist
set ignorecase
set smartcase
set wildmenu
set showmode
set incsearch
set hlsearch
set virtualedit=block
set nowrap

"
" Need to handle mac fileformats because of Flash, grrrr...
"
set ffs=unix,dos,mac

"
" Highlight dos files in red in status line
"
hi User9 term=reverse cterm=bold ctermbg=12 gui=bold guibg=Red

"
" Custom Status Line
"
set laststatus=2
set statusline=
set statusline+=%-3.3n
set statusline+=\[%{strlen(&ft)?&ft:'none'}]
set statusline+=\ %F
set statusline+=\ %9*%{&ff=='unix'?'':&ff.'\ format'}%*
set statusline+=%#warningmsg#
set statusline+=%{fugitive#statusline()}
set statusline+=%*
set statusline+=%=
set statusline+=0x%-8B
set statusline+=LINE\:\ %-6l\ CHAR\:\ %-6c\ COL\:\ %-6v
set statusline+=%<%P

"
" Syntastic
"
let g:syntastic_enable_signs=1
let g:syntastic_auto_loc_list=1

"
" Set height of command line, and show last cmd executed
"
set showcmd
set cmdheight=2


"
" Gah, can't stand these backup files. These lines disable them
"
set nobackup
set nowritebackup
set noswapfile

"
" Turn ~ into an operator (switch case)
"
set tildeop

"
" Enter key clears search
"
nnoremap <CR> :nohlsearch<CR>

"
" mapleader
"
let mapleader=","

"
" Pathogen!
"
runtime bundle/vim-pathogen/autoload/pathogen.vim
call pathogen#infect()

"
" Enable filetype indenting and plugins
"

filetype indent on
filetype plugin on
syntax on
set synmaxcol=3000

"
" Handle buffer switching
"
set switchbuf+=useopen
set switchbuf+=usetab
set hidden



"
" Fix Backspace
"
set backspace=indent,eol,start

"
" Map to set CWD to file being edited
"
map \lcd :lcd %:p:h<CR>

"
" Add a new line with Shift-Enter
"
nnoremap <silent><S-CR> <Esc>i<CR><Esc>


"
" Convenience mappings for running make and make clean
"
nmap <silent> \mm :wa<CR>:make<CR>
nmap <silent> \mc :wa<CR>:make clean<CR>


"
" Handle our gui settings
"  - Font, color, size, etc...
"
if has("gui_running")

  colorscheme ir_black

  " basic sizing
  set lines=50
  " Gui options: hide scrolling, menubar, tabbar, etc
  set guioptions=ehi
  " Show only file name on tab
  set guitablabel=%t

  "
  " Set font based on the type of gui we're using
  "
  if has("gui_gtk2")
    if has("win32unix")
      " Cygwin
      set gfn=Consolas\ 11
    else
      " Linux, probably
      set gfn=Source\ Code\ Pro\ 9
    endif
  elseif has("gui_win32")
    " Win32/64 GVim
    set gfn=Liberation_Mono:h8
    " set gfn=Consolas:h10
    set columns=160
    set lines=65
  elseif has("gui_macvim")
    " MacVim
    set gfn=Liberation\ Mono:h14
  else
    echo "Unknown GUI system!!!!"
  endif

  "
  " Show or hide the menu bar with Control-F11
  "
  nmap <silent> <C-F11> :if &guioptions=~'m' \| set guioptions-=m \| else \| set guioptions+=m \| endif<CR>

  "
  " Disable the visual bell
  "
  set vb t_vb=
else
  set t_Co=256
  if &t_Co == 256
    colorscheme ir_black
  endif
endif

"
" Python Stuff
"

"
" Hide Bike Exceptions
"
let g:bike_exceptions = 0

"
" Highlight all python syntax items
"
let python_highlight_all = 1

"
" Runs the current buffer as python script, and sets the filetype of the
" buffer to be python
"
function! RunPythonBuffer()
  pclose!
  setlocal filetype=python
  silent %y a | below new | silent put a | silent %!python -
  setlocal previewwindow ro nomodifiable nomodified
  winc p
endfunction

command! RunPyBuffer call RunPythonBuffer()
map \py :RunPyBuffer<cr>


"
" Buffer handling:
"   Control-K goes to next buffer
"   Control-J goes to previous buffer
"   \ba Clears out up to 1000 buffers (probably overkill, but oh well)
"   \bd Deletes the current buffer
"
nmap <silent> <C-j> :bprevious<cr>
nmap <silent> <C-k> :bnext<cr>
nmap <silent> \ba :1,1000bd!<cr>
nmap <silent> \bd :bd!<cr>


"
" Maps for ctrl-f (search) and ctrl-v (replace) in visual mode
"
function! GetVisual() range
  let reg_save = getreg('"')
  let regtype_save = getregtype('"')
  let cb_save = &clipboard
  set clipboard&
  normal! ""gvy
  let selection = escape(getreg('"'),'/\.*$^~[')
  call setreg('"', reg_save, regtype_save)
  let &clipboard = cb_save
  return selection
endfunction

vmap <C-H> <Esc>:%s/<c-r>=GetVisual()<cr>/
vmap <C-F> <Esc>/<c-r>=GetVisual()<cr><cr>

"
" Trim Trailing spaces on save
"
function! FnTrimTrailing()
  let savepos = getpos(".")
  %s/\s\+$//g
  nohl
  call setpos(".", savepos)
endfunction

function! FnFileTypeTrim()
  if &filetype != 'mkd'
    call FnTrimTrailing()
  endif
endfunction

command! TrimTrailing silent! call FnFileTypeTrim()
autocmd FileWritePre * :TrimTrailing
autocmd FileAppendPre * :TrimTrailing
autocmd FilterWritePre * :TrimTrailing
autocmd BufWritePre * :TrimTrailing

"
" Show trailing spaces
"
set listchars=tab:»·,trail:·

"
" Some customizations for ZenCoding
"
let g:user_zen_settings = {
      \  'php' : {
      \    'extends' : 'html',
      \    'filters' : 'c',
      \  },
      \  'xml' : {
      \    'extends' : 'html',
      \  },
      \  'mako' : {
      \    'extends' : 'html',
      \  }
      \}


"
" Convenience functions for handling leading tabs/spaces
"
command! -range=% -nargs=0 Tab2Space execute "silent! <line1>,<line2>s/^\\t\\+/\\=substitute(submatch(0), '\\t', repeat(' ', ".&ts."), 'g')" | nohls | redraw
command! -range=% -nargs=0 Space2Tab execute "silent! <line1>,<line2>s/^\\( \\{".&ts."\\}\\)\\+/\\=substitute(submatch(0), ' \\{".&ts."\\}', '\\t', 'g')" | nohls | redraw

"
" NERD_Commenter Defaults
"
let NERDSpaceDelims=1

"
" Use /* */ instead of // for PHP (personal preference)
"
let g:NERD_php_alt_style=1

"
" Map Control J/K to navigate command history
"
cmap <C-J> <Down>
cmap <C-K> <Up>

"
" Twiddle Case!
"
function! TwiddleCase(str)
  if a:str ==# toupper(a:str)
    let result = tolower(a:str)
  elseif a:str ==# tolower(a:str)
    let result = substitute(a:str,'\(\<\w\+\>\)', '\u\1', 'g')
  else
    let result = toupper(a:str)
  endif
  return result
endfunction
vnoremap <silent> ~ ygv"=TwiddleCase(@")<CR>Pgv


function! DoReformat(l1, l2)
  execute a:l1.",".a:l2."g/./normal gqq"
  nohlsearch
  redraw
endfunction

command! -range=% -nargs=0 Reformat call DoReformat(<line1>, <line2>)
map <silent> \r :Reformat<CR>


" Hex mode
nnoremap <C-H> :Hexmode<CR>
inoremap <C-H> <Esc>:Hexmode<CR>
vnoremap <C-H> :<C-U>Hexmode<CR>

command -bar Hexmode call ToggleHex()

function! ToggleHex()
  " hex mode should be considered a read-only operation
  " save values for modified and read-only for restoration later,
  " and clear the read-only flag for now
  let l:modified=&mod
  let l:oldreadonly=&readonly
  let &readonly=0
  let l:oldmodifiable=&modifiable
  let &modifiable=1
  if !exists("b:editHex") || !b:editHex
    " save old options
    let b:oldft=&ft
    let b:oldbin=&bin
    " set new options
    setlocal binary " make sure it overrides any textwidth, etc.
    let &ft="xxd"
    " set status
    let b:editHex=1
    " switch to hex editor
    %!xxd
  else
    " restore old options
    let &ft=b:oldft
    if !b:oldbin
      setlocal nobinary
    endif
    " set status
    let b:editHex=0
    " return to normal editing
    %!xxd -r
  endif
  " restore values for modified and read only state
  let &mod=l:modified
  let &readonly=l:oldreadonly
  let &modifiable=l:oldmodifiable
endfunction

" autocmds to automatically enter hex mode and handle file writes properly
if has("autocmd")
  " vim -b : edit binary using xxd-format!
  augroup Binary
    au!

    " set binary option for all binary files before reading them
    au BufReadPre *.bin,*.hex setlocal binary

    " if on a fresh read the buffer variable is already set, it's wrong
    au BufReadPost *
          \ if exists('b:editHex') && b:editHex |
          \   let b:editHex = 0 |
          \ endif

    " convert to hex on startup for binary files automatically
    au BufReadPost *
          \ if &binary | Hexmode | endif

    " When the text is freed, the next time the buffer is made active it will
    " re-read the text and thus not match the correct mode, we will need to
    " convert it again if the buffer is again loaded.
    au BufUnload *
          \ if getbufvar(expand("<afile>"), 'editHex') == 1 |
          \   call setbufvar(expand("<afile>"), 'editHex', 0) |
          \ endif

    " before writing a file when editing in hex mode, convert back to non-hex
    au BufWritePre *
          \ if exists("b:editHex") && b:editHex && &binary |
          \  let oldro=&ro | let &ro=0 |
          \  let oldma=&ma | let &ma=1 |
          \  silent exe "%!xxd -r" |
          \  let &ma=oldma | let &ro=oldro |
          \  unlet oldma | unlet oldro |
          \ endif

    " after writing a binary file, if we're in hex mode, restore hex mode
    au BufWritePost *
          \ if exists("b:editHex") && b:editHex && &binary |
          \  let oldro=&ro | let &ro=0 |
          \  let oldma=&ma | let &ma=1 |
          \  silent exe "%!xxd" |
          \  exe "set nomod" |
          \  let &ma=oldma | let &ro=oldro |
          \  unlet oldma | unlet oldro |
          \ endif
  augroup END
endif

Offline Amarok

  • Thread Starter
  • Posts: 206
  • Location: Phoenix, AZ
Re: Post your .vimrc file.
« Reply #5 on: Thu, 14 March 2013, 14:05:08 »
Awesome, I'm gonna have to go through that later today. I bet there's lots of good gems in there.
Realforce 87u 55g

Offline OrangeJewce

  • ssk.ℜ
  • Posts: 495
  • Location: Minnesota
  • King of the Jewce
Re: Post your .vimrc file.
« Reply #6 on: Thu, 14 March 2013, 15:37:11 »
Awesome, I'm gonna have to go through that later today. I bet there's lots of good gems in there.

THIS AIN'T RUBY!

jp. <3

Cheers,
IBM Model M 1390120, Otaku Unicomp+RGB, CM QFR Green, Ducky YOTD Red, SSK MKII,
ErgoDox Blue, ErgoDox White

Offline lutherus

  • Posts: 7
Re: Post your .vimrc file.
« Reply #7 on: Mon, 18 March 2013, 11:58:42 »
So here is mine, nothing special

Code: [Select]
" = :: =========================================================== :: =
"  Filename: /home/lutherus/.vimrc
"  Filesize: 13459 Bytes on 461 Lines
"   Purpose: My personal vim configuration file
"    Author: lutherus
"   License: License? uhm, this is a config file; do with it what ever you want!
"   Created: 26.11.2004 18:20 CET (+0100)
"  Modified: 28.04.2011 13:01 CET (+0100)
"   Version: VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Dec  2 2010 10:44:11)
" = :: =========================================================== :: =



" = :: = Esentiallies ===================================== {{{1 = :: =

if version < 700
    echomsg "Your Vim is somewhat out of date, thus"
echomsg "update your Editor or don't use this ~/.vimrc"
finish
endif

set all&
set nocompatible
" set textwidth=0 " Don't wrap
set textwidth=72        " see formatoptions and :h fo-table

set encoding=utf-8
"autocmd!

" = :: = Variables ======================================== {{{1 = :: =

" - :: - 2html.vim Setup ---------------------------------- {{{2 - :: -

    let g:html_use_css        = 1
    let g:html_use_xhtml      = 1
    unlet g:html_use_xhtml
    let g:html_number_lines   = 1
    let g:html_ignore_folding = 1
    let g:html_hover_unfold   = 0
    unlet g:html_hover_unfold
    let g:html_use_encoding = "UTF-8"

" - :: - Spell check Setup -------------------------------- {{{2 - :: -

    let g:spellfile_url = 'http://ftp.vim.org/pub/vim/runtime/spell'
    let g:SpellLangList = [ "nospell", "de_20", "de_19", "en_us" ]
    language messages C

" - :: - BufExplorer Setup -------------------------------- {{{2 · :: -

    let g:bufExplorerDefaultHelp      = 0  " Do not show default help.
    let g:bufExplorerDetailedHelp     = 0
    let g:bufExplorerShowRelativePath = 1  " Show relative paths.
    let g:bufExplorerSplitRight       = 1  " Split right.
    let g:bufExplorerSplitVertical    = 1  " Split vertically.
    let g:bufExplorerUseCurrentWindow = 1  " Open using current window.

" - :: - MiniBufExplorer Setup ---------------------------- {{{2 - :: -

let g:miniBufExplVSplit = 20

" - :: - Miscellaneous ------------------------------------ {{{2 - :: -

    let g:BKUPDIR=expand("~/.vim/bkup")
let g:SWPDIR=expand("~/.vim/swap/")
    let loaded_matchparen = 1
    let mapleader=","
    let g:tex_flavor = "latex" " :h ft-tex-plugin
    let g:loadFileHeaderPlugin = 0

" = :: = File Format, Backup & Swapfile Settings ========== {{{1 = :: =

filetype plugin indent on

if filewritable(BKUPDIR) == 2
set backup
let &backupdir=BKUPDIR
else
set nobackup
endif

if filewritable(SWPDIR) == 2
let &directory=SWPDIR " See `:h dir` and the 'Variables' section in this file for explanation
set swapfile
set updatecount=150
set updatetime=7500
endif

set viminfo='25
set vi+=<0
set vi+=:75
set vi+=@75
set vi+=h
set vi+=n~/.vim/viminfo

set history=75

" = :: = Read, Write Permissions ========================== {{{1 = :: =

set noautoread      " don't automatically read files if they changed outside vim
set noautowrite     " don't automatically write files on ':next, :rewind, :last, ...'
set noautowriteall  " like autowrite, but also used for ':edit, :quit, :exit, ...'

set secure

" = :: = Display Settings ================================= {{{1 = :: =

set showcmd          " Show (partial) command in the last line of the screen.
set showmode         " Display current Modus ( --INSERT --, --REPLACE--, ... )
set report=0         " Show _always_ hints about new/changed/deleted Lines
set ruler            " Show the line and column number of the cursor position
set laststatus=2     " Show _always_ the statusline
"set statusline=[%n]%r%m%-25.25(%y[%{&ff}][%{&fenc}]%)%-40.40(%F%)%<%=[%03.3c,%04.4l]\ (%3P)
set statusline=[%n]%m[%03.3c,%04.4l]%r%-25.25(%y[%{&ff}][%{&fenc}]%)%-40.40(%F%)%<%=(%3P)
set cmdheight=1      " Number of screen lines to use for the command-line.
set helpheight=0     " Minimal initial height of the help window
set scrolloff=2      " Keep (at least) 2 screen lines above/below the cursor
set display=lastline " Display much as possible of the last line
"set linespace=2     " Number of pixel lines to use between characters
set cursorline       " Highlight the screen line of the cursor
set shortmess=a      " a=filmnrwx
set shm+=I           " Start without the intro message
set shm+=s           " Suppress 'search hit BOTTOM, continuing at TOP' message
set shm+=tT          " Truncate long filenames/messages
set shm+=oO          " Overwrite some status messages
"set shm+=A           " get rid off the „ATTENTION“ message when a swap file is found

set warn             " Warning when a shell cmd is used while the buffer has been changed.

set nolist           " Show special chars defined by 'listchars'
                     " Notice the the toggle (function) keys in the
                     " mapping section below.
set listchars=tab:×·
set lcs+=trail:←
set lcs+=eol:$
set lcs+=extends:»
set lcs+=precedes:«
set lcs+=nbsp:¬

set nowrap           " wrap lines longer than windowwidth
set linebreak
set breakat=\ \ !;:,.?
set showbreak=\:\:\ »\
set sidescroll=1     " min. number of columns to scroll horizontally.
set sidescrolloff=2  " min. number of columns to keep to the left/right of the cursor

set wrapmargin=0     " Chars from the right window border where wrapping starts

set noerrorbells     " Shut up!
set novisualbell     " Don't flicker!
set t_vb=            " Holy ..., be quite!

" = :: = Window Settings ================================== {{{1 = :: =

set splitbelow
set splitright

" = :: = Completion Settings ============================== {{{1 = :: =

set wildmenu
set wildmode=full
set wildignore+=*.ps
set wig+=*.dvi
set wig+=*.toc
set wig+=*.swp
set wig+=*~

set suffixes+=.pdf
set su+=.aux

" = :: = Tabstop Settings ================================= {{{1 = :: =

set tabstop=4        " ???
set shiftwidth=4     " ???
set expandtab
set shiftround       " ???

"set smartindent
"set softtabstop=4

" = :: = Motion Settings ================================== {{{1 = :: =

set whichwrap=<,>,~,[,]
set backspace=eol,start,indent
set esckeys           " Use cursor keys in Insert Mode
set virtualedit=block " only in Visual Block Mode
set nostartofline     " keep the cursor in the same column

" = :: = Mouse Settings =================================== {{{1 = :: =

set mouse=a
nmap <MiddleMouse> <Nop>
set selectmode=mouse

" = :: = Folding Settings ================================= {{{1 = :: =

set foldmethod=marker
set foldenable

" = :: = Search Settings ================================== {{{1 = :: =

set magic
set wrapscan
set ignorecase
set smartcase
set nohlsearch
set incsearch

" = :: = Printer Settings ================================= {{{1 = :: =

set printheader=%<%F%h%m%=Page\ %N
set printfont=terminus:h11
set printoptions=paper:A4
set popt+=syntax:n
set popt+=jobsplit:y
set popt+=number:y
set popt+=header:2
set popt+=wrap:y
set popt+=duplex:off
set popt+=collate:y

" = :: = Syntax Highlighting ============================== {{{1 = :: =

syntax on

colorscheme miromiro

" = :: = Format Settings ================================== {{{1 = :: =

set noautoindent      " ??? (complex)
set nosmartindent     " ??? (complex)
set nocindent         " ??? (complex)
set nocopyindent      " ??? (complex)

" set formatoptions=tcq " vim standard
" set fo+=r             " insert comment leader after hitting enter
" set fo+=n             " recognize numbered lists
" set fo+=1             " don't break a line after a one-letter word

" set formatoptions=tcq " vim standard
set fo-=t               " Don't auto-wrap text using textwidth

"set formatlistpat=^\s*\d\+[\]:.)}\t ]\s*  " vim standard

set nojoinspaces      " don't insert spaces after '.,?!' with <J>

set switchbuf=usetab,newtab

" = :: = Miscellaneous settings =========================== {{{1 = :: =

set hidden
set ttyfast
set nolazyredraw
set modeline
set modelines=3
set notitle

" = :: = Mappings ========================================= {{{1 = :: =

" - :: - Comments in VISUAL MODE -------------------------- {{{2 - :: -
" Im Visual Mode mehrere Zeilen markieren, dann das gewünschte
" Kommentarzeichen dücken.
" :let @/=""  löscht den letzten Suchbegriff, also den Zeilenanfang
" ansonsten ist bei :set hlsearch in der ganzen Datei der Zeilenan-
" fang hervorgehoben!

vmap # :s/^/# <CR>:let @/=""<CR>
vmap " :s/^/" /<CR>:let @/=""<CR>
vmap % :s/^/% /<CR>:let @/=""<CR>
vmap / :s/^/\/\/ /<CR>:let @/=""<CR>
vmap ; :s/^/; /<CR>:let @/=""<CR>
vmap ! :s/^/! /<CR>:let @/=""<CR>
" und hier löscht man die Kommentarzeichen wieder
vmap - :s/^[#"%\/;!]*<SPACE>//<CR>:let @/=""<CR>

" - :: - Function Keys ------------------------------------ {{{2 - :: -

nmap <F1> :help <C-R>=expand("<cword>")<CR><CR>

map <F2> <ESC>:setlocal hlsearch! <bar> set hlsearch?<CR>
imap <F2> <C-O>:setlocal hlsearch!<CR>

map <F3> <ESC>:setlocal wrap! <bar> set wrap?<CR>
imap <F3> <C-O>:setlocal wrap!<CR>

map <F4> <ESC>:setlocal list! <bar> set list?<CR>
imap <F4> <C-O>:setlocal list!<CR>

map <F5> <ESC>:setlocal number! <bar> set number?<CR>
imap <F5> <C-O>:setlocal number!<CR>

map <F6> <ESC>:setlocal foldenable! <bar> set foldenable?<CR>
imap <F6> <C-O>:setlocal foldenable!<CR>

map <F7> <ESC>:setlocal cursorline! <bar> set cursorline?<CR>

map <F8> <ESC>:call ToggleColorColumne()<CR>

map <F9> <ESC>:call ToggleSpellLang()<CR>
imap <F9> <C-O>:call ToggleSpellLang()<CR>


set pastetoggle=<F12>



" - :: - Misc Mappings ------------------------------------ {{{2 - :: -

map S O#<ESC>a<SPACE>=<SPACE>::<SPACE><ESC>60a=<ESC><CR><ESC>0k9lR

nmap + <C-W>+
nmap - <C-W>-
nmap <S-LEFT> 10<C-W><
nmap <S-RIGHT> 10<C-W>>

nmap <LEADER>e :Texplore<CR>
nmap <LEADER>E :Sexplore<CR>
nmap <LEADER>tn :tabnew<SPACE>
nmap <LEADER>tc :tabclose<CR>

nmap :W :w
nmap :Q :q

nmap <LEADER>HI :so $VIMRUNTIME/syntax/hitest.vim
nmap <LEADER>sv :so ~/.vimrc<CR>

map <LEADER>tm <esc>:r!date +\%R<CR>
map <LEADER>dt <esc>:r!date +'\%A, \%d.\%B \%Y  \%k:\%M'<CR>

nmap <LEADER>s <esc>:%s/ *$//g<CR>
nmap <LEADER>S <esc>:%s/ *$//g<CR>

nmap <LEADER>m <PLUG>MiniBufExplorer
nmap <LEADER>c <PLUG>CMiniBufExplorer

nnoremap j gj
nnoremap k gk
nnoremap Q gq

" = :: = Abbreviations ==================================== {{{1 = :: =

ca hitest so $VIMRUNTIME/syntax/hitest.vim

iab hrul = :: =========================================================== :: =
iab teh the

iab -today- <esc>:r!date \+'\%c'<CR>kJA<esc>

" = :: = Autocommands ===================================== {{{1 = :: =

augroup zsh
autocmd!
autocmd BufNewFile,BufRead ~/zsh/*.zsh setlocal ft=zsh
augroup END

augroup note
autocmd!
autocmd BufNewFile,BufRead /tmp/sartoo-1000/notes/* setlocal tw=72 fo+=t
augroup END

augroup html
autocmd!
" autocmd BufNewFile,BufRead *.html setlocal wrap linebreak matchpairs+=<:>
    autocmd FileType html,xhtml setlocal fo-=t fo-=c
autocmd FileType html,php,css source ~/.vim/html.vim
augroup END

augroup mutt
autocmd!
autocmd BufNewFile,BufRead ~/.mutt/*.muttrc setlocal ft=muttrc
augroup END

augroup mail
autocmd!
" autocmd FileType mail setlocal spell spelllang=de_de
" Das meiste erledigt `ftplugin/mail.vim´
autocmd BufNewFile,BufRead /tmp/*/mutt-* setlocal comments=n:>,fb:- tw=72 ts=8 sw=8 sts=0 et
"   Entferne leere Kommentarzeilen aus den Mails, also sowas mag ich
"   nicht in meinen Mails:
"   > blabla
"   >
"   >> weiteres blablb
autocmd BufRead /tmp/*/mutt-* normal :g/^> -- $/,/^$/-1d<CR><C-L>gg
"   in der muttrc wird vim so aufgerufen: set editor="/usr/bin/vim -c '+/^Subject:'
augroup END

augroup tex
autocmd!
autocmd BufNewFile *.tex 0r ~/documents/templates/skel.tex
autocmd BufNewFile,BufRead ~/*.tex setlocal tw=80
augroup END

autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
autocmd BufNewFile ~/*.bwb setlocal ft=txt wrap linebreak expandtab list cursorline
autocmd BufNewFile ~/*.bwb 0r ~/.vim/templates/bwb.tmp
autocmd BufNewFile ~/*.bwb retab

" autocmd! FileType vo_base colorscheme 256-sartoo

" = :: = Functions ======================================== {{{1 = :: =

func! ToggleSpellLang()
if !exists("b:SpellLang")
let b:SpellLang = 0
endif

let b:SpellLang = b:SpellLang + 1

if b:SpellLang >= len(g:SpellLangList)
let b:SpellLang = 0
setlocal nospell
endif

if b:SpellLang > 0
setlocal spell
setlocal nohls
let &spelllang=g:SpellLangList[b:SpellLang]
endif

echo "language:" g:SpellLangList[b:SpellLang]
endfunc

func! ToggleColorColumne()
    if !exists("b:ColCol")
        let b:ColCol = 0
    endif
    if b:ColCol == 0
        setlocal colorcolumn=+2
        let b:ColCol = 1
        echo "set Colorcolumn"
    else
        setlocal colorcolumn=
        let b:ColCol = 0
        echo "unset Colorcolumn"
    endif

endfunc

" :help :abbreviate-local 14k
func Eatchar(pat)
    let c = nr2char(getchar(0))
    return (c =~ a:pat) ? '' : c
endfunc


" = :: = Plugins ========================================== {{{1 = :: =

runtime! ftplugin/man.vim

filetype plugin indent on
set grepprg=grep\ -nH\ $*
let g:tex_flavor = "latex"

Offline gvfarns

  • Posts: 34
Re: Post your .vimrc file.
« Reply #8 on: Thu, 21 March 2013, 22:23:19 »
My main issue is that I don't like hitting shift before colon commands, so use semicolon--saves a lot of time and mistakes.  Also I have escape and caps lock switched at the OS level.  With those two changes, vim becomes incredible.

Code: [Select]
:set nocompatible " don't try and be compatible with vi
:syntax on " highlight syntax by default
:set showmatch " show matching parenthesis
:set shiftwidth=2  " how many spaces does a tab occupy
:set expandtab " convert tabs to spaces
":set foldmethod=indent  " fold based on indentation
:set ruler  " display cursor position always
:set mousemodel=popup
:highlight Normal guibg=black guifg=green
:set hls " highlight search
":set autoindent " let next line indention match this one
:set incsearch " start searching as soon as I start typing
:set cryptmethod=blowfish " use good encryption if I want it

" let ; be : in normal mode
:nnoremap ; :
:nnoremap : <nop>

" let ; be : in visual mode
:vnoremap ; :
:vnoremap : <nop>

" here we remap CTRL-J and CTRL-K to page up and down
" I just find this more intuitive than CTRL-F and CTRL-B
:nnoremap <C-j> <C-F>
:nnoremap <C-k> <C-B>

Offline hashbaz

  • Grand Ancient One
  • * Moderator Emeritus
  • Posts: 5057
  • Location: SF Bae Area
Re: Post your .vimrc file.
« Reply #9 on: Fri, 22 March 2013, 02:48:27 »
My main issue is that I don't like hitting shift before colon commands, so use semicolon--saves a lot of time and mistakes.  Also I have escape and caps lock switched at the OS level.  With those two changes, vim becomes incredible.

Do you not use , and ; for jumping to the next/previous t/f match?  If you don't use t and f (i.e., to jump to the next instance of a character in the current line), you're missing out on one of vim's hugest wins over all other editors.

Offline gvfarns

  • Posts: 34
Re: Post your .vimrc file.
« Reply #10 on: Fri, 22 March 2013, 14:03:30 »
My main issue is that I don't like hitting shift before colon commands, so use semicolon--saves a lot of time and mistakes.  Also I have escape and caps lock switched at the OS level.  With those two changes, vim becomes incredible.

Do you not use , and ; for jumping to the next/previous t/f match?  If you don't use t and f (i.e., to jump to the next instance of a character in the current line), you're missing out on one of vim's hugest wins over all other editors.

I do use t and f but I don't use ; or , to repeat those searches--I typically use t and f only when deleting or changing between the current position and the match.  If I want to move to a character that is farther away than the next match, I use / and  n.   I use colon commands far more often than I use t or f, so it's a good trade in my opinion.
« Last Edit: Fri, 22 March 2013, 14:05:37 by gvfarns »

Offline nar

  • Posts: 254
  • Location: Tokyo
Re: Post your .vimrc file.
« Reply #11 on: Sat, 23 March 2013, 00:18:28 »
Here is my vimpusher profile, the github link to my vimrc and all the plugins I use are on there.

http://www.vimpusher.com/naruyan

On that note, for a bit of self-advertising. If you've ever used Source Insight and want the context window, check out SrcExpl, I wrote the docs and did a few patches to the plugin myself :p
Keyboards: Topre HE0100 | REALFORCE 103UB & 104UB-DK | FILCO Majestouch 2 Ai Cherry MX Blue | CHERRY G84-4101SPAUS

Offline iri

  • Posts: 998
  • Location: England
Re: Post your .vimrc file.
« Reply #12 on: Sat, 23 March 2013, 13:59:36 »
now i know daerid's first name, lolz

i have different vimrc's on different machines, this is the shortest one with the least number of comments in russian.

Code: [Select]
syntax on
set guioptions-=T
set guioptions-=m
set guioptions-=r
set guioptions-=e

set guifont=Monospace\ 10

set novisualbell

set expandtab

set backspace=indent,eol,start

set history=999

set incsearch
set ignorecase

set hlsearch

" Scroll when cursor gets within 3 characters of top/bottom edge
set scrolloff=4

set shiftwidth=4
set softtabstop=4
set tabstop=4

" Round indent to multiple of 'shiftwidth' for > and < commands
set shiftround
set autoindent

set wrap

set linebreak

set smartindent
" Show (partial) commands (or size of selection in Visual mode) in the status line
set showcmd


" Write swap file to disk after every 50 characters
set updatecount=50

" Remember things between sessions
"
" '20 - remember marks for 20 previous files
" \"50 - save 50 lines for each register
" :20 - remember 20 items in command-line history
" % - remember the buffer list (if vim started without a file arg)
" n - set name of viminfo file
set viminfo='20,\"50,:20,%,n~/.viminfo


set ruler
set number
set hidden


" Go back to the position the cursor was on the last time this file was edited
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")|execute("normal `\"")|endif

map ,s :w<cr>

" exit vim without saving any changes
map ,q :q<cr>

" exit vim saving changes
map ,w :x<cr>

nmap ,b :BufExplorer<cr>
vmap ,b :BufExplorer<cr>

map ,d :tabp<cr>
map ,f :tabn<cr>

" map and to paste below/above and reformat
nnoremap P P'[v']=
nnoremap p p'[v']=

let Tlist_Inc_Winwidth = 1
let Tlist_Exit_OnlyWindow = 0
let Tlist_File_Fold_Auto_Close = 1
let Tlist_Process_File_Always = 1
let Tlist_Enable_Fold_Column = 0
let tlist_php_settings = 'php;c:class;d:constant;f:function'
let Tlist_Show_One_File = 1
let Tlist_Sort_Type = "name"

set tags=./tags,tags
au VimLeave * :mksession! ~/ide.session

" visual shifting (does not exit Visual mode)
vnoremap < >gv

" page down with <space>
nmap <space> <pagedown>
nmap <c-u> <pageup>

imap {<cr> {<cr>}<esc>O

" F2 - saving
nmap <f2> :w<cr>
vmap <f2> <esc>:w<cr>i
imap <f2> <esc>:w<cr>i

nmap <silent> <f4> :!ctags -f %:p:h/tags --langmap="php:+.inc" -h ".php.inc" -R --totals=yes --tag-relative=yes --PHP-kinds=+cf-v %:p:h<cr>

" F6 - предыдущий буфер
map <f6> :bp<cr>
vmap <f6> <esc>:bp<cr>i
imap <f6> <esc>:bp<cr>i
" F7 - следующий буфер
map <f7> :bn<cr>
vmap <f7> <esc>:bn<cr>i
imap <f7> <esc>:bn<cr>i

" F10 - delete buffer
map <f10> :bd<cr>
vmap <f10> <esc>:bd<cr>
imap <f10> <esc>:bd<cr>

" F11 - Taglist
map <f11> :TlistToggle<cr>
vmap <f11> <esc>:TlistToggle<cr>
imap <f11> <esc>:TlistToggle<cr>

" F12 - file browser
map <f12> :Ex<cr>
vmap <f12> <esc>:Ex<cr>i
imap <f12> <esc>:Ex<cr>i

(...)Whereas back then I wrote about the tyranny of the majority, today I'd combine that with the tyranny of the minorities. These days, you have to be careful of both. They both want to control you. The first group, by making you do the same thing over and over again. The second group is indicated by the letters I get from the Vassar girls who want me to put more women's lib in The Martian Chronicles, or from blacks who want more black people in Dandelion Wine.
I say to both bunches, Whether you're a majority or minority, bug off! To hell with anybody who wants to tell me what to write. Their society breaks down into subsections of minorities who then, in effect, burn books by banning them. All this political correctness that's rampant on campuses is b.s.

-Ray Bradbury

Offline gvfarns

  • Posts: 34
Re: Post your .vimrc file.
« Reply #13 on: Mon, 25 March 2013, 13:23:12 »
Ok, you guys have inspired me.  Over the last few days I've done a ton of research on vim and I think I have my vimrc the way I really like it.  The only non-stock plugin I use is r-plugin (I use R constantly).  I use tabs fairly frequently as well.  My default terminal has a black background and green letters, which works well with the colors I have here.

The finished product (with pretty good commenting, for your reading pleasure):

Code: [Select]
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""'
" Standard settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""'
:set nocompatible          " don't try and be compatible with vi
:syntax enable             " load syntax highlighting
:syntax on                 " highlight syntax by default
:set showmatch             " show matching parenthesis
:set shiftwidth=2          " how many spaces does a tab occupy
:set expandtab             " convert tabs to spaces
:set ruler                 " display cursor position always
:set hlsearch              " highlight search
:set incsearch             " start searching as soon as I start typing
:set cryptmethod=blowfish  " use good encryption if I want it
:set history=1000          " remember a longer history of commands and patterns
:set wildmode=list:longest " for file completion, show list
:set title                 " set the xterm's title to show file
:set sidescrolloff=5       " scroll before I get to right edge
:set sidescroll=1          " scroll by 1 at edge
:filetype on               " turn on filetype detection
:filetype plugin on        " load plugins by filetype
:filetype indent on        " indent based on filetype
:set shortmess=atITO       " abbreviate some of the warning verbosity
:set bs=2                  " allow backspacing over everything
:set nowrap                " don't wrap by default
:set gdefault              " assume global for regex substitutions
:set nostartofline         " try to preserve column when moving
:set nohidden              " don't leave unsaved buffers hidden
:set cursorline            " underline current line
:set showcmd               " show commands while I enter them
:set wildmenu              " show options when using wildcard to select files (etc.)                                                                                                                               
:set foldminlines=99999    " really prevent folding, even in diff mode
:set diffopt+=foldcolumn:0 " don't add foldcolumn in diff mode

" never syntax highlight text files
:let g:ft_ignore_pat = '\.\(Z\|gz\|bz2\|zip\|tgz\|txt\)$'

" file types to ignore in wildcards (we never edit these)
:set wildignore=.git,*.o,*.a,.la,*.so,*.obj,*.swp,*.jpg,*.png,*.xpm,*.gif,*.pdf,*.Rdata,*.rda

" these I may open, but infrequently enough that it's worth ignoring them in wildcard
:set wildignore+=*.log,*.aux,*.bbl,*.LOG,*.bib,*.bst

" don't assume a line after a comment is also a comment
:autocmd FileType * setlocal formatoptions-=c
:autocmd FileType * setlocal formatoptions-=r
:autocmd FileType * setlocal formatoptions-=o

" remove comment char when joining comment lines
:autocmd FileType * setlocal formatoptions+=j

" open help in new tab instead of splitting screen
:cabbrev help tab help

" open new files with e in new tabs
:cabbrev e tabnew

"""""""""""""""""""""""""""""""""""""""""""""""""""""
" settings that may depend on whether this is a diff
"""""""""""""""""""""""""""""""""""""""""""""""""""""
if &diff
  :set nonumber              " no numbering in vimdiff
  :set norelativenumber      " also disable relative numbering
  " fix colors with control l
  :noremap <c-l> :diffupdate<cr>:redraw!<cr>
  " keep windows equal sized when window is resized                                                                                                             
  :autocmd VimResized * wincmd =
else
  :set relativenumber        " enables relative line numbers (love them)
  :set numberwidth=2         " we don't need 3 spaces for relative numbers
  " fix colors with control l
  :noremap <c-l> :syntax sync fromstart<cr>:redraw!<cr>
endif

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" R plugin stuff (http://www.vim.org/scripts/script.php?script_id=2628)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" don't use screen
:let vimrplugin_screenplugin = 0

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Colors
"
" see http://vim.wikia.com/wiki/Xterm256_color_names_for_console_Vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" default scheme. Inherits fg and bg from terminal.  I use green on black
:colorscheme default

" change line number color to something less obtrusive
:highlight LineNr         ctermfg=243

" give cursorline a dark grey background
:highlight CursorLine     cterm=NONE ctermbg=232
:highlight CursorLineNr   cterm=NONE ctermbg=232 ctermfg=grey

" don't make tabline fill reverse (too loud)
:highlight TabLineFill    cterm=underline ctermfg=Green                                                                                                                                                           

" make non-current tabs less obtrusive
:highlight TabLine        cterm=underline ctermbg=16 ctermfg=Green

" highlight current tab
:highlight TabLineSel     cterm=bold ctermbg=Green ctermfg=16

" diff colors (I keep it simple...red background for changes)
:highlight DiffAdd        cterm=bold ctermfg=yellow ctermbg=DarkRed
:highlight DiffText       cterm=bold ctermfg=yellow ctermbg=DarkRed
:highlight DiffDelete     ctermfg=0 ctermbg=0
:highlight DiffChange     ctermbg=16

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Disable certain functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" used to try to execute some crap to look stuff up
:nnoremap K <nop>

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Custom Mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Clear search with enter
:nnoremap <CR> :nohlsearch<CR>

" let ; be : in normal mode
:noremap ; :

" let CTRL-j and CTRL-k to they page up and down
" the 1000 is so it works even with a large screen
:noremap <C-k> 1000<C-U>
:noremap <C-j> 1000<C-D>

" I prefer to go to beginning and end of line using these
" because I can easily move to top of page using relative numbering
:noremap H ^
:noremap L $

" Shift-tab to insert a hard tab
:imap <silent> <S-tab> <C-v><tab>

" when indenting, keep selection for more indenting
:vnoremap < <gv
:vnoremap > >gv

" toggle numbers (turn them off for copy/paste with mouse)
:nnoremap N :set invrelativenumber<cr>

" shorter command to cycle through tabs
:nnoremap T gt

« Last Edit: Tue, 26 March 2013, 15:36:14 by gvfarns »

Offline daerid

  • Posts: 4276
  • Location: Denver, CO
    • Rossipedia
Re: Post your .vimrc file.
« Reply #14 on: Tue, 26 March 2013, 09:53:24 »
now i know daerid's first name, lolz

*shrug* Figured most did, I've been on here long enough