-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 30b6b04
Showing
8 changed files
with
1,305 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
" __ _(_)_ __ ___ _ __ ___ | ||
" \ \ / / | '_ ` _ \| '__/ __| | ||
" \ V /| | | | | | | | | (__ | ||
" (_)_/ |_|_| |_| |_|_| \___| | ||
|
||
" This vimrc changes a lot. I'll try to document pieces of it whenever I have some spare minutes to kill. | ||
|
||
" On Windows, use '.vim' instead of 'vimfiles': this makes synchronization across heterogeneous Windows/POSIX environments easier. | ||
let s:MSWindows = has('win95') + has('win16') + has('win32') + has('win64') | ||
|
||
if s:MSWindows | ||
set runtimepath=$VIM/.vim,$VIMRUNTIME,$VIM/vimfiles/after,$VIM/.vim/after | ||
endif | ||
|
||
" Vi is soooo 1970. Who cares about vi? | ||
set nocompatible | ||
|
||
" Thanks Tim Pope | ||
execute pathogen#infect() | ||
syntax on | ||
filetype plugin indent on | ||
|
||
" Vim configuration | ||
source $VIM\vim config\autocommands.vim " The filename says it already | ||
source $VIM\vim config\fold.vim " Setting the folds properly | ||
source $VIM\vim config\general.vim " General things. | ||
source $VIM\vim config\keymap.vim " Map the keys for a better workflow. | ||
source $VIM\vim config\pluginsettings.vim " Customize the others plugin. | ||
source $VIM\vim config\styling.vim " Give Vim some style. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Vim’s basics are fairly simple, but in combination the simple commands become powerful. | ||
This is my Vim configuration tree, used and tweaked over a year. Most of the time I'm writing code. So it's focused on faster writing, completion and navigation. | ||
|
||
Although a vimrc is a very personal thing, I believe there are some settings/configs that you could use to improve your Vim setup, so I have commented most settings. | ||
Feel free to explore it and use pieces from it (or use it in it's entirety, but I don't think that would really be useful). | ||
|
||
In particular, there's a nice config for Neocomplete. These days it's somewhat geared towards Linux and Windows, but it is known to also work on MacOS X. | ||
|
||
How to update to latest version? | ||
-------------------------------- | ||
Simply just do a git rebase! | ||
|
||
cd ~/.vimrc | ||
git pull --rebase | ||
|
||
Manually install on Windows | ||
--------------------------- | ||
1. Check out from github | ||
|
||
cd C:\Program Files\Vim (or your installed path to Vim) | ||
rmdir /s vimfiles (This deletes your old vim configurations. If you want to keep it, use move instead of rmdir.) | ||
git clone git://github.com/ehartc/dot-vimrc.git vimfiles | ||
git submodule update --init | ||
|
||
2. Install vimrc. Add the following line at the end of C:\Program Files\Vim\vimrc | ||
|
||
source $VIM/vimfiles/vimrc | ||
|
||
That's it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
" Autocommands for Vim/Neovim | ||
" Last modified: 30 december 2013 | ||
" Author: Ernst de Hart | ||
|
||
" Remove trailing spaces when writing the buffer: | ||
" autocmd BufWritePre * :%s/\s\+$//e | ||
|
||
" Automatically change into the directory of the buffer, when switching. | ||
au BufEnter * silent! lcd %:p:h | ||
|
||
" Fix "press Enter" message, when starting Vim with opening file. | ||
au VimEnter * set shortmess=IA | ||
|
||
" Don't continue comment mark after press 'o' when youre on a commented line | ||
au VimEnter * set formatoptions -=cro | ||
|
||
" Execute fullscreen without timewait will not work, due to overhead in driver. Ugly patch, until this issue will be fixed. { | ||
function! Wait(mil) | ||
let timetowait = a:mil . " m" | ||
exe 'sleep '.timetowait | ||
endfunction | ||
|
||
" Enable it: | ||
function! FixFullScreen() | ||
call Wait(1) | ||
call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0) | ||
call Wait(1) | ||
call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0) | ||
call Wait(1) | ||
call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0) | ||
endfunction | ||
|
||
autocmd VimEnter * call FixFullScreen() | ||
" } | ||
|
||
|
||
" Switch to the directory of the current file, unless it's a help file. | ||
" Could use BufEnter instead, but then we have constant changing pwd. | ||
" autocmd BufReadPost * if &ft != 'help' | silent! cd %:p:h | endif | ||
|
||
" Start interactive EasyAlign in visual mode (e.g. vip<Enter>). | ||
au VimEnter * vmap <Enter> <Plug>(EasyAlign) | ||
" Don't continue comment mark after press 'o' when you're on a commented line. | ||
au VimEnter * set formatoptions -=cro | ||
au BufEnter * set formatoptions -=cro | ||
|
||
" Auoindent XML correctly. | ||
au FileType xml setlocal equalprg=xmllint\ --format\ --recover\ -\ 2>/dev/null | ||
|
||
" Display CSS well in small side-diwi window. | ||
au BufEnter * if &ft ==# 'css' | vertical resize 50 | endif | ||
|
||
" Remove the buffers from list which are not viewed in tabs and windows. { | ||
function RemoveHiddenBuffers() | ||
let tpbl=[] | ||
call map(range(1, tabpagenr('$')), 'extend(tpbl, tabpagebuflist(v:val))') | ||
for buf in filter(range(1, bufnr('$')), 'bufexists(v:val) && index(tpbl, v:val)==-1') | ||
silent execute 'bwipeout' buf | ||
endfor | ||
endfunction | ||
|
||
" Faster to type it: | ||
au VimEnter * call CmdAlias('buuf', 'call RemoveHiddenBuffers() <bar> echo "The hidden buffers are removed!"') | ||
au VimEnter * call CmdAlias('line', 'set fillchars+=stl:\_') | ||
au VimEnter * call CmdAlias('local', 'cd /var/www/html/') | ||
au VimEnter * call CmdAlias('dir', 'cd %:p:h') | ||
au VimEnter * call CmdAlias('uf', 'Unite -auto-resize -start-insert file file_rec/async') | ||
|
||
command! -nargs=* -range -bang EA <line1>,<line2>call easy_align#align('<bang>' == '!', 0, '', <q-args>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
" Enables manual folding, in order to get my preferences working. | ||
set foldmethod=manual | ||
|
||
" See :h foldcolumn | ||
set foldcolumn=1 | ||
|
||
" Deepest fold is 3 levels. | ||
set foldnestmax=3 | ||
|
||
" But have fold open by default, autofold should be not enabled. { | ||
set nofoldenable | ||
|
||
" Load the viewport with his own settings per buffer. | ||
if !isdirectory(expand(&viewdir))|call mkdir(expand(&viewdir), "p", 451)|endif | ||
|
||
|
||
" When viewing files from others with fold tags included, I noticed that their foldlevel are often conflicting with my preferences. | ||
function FoldLevelFix() | ||
if(&foldlevel == 0) | ||
set foldlevel=1 | ||
elseif(&foldlevel != 0) | ||
set foldlevel=0 | ||
endif | ||
endfunction | ||
|
||
" Wrote function, to check if the viewport contains any folds. | ||
function HasFoldedLine() | ||
let lnum=1 | ||
while lnum <= line("$") | ||
if (foldclosed(lnum) > -1) | ||
return 1 | ||
endif | ||
let lnum+=1 | ||
endwhile | ||
return 0 | ||
endfu | ||
|
||
" Give location for fold layout and their settings. | ||
set viewoptions=cursor,folds,slash,unix | ||
let &viewdir="C:\\Dropbox\\Vim\\.vim\\files-viewdir" | ||
|
||
" PHP { | ||
let php_htmlInStrings = 1 " Syntax highlight HTML code inside PHP strings. | ||
let php_sql_query = 1 " Syntax highlight SQL code inside PHP strings. | ||
" let php_noShortTags = 1 " Disable PHP short tags. | ||
let php_parent_error_close = 1 | ||
let php_parent_error_open = 1 | ||
" let php_alt_comparisons = 1 | ||
" let php_alt_assignByReference = 1 | ||
" } | ||
|
||
|
||
" ---------------------------------------------------------------------------------------------------------------------- | ||
" Keymappings for folding | ||
" ---------------------------------------------------------------------------------------------------------------------- | ||
" I found the keys of Vim for folding not comfortable, so so let's rebind the keys. { | ||
" Create fold, z is not on homerow. I don't use 's', so remap z to s. | ||
vnoremap sf zf | ||
" za :When on a closed fold: open it. And vice versa. | ||
nnoremap sf zA | ||
" [z :Move to the start of the current open fold. | ||
nnoremap [s [z | ||
nnoremap s[ [z | ||
" ]z :Move to the end of the current open fold. | ||
nnoremap ]s ]z | ||
vnoremap ]s ]z | ||
nnoremap s] ]z | ||
vnoremap s] ]z | ||
" zj :Move downwards. to the start of the next fold. | ||
nnoremap <silent> sj :call NextGeslotenFold('j')<cr> | ||
" | ||
" zk :Move upwards to the end of the previous fold. | ||
nnoremap <silent> sk :call NextGeslotenFold('k')<cr> | ||
" zR :Open/close all folds | ||
nnoremap <silent> sl :call FoldLevelFix()<CR> | ||
" Create fold of function, to select just one line of function header. | ||
nnoremap sh v$%zf | ||
" When vap, press space to fold it | ||
vnoremap <Space> zf | ||
" Create fold of casebreak, to select just one line of function header. | ||
vnoremap sb /break<CR>zf | ||
nnoremap sb v/break<CR>zf | ||
" zE :Erase all folds. | ||
nnoremap sd zD | ||
nnoremap sD zE | ||
" } | ||
|
||
|
||
|
||
" ---------------------------------------------------------------------------------------------------------------------- | ||
" Modify the fold layout | ||
" ---------------------------------------------------------------------------------------------------------------------- | ||
|
||
" I found the fold layout of Vim not extremely helpful, so let's modify it. { | ||
function! UsefulFoldText() | ||
" Add regex to find the relevant lines. | ||
let line = ' ' . substitute(getline(v:foldstart), '^\s*"\?\s*\|\s*"\?\s*{{' . '{\d*\s*', '', 'g') . ' ' | ||
let linesCount = v:foldend - v:foldstart + 1 | ||
|
||
let foldSize = 1 + v:foldend - v:foldstart | ||
let lineCount = line("$") | ||
|
||
" Then abuse the error (E806) as indicator when passing a float as string. | ||
" However, I would be interested in a better way to read the fold input with VimL. If you do know a way, let me know at ernst de hart dot gmail dot the default domain. | ||
if has("float") | ||
try | ||
let foldPercentage = printf(" %.1f", (foldSize*1.0)/lineCount*100) . "% " | ||
catch /^Vim\%((\a\+)\)\=:E806/ | ||
let foldPercentage = printf("| [of %d lines] |", lineCount) | ||
endtry | ||
endif | ||
|
||
" Tie the vars together. | ||
let linesCountText = '| ' . printf("%10s", lines_count . ' lines of Vi code') . ' - ' . foldPercentage . ' |' | ||
let foldchar = matchstr(&fillchars, 'fold:\zs.') | ||
let foldtextStart = strpart('+' . repeat(foldchar, v:foldlevel*2) . line, 0, (winwidth(0)*2)/3) | ||
let foldtextEnd = linesCountText . repeat(foldchar, 28) | ||
let foldtextLength = strlen(substitute(foldtextStart . foldtextEnd, '.', 'x', 'g')) + &foldcolumn | ||
|
||
" Keep in mind that the align-feature is already included below. | ||
return foldtextStart . repeat(foldchar, winwidth(0)-foldtextLength) . foldtextEnd | ||
endfunction | ||
" Start it: | ||
set foldtext=UsefulFoldText() | ||
|
||
" } | ||
|
||
" I would like to move between the folds only, instead text. { | ||
function! NextGeslotenFold(dir) | ||
" Use the same dir where the memory buffer resides. | ||
let cmd = 'norm!z' . a:dir | ||
let view = winsaveview() | ||
" Then count the folds. | ||
let [l0, l, open] = [0, view.lnum, 1] | ||
while l != l0 && open | ||
exe cmd | ||
let [l0, l] = [l, line('.')] | ||
let open = foldclosed(l) < 0 | ||
endwhile | ||
if open | ||
call winrestview(view) | ||
endif | ||
endfunction | ||
" } | ||
|
Oops, something went wrong.