<commit_before>" ## Hacks
" Little something from http://www.ibm.com/developerworks/linux/library/l-vim-script-5/index.html 
" Agressive auto saving
function! Autosave()

	" close the preview window if it's visible
	" and the pop up menu is not visible, but not if
    " we're in a preview window.
	if pumvisible() == 0 && &buftype == ''
		pclose
	endif

	if ! &modified || ! &modifiable || &readonly
		return
	endif

	if expand('%') != ""
		write
	endif
endfunction

" A more verbose pastetoggle
function! TogglePaste()
	if	&paste == 0
		set paste
		echo "Paste is ON!"
	else
		set nopaste
		echo "Paste is OFF!"
	endif
endfunction

" Map the <End> key to <Esc>
" This is do to my X1 gen 2 kbd layout
nmap <End> <ESC>
imap <End> <ESC>

" Allow toggling of paste/nopaste via F2
"set pastetoggle=<F2>
nmap <F2> <ESC>:call TogglePaste()<CR>
imap <F2> <ESC>:call TogglePaste()<CR>i

" No much going on here for Omni Completion. In the past there were all sorts of
" nasty hacks for this section.  
" When c-y is used to select a completion, enter normal mode after it's inserted.
" imap <c-y> <c-y><esc>
" function! CmplChooseNorm()
"     if pumvisible()
"         return "\<ESC>"
"     endif

"     return "\<C-Y>"
" endfunction
" imap <c-y> <c-r>=CmplChooseNorm()<cr>

"highlight OverColLimit term=inverse,bold cterm=bold ctermbg=red ctermfg=black gui=bold guibg=red guifg=black 
function! SetColorColumn(ccol)

	if ! exists("b:longLineMatchID")
		let b:longLineMatchID = 0
	endif
	set cursorcolumn

	if !exists('&colorcolumn')
		return
	endif

	call clearmatches()

	"echo "SetColorColumn " b:longLineMatchID "" a:ccol "\%>".a:ccol."v.\+"

	if a:ccol == 0 || &buftype != "" || expand('%') == '' || &buftype == "log"
		setlocal colorcolumn=0
		let &textwidth = (0)
        " echo "bailing out"
		return
	endif

	let l:mlist = getmatches()
	if len(l:mlist) < 1 || b:longLineMatchID == 0 || &colorcolumn != (a:ccol+1)
		" echo "SetColorColumn applying" b:longLineMatchID "" a:ccol "\%>".a:ccol."v.\+"
		let &colorcolumn = (a:ccol)
		let &textwidth = (a:ccol-1)
		let b:longLineMatchID=matchadd( "ErrorMsg", '\%>'.a:ccol.'v.\+', -1 )
	endif

endfunction
if ! exists("g:maxLineLength")
	let g:maxLineLength=100
endif

" helper function to toggle hex mode
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

" Open a shell command in a new window, the command supports shell completion
command! -complete=shellcmd -nargs=* R rightbelow vnew | r ! <args>

" Open a Quickfix window for the last search.
nnoremap <silent> ,/ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR>

" Allow paste of visually selected without overwriting the copy register
" vnoremap <leader>p "_dP
vnoremap <s-p> "_dP

" "====[ Make tabs, trailing whitespace, and non-breaking spaces visible ]======

exec "set listchars=tab:\uBB\uBB,trail:\uB7,nbsp:~"
set list


"====[ Swap : and ; to make colon commands easier to type ]======

" nnoremap  ;  :
" If you swap the other way, it breaks my NERDTree
" nnoremap  :  ;

" " runtime plugin/dragvisuals.vim

" Add the virtualenv's site-packages to vim path
python3 << EOF
import os.path
import sys
import vim
if 'VIRTUAL_ENV' in os.environ:
    project_base_dir = os.environ['VIRTUAL_ENV']
    py_vers = ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4', '3.5', '3.6', '3.7', '3.8']
    for pv in py_vers:
        ipath = os.path.join(project_base_dir, 'lib', 'python' + pv, 'site-packages')
        if os.path.exists(ipath):
            vim.command('set path+=%s' % ipath )
            vim.command('silent! echo "Set venv path ' + ipath + '"')

    sys.path.insert(0, project_base_dir)
    activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
    vim.command("let g:python3_host_prog = '" + os.path.join(project_base_dir, 'bin/python') + "'")
    execfile(activate_this, dict(__file__=activate_this))

    # Add tags if they are at the virtualenv dir<commit_msg>replace execfile with exec in aaahacks<commit_after>" ## Hacks
