" Set nocompatible mode set nocompatible " Windows-like keybindings and settings source $VIMRUNTIME/mswin.vim startinsert set mouse=a "set insertmode "set hidden " Make cursor keys ignore wrapping inoremap =pumvisible() ? "\Down>" : "\C-O>gj" inoremap =pumvisible() ? "\Up>" : "\C-O>gk" " Basic UI settings colorscheme desert set history=100 set confirm set ruler set showcmd set number set nowrap set wildmenu set wildmode=longest,full "set showmatch " Searching set ignorecase set smartcase set incsearch set hlsearch " Indentation set autoindent set smartindent set expandtab set smarttab set tabstop=4 set softtabstop=4 set shiftwidth=4 " Filetype detection and syntax highlighting filetype plugin indent on syntax on " Highlight current line highlight cursorline cterm=none ctermbg=black gui=none guibg=grey30 autocmd InsertLeave * setlocal nocursorline autocmd InsertEnter * setlocal cursorline " Set file encoding automagically (use enca) function! GetEncoding(f) let e = system('enca -Pe "' . a:f . '"') let e = substitute(e, '/.*', '', '') if e =~ 'unknown' return 'utf-8' endif return e endfunc autocmd BufReadPre * exec "set fileencodings=" . GetEncoding(expand('')) " Tab completion function! CleverTab(command) if strpart(getline('.'), 0, col('.')-1) =~ '^\s*$' if a:command == 'next' return "\" elseif a:command == 'prev' return "\" endif else if a:command == 'next' return "\" elseif a:command == 'prev' return "\" endif endif endfunction inoremap inoremap =CleverTab('next') inoremap =CleverTab('prev') " (Un)comment selection function! ToggleComment(CommentLeader, CommentTrailer) let hls = @/ if getline(".") =~ a:CommentLeader execute ":s/^\\(\\s*\\)" . a:CommentLeader . "/\\1/" execute ":s/" . a:CommentTrailer . "$//" else execute ":s/^\\(\\s*\\)/\\1" . a:CommentLeader . "/" execute ":s/$/" . a:CommentTrailer . "/" endif let @/ = hls endfunction vnoremap :call ToggleComment('### ', '') autocmd FileType c vnoremap :call ToggleComment('\/\/ ', '') autocmd FileType php vnoremap :call ToggleComment('\/\/ ', '') autocmd FileType python vnoremap :call ToggleComment('# ', '') autocmd FileType sh vnoremap :call ToggleComment('# ', '') autocmd FileType html vnoremap :call ToggleComment('') " (Un)indent selection function! Indenter(IndentChar) normal gv execute "normal " . a:IndentChar normal gv endfunction vnoremap :call Indenter(">") vnoremap :call Indenter("<") " Intelligent End key (from Cream) function! Cream_motion_home() " Original Concept: http://www.derwok.de/downloads/index.html " get current column let oldcol = col('.') " go to first non-white normal g^ " get current column, new let newcol = col('.') " if already were at first-non-white, toggle if (oldcol == newcol) " if we're on the first line, stop, otherwise toggle if (&wrap == 1) && (newcol > Cream_linewidth()) " stop else execute "normal gI\" let lastcol = col('.') " already were at first col? if (newcol == lastcol) " fix being stuck on second column if a one character line if (newcol == oldcol) " terminate, ensure at beginning normal i else " toggle back to first non-white normal g^ endif else " toggle to first col execute "normal gI\" endif endif endif endfunction inoremap :call Cream_motion_home() vnoremap :call Cream_motion_home() " ESC toggle normal/insert mode... broken :-( "nnoremap :startinsert " Keybindings (like Windows, Nano, Konqueror, etc.) inoremap dd nnoremap dd inoremap P nnoremap P inoremap / nnoremap / inoremap n nnoremap n inoremap N nnoremap N inoremap :tabnew nnoremap :tabnew inoremap :tabprevious nnoremap :tabprevious inoremap :tabnext nnoremap :tabnext inoremap w nnoremap w inoremap W nnoremap W