My vim configuration
git clone https://github.com/m-col/vim-misc
Files | Refs | Readme

Commit d6a4b2fc18850966a14fd9e33c078989c4119453
Parent: 6659cc9afb2af9481ed2f50ad61cde8b533085e4
Author: mcol <mcol@posteo.net>
Date: 2018-11-28 19:41:59 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2018-11-28 19:41:59 +0000

moved to plugin folder

plugin/indent.vim Added

@@ -0,0 +1,13 @@
+"------------------------------------------------------------------
+"  Indentation of entire file
+"------------------------------------------------------------------
+
+function! IndentFile()
+    mkview
+    let l:win_view = winsaveview()
+    :normal! gg=G
+    silent loadview
+    call winrestview(l:win_view)
+endfunction
+
+nnoremap <C-i> :call IndentFile()<CR>

plugin/bclose.vim Added

@@ -0,0 +1,95 @@
+"------------------------------------------------------------------"
+" :bclose                                                          "
+"------------------------------------------------------------------"
+
+" Delete buffer while keeping window layout (don't close buffer's windows).
+" Version 2008-11-18 from http://vim.wikia.com/wiki/VimTip165
+if v:version < 700 || exists('loaded_bclose') || &cp
+    finish
+endif
+let loaded_bclose = 1
+if !exists('bclose_multiple')
+    let bclose_multiple = 1
+endif
+
+" Display an error message.
+function! s:Warn(msg)
+    echohl ErrorMsg
+    echomsg a:msg
+    echohl NONE
+endfunction
+
+" Command ':Bclose' executes ':bd' to delete buffer in current window.
+" The window will show the alternate buffer (Ctrl-^) if it exists,
+" or the previous buffer (:bp), or a blank buffer if no previous.
+" Command ':Bclose!' is the same, but executes ':bd!' (discard changes).
+" An optional argument can specify which buffer to close (name or number).
+function! s:Bclose(bang, buffer)
+    if empty(a:buffer)
+	let btarget = bufnr('%')
+    elseif a:buffer =~ '^\d\+$'
+	let btarget = bufnr(str2nr(a:buffer))
+    else
+	let btarget = bufnr(a:buffer)
+    endif
+    if btarget < 0
+	call s:Warn('No matching buffer for '.a:buffer)
+	return
+    endif
+    if empty(a:bang) && getbufvar(btarget, '&modified')
+	call s:Warn('No write since last change for buffer '.btarget.' (use :Bclose!)')
+	return
+    endif
+    " Numbers of windows that view target buffer which we will delete.
+    let wnums = filter(range(1, winnr('$')), 'winbufnr(v:val) == btarget')
+    if !g:bclose_multiple && len(wnums) > 1
+	call s:Warn('Buffer is in multiple windows (use ":let bclose_multiple=1")')
+	return
+    endif
+    let wcurrent = winnr()
+    for w in wnums
+	execute w.'wincmd w'
+	let prevbuf = bufnr('#')
+	if prevbuf > 0 && buflisted(prevbuf) && prevbuf != w
+	    buffer #
+	else
+	    bprevious
+	endif
+	if btarget == bufnr('%')
+	    " Numbers of listed buffers which are not the target to be deleted.
+	    let blisted = filter(range(1, bufnr('$')), 'buflisted(v:val) && v:val != btarget')
+	    " Listed, not target, and not displayed.
+	    let bhidden = filter(copy(blisted), 'bufwinnr(v:val) < 0')
+	    " Take the first buffer, if any (could be more intelligent).
+	    let bjump = (bhidden + blisted + [-1])[0]
+	    if bjump > 0
+		execute 'buffer '.bjump
+	    else
+		execute 'enew'.a:bang
+	    endif
+	endif
+    endfor
+    execute 'bdelete'.a:bang.' '.btarget
+    execute wcurrent.'wincmd w'
+endfunction
+command! -bang -complete=buffer -nargs=? Bclose call s:Bclose('<bang>', '<args>')
+
+
+""""" These are left in case the above is not ideal
+"function! CloseIfLastBuffer()
+"    if len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1 
+"    let g:fromFile=expand('%:p')
+"    execute "q"
+"    execute "bd"
+"endfunction
+"nnoremap <BS> :call CloseIfLastBuffer()<CR>
+
+"autocmd BufDelete * if len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1 | quit | endif
+"autocmd BufDelete * if len(filter(range(1, bufnr('$')), '! empty(bufname(v:val)) && buflisted(v:val)')) == 1 | quit | endif
+
+
+
+if v:this_session == expand("$HOME") . ".cache/vim/sessions/matlab-session.vim"
+    nnoremap <buffer> <silent> <BS> :Bclose<CR>
+endif
+

plugin/autohighlight.vim Added

@@ -0,0 +1,20 @@
+" Highlight all instances of word under cursor, when idle.
+nnoremap <bar> :if AutoHighlightToggle()<Bar>set hls<Bar>endif<CR>
+function! AutoHighlightToggle()
+  let @/ = ''
+  if exists('#auto_highlight')
+    au! auto_highlight
+    augroup! auto_highlight
+    setl updatetime=4000
+    echo 'Highlight current word: off'
+    return 0
+  else
+    augroup auto_highlight
+      au!
+      au CursorHold * let @/ = '\V\<'.escape(expand('<cword>'), '\').'\>'
+    augroup end
+    setl updatetime=500
+    echo 'Highlight current word: ON'
+    return 1
+  endif
+endfunction

indent.vim Deleted

@@ -1,13 +0,0 @@
-"------------------------------------------------------------------
-"  Indentation of entire file
-"------------------------------------------------------------------
-
-function! IndentFile()
-    mkview
-    let l:win_view = winsaveview()
-    :normal! gg=G
-    silent loadview
-    call winrestview(l:win_view)
-endfunction
-
-nnoremap <C-i> :call IndentFile()<CR>

bclose.vim Deleted

@@ -1,89 +0,0 @@
-"------------------------------------------------------------------"
-" :bclose                                                          "
-"------------------------------------------------------------------"
-
-" Delete buffer while keeping window layout (don't close buffer's windows).
-" Version 2008-11-18 from http://vim.wikia.com/wiki/VimTip165
-if v:version < 700 || exists('loaded_bclose') || &cp
-    finish
-endif
-let loaded_bclose = 1
-if !exists('bclose_multiple')
-    let bclose_multiple = 1
-endif
-
-" Display an error message.
-function! s:Warn(msg)
-    echohl ErrorMsg
-    echomsg a:msg
-    echohl NONE
-endfunction
-
-" Command ':Bclose' executes ':bd' to delete buffer in current window.
-" The window will show the alternate buffer (Ctrl-^) if it exists,
-" or the previous buffer (:bp), or a blank buffer if no previous.
-" Command ':Bclose!' is the same, but executes ':bd!' (discard changes).
-" An optional argument can specify which buffer to close (name or number).
-function! s:Bclose(bang, buffer)
-    if empty(a:buffer)
-	let btarget = bufnr('%')
-    elseif a:buffer =~ '^\d\+$'
-	let btarget = bufnr(str2nr(a:buffer))
-    else
-	let btarget = bufnr(a:buffer)
-    endif
-    if btarget < 0
-	call s:Warn('No matching buffer for '.a:buffer)
-	return
-    endif
-    if empty(a:bang) && getbufvar(btarget, '&modified')
-	call s:Warn('No write since last change for buffer '.btarget.' (use :Bclose!)')
-	return
-    endif
-    " Numbers of windows that view target buffer which we will delete.
-    let wnums = filter(range(1, winnr('$')), 'winbufnr(v:val) == btarget')
-    if !g:bclose_multiple && len(wnums) > 1
-	call s:Warn('Buffer is in multiple windows (use ":let bclose_multiple=1")')
-	return
-    endif
-    let wcurrent = winnr()
-    for w in wnums
-	execute w.'wincmd w'
-	let prevbuf = bufnr('#')
-	if prevbuf > 0 && buflisted(prevbuf) && prevbuf != w
-	    buffer #
-	else
-	    bprevious
-	endif
-	if btarget == bufnr('%')
-	    " Numbers of listed buffers which are not the target to be deleted.
-	    let blisted = filter(range(1, bufnr('$')), 'buflisted(v:val) && v:val != btarget')
-	    " Listed, not target, and not displayed.
-	    let bhidden = filter(copy(blisted), 'bufwinnr(v:val) < 0')
-	    " Take the first buffer, if any (could be more intelligent).
-	    let bjump = (bhidden + blisted + [-1])[0]
-	    if bjump > 0
-		execute 'buffer '.bjump
-	    else
-		execute 'enew'.a:bang
-	    endif
-	endif
-    endfor
-    execute 'bdelete'.a:bang.' '.btarget
-    execute wcurrent.'wincmd w'
-endfunction
-command! -bang -complete=buffer -nargs=? Bclose call s:Bclose('<bang>', '<args>')
-
-
-""""" These are left in case the above is not ideal
-"function! CloseIfLastBuffer()
-"    if len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1 
-"    let g:fromFile=expand('%:p')
-"    execute "q"
-"    execute "bd"
-"endfunction
-"nnoremap <BS> :call CloseIfLastBuffer()<CR>
-
-"autocmd BufDelete * if len(filter(range(1, bufnr('$')), 'buflisted(v:val)')) == 1 | quit | endif
-"autocmd BufDelete * if len(filter(range(1, bufnr('$')), '! empty(bufname(v:val)) && buflisted(v:val)')) == 1 | quit | endif
-

autohighlight.vim Deleted

@@ -1,20 +0,0 @@
-" Highlight all instances of word under cursor, when idle.
-nnoremap <bar> :if AutoHighlightToggle()<Bar>set hls<Bar>endif<CR>
-function! AutoHighlightToggle()
-  let @/ = ''
-  if exists('#auto_highlight')
-    au! auto_highlight
-    augroup! auto_highlight
-    setl updatetime=4000
-    echo 'Highlight current word: off'
-    return 0
-  else
-    augroup auto_highlight
-      au!
-      au CursorHold * let @/ = '\V\<'.escape(expand('<cword>'), '\').'\>'
-    augroup end
-    setl updatetime=500
-    echo 'Highlight current word: ON'
-    return 1
-  endif
-endfunction