" Little something from http://www.ibm.com/developerworks/linux/library/l-vim-script-5/index.html 
" Agressive auto saving
function! Autosave()

	" close the preview window if it's visible
	" and the pop up menu is not visible, but not if
    " we're in a preview window.
	if pumvisible() == 0 && &buftype == ''
		pclose
	endif

	if ! &modified || ! &modifiable || &readonly
		return
	endif

	if expand('%') != ""
		write
	endif
endfunction

" A more verbose pastetoggle
function! TogglePaste()
	if	&paste == 0
		set paste
		echo "Paste is ON!"
	else
		set nopaste
		echo "Paste is OFF!"
	endif
endfunction

" Map the <End> key to <Esc>
" This is do to my X1 gen 2 kbd layout
nmap <End> <ESC>
imap <End> <ESC>

" Allow toggling of paste/nopaste via F2
"set pastetoggle=<F2>
nmap <F2> <ESC>:call TogglePaste()<CR>
imap <F2> <ESC>:call TogglePaste()<CR>i

" No much going on here for Omni Completion. In the past there were all sorts of
" nasty hacks for this section.  
" When c-y is used to select a completion, enter normal mode after it's inserted.
" imap <c-y> <c-y><esc>
" function! CmplChooseNorm()
"     if pumvisible()
"         return "\<ESC>"
"     endif

"     return "\<C-Y>"
" endfunction
" imap <c-y> <c-r>=CmplChooseNorm()<cr>

"highlight OverColLimit term=inverse,bold cterm=bold ctermbg=red ctermfg=black gui=bold guibg=red guifg=black 
function! SetColorColumn(ccol)

	if ! exists("b:longLineMatchID")
		let b:longLineMatchID = 0
	endif
	set cursorcolumn

	if !exists('&colorcolumn')
		return
	endif

	call clearmatches()

	"echo "SetColorColumn " b:longLineMatchID "" a:ccol "\%>".a:ccol."v.\+"

	if a:ccol == 0 || &buftype != "" || expand('%') == '' || &buftype == "log"
		setlocal colorcolumn=0
		let &textwidth = (0)
        " echo "bailing out"
		return
	endif

	let l:mlist = getmatches()
	if len(l:mlist) < 1 || b:longLineMatchID == 0 || &colorcolumn != (a:ccol+1)
		" echo "SetColorColumn applying" b:longLineMatchID "" a:ccol "\%>".a:ccol."v.\+"
		let &colorcolumn = (a:ccol)
		let &textwidth = (a:ccol-1)
		let b:longLineMatchID=matchadd( "ErrorMsg", '\%>'.a:ccol.'v.\+', -1 )
	endif

endfunction
if ! exists("g:maxLineLength")
	let g:maxLineLength=100
endif

" helper function to toggle hex mode
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

" Open a shell command in a new window, the command supports shell completion
command! -complete=shellcmd -nargs=* R rightbelow vnew | r ! <args>

" Open a Quickfix window for the last search.
nnoremap <silent> ,/ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR>

" Allow paste of visually selected without overwriting the copy register
" vnoremap <leader>p "_dP
vnoremap <s-p> "_dP

" "====[ Make tabs, trailing whitespace, and non-breaking spaces visible ]======

exec "set listchars=tab:\uBB\uBB,trail:\uB7,nbsp:~"
set list


"====[ Swap : and ; to make colon commands easier to type ]======

" nnoremap  ;  :
" If you swap the other way, it breaks my NERDTree
" nnoremap  :  ;

" " runtime plugin/dragvisuals.vim

" Add the virtualenv's site-packages to vim path
python3 << EOF
import os.path
import sys
import vim
if 'VIRTUAL_ENV' in os.environ:
    project_base_dir = os.environ['VIRTUAL_ENV']
    py_vers = ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4', '3.5', '3.6', '3.7', '3.8']
    for pv in py_vers:
        ipath = os.path.join(project_base_dir, 'lib', 'python' + pv, 'site-packages')
        if os.path.exists(ipath):
            vim.command('set path+=%s' % ipath )
            vim.command('silent! echo "Set venv path ' + ipath + '"')

    sys.path.insert(0, project_base_dir)
    activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
    vim.command("let g:python3_host_prog = '" + os.path.join(project_base_dir, 'bin/python') + "'")
    exec(open(activate_this).read(), dict(__file__=activate_this))

    # Add tags if they are at the virtualenv dir
{'fraction_non_alphanumeric': 0.137047877900899, 'fraction_numerical': 0.0102446163495714, 'mean_word_length': 3.623972933784437, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 63, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '779600', 'n_tokens_mistral': 3607, 'n_tokens_neox': 3441, 'n_words': 1038}