set t_Co=256 colorscheme mipscheme set bg=light syntax enable " Allow buffers to be hidden even if there are changes not yet written (!!! beware then when using :q! or :qa!) set hidden set number set bs=2 set incsearch "Enable mouse double-click on hyperlink in help screen "- Double click or CTRL-] on any word to find help on that topic "- g, CTRL-T, CTRL-O to go back set mouse=a " "Use unnamed register (clipboard) as default register... " set clipboard=unnamed,exclude:cons\|linux " NOT ANYMORE - Seems I can't do smthg like cut - delete - paste... "#### Remap cursor keys to keys under the fingers! ####### noremap j h " noremap J H noremap j h noremap k j " noremap K J noremap k j noremap l k " noremap L K noremap l k noremap m l " noremap M L noremap m l noremap h m " noremap H M " Moreover, in normal mode, we scroll by visual lines (i.e. word wrap lines) (see tip http://vim.wikia.com/wiki/VimTip979) " (only for normal mode, not for visual mode, or operator-pending mode) nnoremap k gj nnoremap l gk "#### Use Clipboard as default register for yank / paste - Use D / C to Cut / Change to clipboard ############ " C: Change using clipboard register (do c$ for Change to eol) " CC: change current line using clipboard register " D: Delete using clipboard register (do d$ for delete to eol) " DD: delete current line using clipboard register " X: delete current line " x: (visual) keep the current selection " BS: same as original X nnoremap C :set opfunc=ChangeToClipboardg@ nnoremap CC "+cc vnoremap C :call ChangeToClipboard(visualmode(), 1) nnoremap D :set opfunc=DeleteToClipboardg@ nnoremap DD "+dd vnoremap D :call DeleteToClipboard(visualmode(), 1) nnoremap X dd nnoremap X vnoremap x xgv nnoremap y "+y vnoremap y "+y nnoremap Y "+Y vnoremap Y "+Y nnoremap p "+p vnoremap p "+p nnoremap P "+P vnoremap P "+P function! DeleteToClipboard(type, ...) let sel_save = &selection let &selection = "inclusive" if a:0 " Invoked from Visual mode, use '< and '> marks. silent exe "normal! `<" . a:type . "`>\"+x" elseif a:type == 'line' silent exe "normal! '[V']\"+x" elseif a:type == 'block' silent exe "normal! `[\`]\"+x" else silent exe "normal! `[v`]\"+x" endif let &selection = sel_save endfunction function! ChangeToClipboard(type, ...) let sel_save = &selection let sel_ve= &virtualedit let &selection = "inclusive" let &virtualedit = "onemore" if a:0 " Invoked from Visual mode, use '< and '> marks. exe "normal! `<" . a:type . "`>\"+x" | startinsert elseif a:type == 'line' exe "normal! '[V']\"+x" | startinsert elseif a:type == 'block' exe "normal! `[\`]\"+x" | startinsert else exe "normal! `[v`]\"+x" | startinsert endif let &selection = sel_save let &virtualedit = sel_ve endfunction "#### Cursor movements wrap over end-of-line ############## set whichwrap+=<,>,h,l "#### Indentation ######################################## set tabstop=4 softtabstop=4 shiftwidth=4 noexpandtab copyindent preserveindent smarttab set autoindent "set smartindent "set cindent " Use :notab to replace tab with spaces ca notab set expandtab:retab "#### Auto-Complete ###################################### " Press Ctrl-N to have the drop down menu with auto-completion proposals inoremap pumvisible() \|\| &omnifunc == '' ? \ "\C-n>" : \ "\C-x>\C-o>=pumvisible() ?" . \ "\"\\c-n>\\c-p>\\c-n>\" :" . \ "\" \\bs>\\C-n>\"\" " Alternative solution, using "clever" tabs, ie. completion is triggered only if word on the left of the cursor is an identifier " inoremap CleverTab() " function! CleverTab() " if pumvisible() " return "\" " endif " let line=strpart( getline('.'), 0, col('.')-1 ) " if !(line =~ '^.*[a-zA-Z0-1_]$') "completion only if last char is a word char " return "\" " elseif exists('&omnifunc') && &omnifunc != '' " return "\\" " else " return "\" " endif " endfunction "#### Avoid the ESCAPE Key ############################### " Press Ctrl-Space instead of ESC (because Shift-Space only work in GUI). " See http://vim.wikia.com/wiki/Avoid_the_escape_key "- nnoremap --> cancel any prefix keys " nnoremap - Conflicts with cscope mapping, let's try without this "- vnoremap --> cancel any selection (gV is required to prevent automatic reselection) vnoremap gV "- onoremap --> cancel any operator pending commands (like y) onoremap "- inoremap --> exit insert mode and `^ restore cursor position (cursor does not move left) inoremap `^ "- Prevent Ctrl-C to move one character on the left inoremap `^ "#### EASY NAVIGATION IN INSERT MODE ################################ noremap noremap noremap noremap inoremap inoremap inoremap inoremap "inoremap - is now used as replacement to in insert mode "inoremap - is shortcut to insert last inserted text... inoremap inoremap " (modified from mswin.vim) CTRL-V pastes Clipboard and SHIFT-Insert pastes X-Clipboard - Use CTRL-Q for regular CTRL-V in insert mode inoremap + cnoremap + inoremap nnoremap "*gP inoremap * cnoremap * " #### EASY SEARCH / SUBSTITUTE ###################################### " See tip [http://vim.wikia.com/wiki/Keystroke_Saving_Substituting_and_Searching] " and [http://vim.wikia.com/wiki/Search_and_replace_the_word_under_the_cursor] " -- for convenience the current word is also copied in register "* (X clipboard), so that it can be inserted with shift-INS " General substitution - to complete it, just enter myoldpattern/mynewpattern :noremap "*yiw:%s//gc " Substitute word under cursor - to complete it, just enter mynewpattern :noremap "*yiw:%s///gc :nnoremap s "*yiw:%s/\<\>//gc " Search highlighted text in visual mode :vnoremap / y:execute "/".escape(@",'[]/\.*') " Substite highlighted text in visual mode - to complete it, just enter mynewpattern :vnoremap y:execute "%s/".escape(@",'[]/')."//gc" " Copy current word under cursor in clipboard (shortcut for yiw) (see also below) nnoremap "+yiw " Replace current word with content of clipboard (see also below) nnoremap ciw+ " Tab / Shift-Tab: in normal mode, same as >> <<; in visual mode, idem but also remains in visual mode " TODO: PARTLY DISABLED because interferes with csope (a Tab is generated after each symbol look up... why?) " vnoremap < << " vnoremap > >gv vnoremap >gv " nnoremap >> " The F3 series for easy variable renaming (a tribute to good old UltraEdit F3 ;-) ) " - Edit clipboard content, preset with word under cursor ( to delete it) " - Set current word as search pattern (but don't perform the search) " - replace current word with content of clipboard, and search next occurence of replaced text " (OLD F3) - would actually search for next occurence of register - (last deleted text) " nnoremap :execute "/".escape(@-,'[]/\.*') " (ALTERNATE MAPPTING) - would be to use exchange and ; also why not use ù instead of " " To rename a variable: " (or ) edit clipboard content, preset with word under curssor ( to delete it) " (or ) replace current word with clipboard content and search new occurence " (or ) replace current word with clipboard content and search new occurence " or " Set clipboard to word under cursor " hjkl find variable to replace " (or ) replace current word with clipboard content and search new occurence " (or ) replace current word with clipboard content and search new occurence nnoremap :let @+ = "" nnoremap :let @/ = "\\<".escape("",'[]/\.*')."\\>" nmap ciw+n nmap nmap "#### MISCELLANEOUS ################################################## " Allow virtual edit only in block mode set ve=block " choice: block, insert, all, onemore " Highlight the current line set cursorline " fix vim bug - original value does not expand the ~ set tags=~/.vimtags,./tags,./TAGS,tags,TAGS " Generate a new tag file and highlight tags in the current file /OR/ " highlight tags only... map :sp tags:%s/^\([^ :]*:\)\=\([^ ]*\).*/syntax keyword Tag \2/:wq! tags.vim/^ map :so tags.vim " Determining the highlight group that the word under the cursor belongs to ([http://mysite.verizon.net/astronaut/vim/index.html#Tags]) nmap :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" "#### Fast Macro - use qq to register the fast macro, and @@ to replay the fast macro ###### noremap @@ @q " Compensates for AZERTY keyboard noremap ² ` noremap ²² `` noremap ³ ~ noremap g³ g~ noremap é @ noremap éé @q noremap § ^ noremap ç { noremap à } " Display or remove unwanted whitespace with a script (http://vim.wikia.com/wiki/Remove_unwanted_spaces) function ShowSpaces(...) let @/="\\v(\\s+$)|( +\\ze\\t)" let oldhlsearch=&hlsearch if !a:0 let &hlsearch=!&hlsearch if &hlsearch echo 'hlsearch is ON' else echo 'hlsearch is OFF' end else let &hlsearch=a:1 end return oldhlsearch endfunction function TrimSpaces() range let oldhlsearch=ShowSpaces(1) execute a:firstline.",".a:lastline."substitute ///gec" let &hlsearch=oldhlsearch endfunction command -bar -nargs=? ShowSpaces call ShowSpaces() command -bar -nargs=0 -range=% TrimSpaces ,call TrimSpaces() nnoremap :ShowSpaces nnoremap m`:TrimSpaces`` vnoremap :TrimSpaces " Use to insert a single character (http://vim.wikia.com/wiki/Insert_a_single_character) :nnoremap :exec "normal i".nr2char(getchar())."\e" " Adjust back textwidth (TODO: find out which script set it to 78!!!) " We want to keep comments within an 160 column limit, but not code. " These two options give us that set formatoptions=crq set textwidth=160 " Quick shortcut to increase size of current window nnoremap + nnoremap - nnoremap > nnoremap < " Quickly adding and deleting empty lines - See http://vim.wikia.com/wiki/Quickly_adding_and_deleting_empty_lines " Ctrl-j/k deletes blank line below/above, and Alt-j/k inserts. " nnoremap m`:silent +g/\m^\s*$/d``:noh " nnoremap m`:silent -g/\m^\s*$/d``:noh nnoremap :set pastem`o``:set nopaste nnoremap :set pastem`O``:set nopaste "#### C EDITING ######################################################## "#### PLUGINS ######################################################## " Update the help doc tags (uncomment if needed) " :helptags ~/.vim/doc " --- SnipMat (http://www.vim.org/scripts/script.php?script_id=2540) :filetype plugin on " --- trinity " Open and close all the three plugins on the same time nmap :TrinityToggleAll " Open and close the srcexpl.vim separately nmap :TrinityToggleSourceExplorer " Open and close the taglist.vim separately nmap :TrinityToggleTagList " Open and close the NERD_tree.vim separately nmap :TrinityToggleNERDTree " --- Easytags " let g:easytags_file = '~/.vimtags' " " MiniBufExpl (from http://vim.wikia.com/wiki/Using_vim_as_an_IDE_all_in_one) " " -------------------- " let g:miniBufExplTabWrap = 1 " make tabs show complete (no broken on two lines) " let g:miniBufExplModSelTarget = 1 " If you use other explorers like TagList you can (As of 6.2.8) set it at 1: " let g:miniBufExplUseSingleClick = 1 " If you would like to single click on tabs rather than double clicking on them to goto the selected buffer. " let g:miniBufExplMaxSize = 0 " setting this to 0 will mean the window gets as big as needed to fit all your buffers. " "let g:miniBufExplForceSyntaxEnable = 1 " There is a Vim bug that can cause buffers to show up without their highlighting. The following setting will cause MBE to " let g:miniBufExplorerMoreThanOne = 1 " Setting this to 0 will cause the MBE window to be loaded even " let g:miniBufExplMapCTabSwitchBufs = 1 " " let g:miniBufExplMapWindowNavVim = 1 " let g:miniBufExplMapWindowNavArrows = 1 " "for buffers that have NOT CHANGED and are NOT VISIBLE. " highlight MBENormal guibg=LightGray guifg=DarkGray " " for buffers that HAVE CHANGED and are NOT VISIBLE " highlight MBEChanged guibg=Red guifg=DarkRed " " buffers that have NOT CHANGED and are VISIBLE " highlight MBEVisibleNormal term=bold cterm=bold gui=bold guibg=Gray guifg=Black " " buffers that have CHANGED and are VISIBLE " highlight MBEVisibleChanged term=bold cterm=bold gui=bold guibg=DarkRed guifg=Black " TagList let Tlist_Show_One_File = 0 let Tlist_File_Fold_Auto_Close = 0