Skip to content

Instantly share code, notes, and snippets.

@WaterSibilantFalling
Created September 21, 2017 14:10
Show Gist options
  • Save WaterSibilantFalling/146f045e91af17c4c565bc0a6abd10b4 to your computer and use it in GitHub Desktop.
Save WaterSibilantFalling/146f045e91af17c4c565bc0a6abd10b4 to your computer and use it in GitHub Desktop.
my vimrc
" ============= Contents =============================================
" 1. meta settings
" 2. plugin manager & plugins
" 3. settings for all files
" 4. call to each setup_XXX_buffers()
"5.ToggleLineNumbers()each filetype setup function
" 6. utility functions used by any of the above
"
" reference
" --- include guard: don't source this file twice
if exists('g:haveLoadedMyVimrc')
finish
endif
let g:haveLoadedMyVimrc = 1
" ========== (1) === meta settings ====================================
"
" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below. If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed. It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
"runtime! debian.vim
source /usr/share/vim/vim80/debian.vim
let &runtimepath .= ',/usr/share/nvim/not-fucked'
" use ":set rtp?" to check what is actually the runtimepath
" set in debian.vim
"set runtimepath+=~/.vim,/usr/share/vim/vimcurrent
" Set to auto read when a file is changed from the outside
set autoread
let mapleader = ";"
let g:mapleader = ";"
if !has('nvim')
unlet! term
set term=$TERM
endif
au! CursorMovedI " for the infinitely moronic plugins that operate on
au! CursorMoved " EVERY! keypress. stupidity unbounded
set lispwords=""
set viminfo='10,\"20 " 10 oldfiles, 20 changes
setlocal hidden " Hide buffers when they are abandoned, change w/o saving
set ttyfast " already default for rxvt
set history=20
"------ vundle ---------------------------
" READ THIS: you have to close vim, and reopen.
" 'save' is, for some reason, not enough
" READ THIS: "PluginInstall" has to be run for each user separately
" install 'root' user LAST
" --- Brief help
" :PluginList - lists configured plugins
" :PluginInstall - INSTALLS PLUGINS; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-
" approve removal
" --- samples of different source of plugins
" - plugin from http://vim-scripts.org/vim/scripts.html
"Plugin 'L9'
" - Git plugin not hosted on GitHub
"Plugin 'git://git.wincent.com/command-t.git'
" - git repos on your local machine (i.e. when working on your own plugin)
"Plugin 'file:///home/gmarik/path/to/plugin'
" - a vim script in a subdirectory of a repo called vim.
" Pass the path to set the runtimepath properly.
"Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
"--- Vundle
" REPLACE: filetype off " required
source /usr/share/vim/vimcurrent/ftoff.vim
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin("~/.vim/plugins_local_vundleManaged")
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
"source ~/.vim/plugins_local_vundleManaged/Vundle.vim/autoload/vundle.vim
"--- plugin on GitHub repo
" comment blocks, and uncomment them:
Plugin 'git://github.com/tomtom/tcomment_vim'
" syntax highlighting for tmux files
" Plugin 'git://github.com/keith/tmux.vim'
" simpler align plugin : [cound]gl+object+at what eg 3glip=
Plugin 'tommcdo/vim-lion'
" auto linter
Plugin 'w0rp/ale'
" the vdebug debugger (perl, python)
Plugin 'joonty/vdebug'
" one C++ able debugger : vebugger
Plugin 'idanarye/vim-vebugger'
" same pane switching for vim and tmux
Plugin 'christoomey/vim-tmux-navigator'
" python tidy
Plugin 'minamorl/autopep8.vim'
" manpage viewer
Plugin 'powerman/vim-plugin-viewdoc'
" better move to chars: sxy ssb to move to (next Sab) prev ab or xy
Plugin 'justinmk/vim-sneak'
" colour investigator
"Plugin 'chrisbra/Colorizer'
" highlight the t T f and F move characters : buggsy
" Plugin 'unblevable/quick-scope'
" neovim api viewr
" Plugin 'tweekmonster/nvim-api-viewer'
" " default nvim colorscheme
" Plugin 'w0ng/vim-hybrid'
" " another colorscheme
" Plugin 'freeo/vim-kalisi'
" " a base-16 colorscheme
" " Plugin 'chriskempson/base16-vim'
" reddit plugin
"Plugin 'joshhartigan/vim-reddit'
" fast folding: only updated when opened, saved or moved
" Plugin 'Konfekt/FastFold'
" access Zeal automatically
"Plugin 'KabbAmine/zeavim.vim'
" railscasts theme
" Plugin 'chankaward/vim-railscasts-theme'
" align on '=' or : or ... (read the help)
" Plugin 'junegunn/vim-easy-align'
call vundle#end() " required: EVERYTHING before this
" --- post Vundle fixups
" apparently this is the order - old wives tale
if !has('nvim')
" done by default in neovim
" filetype on
" also calls ftdetect.vim
source /usr/share/vim/vimcurrent/filetype.vim
source ~/.vim/after/filetype.vim
"filetype indent on
source /usr/share/vim/vimcurrent/indent.vim
source ~/.vim/after/indent.vim
endif
" todo : check if this is called by any of the above scripts
" or by default by nvim. If so --> delete
"
"filetype plugin on
"" required: the \"plugin\" does languages other than C
if has ('nvim')
source /usr/share/nvim/runtime/ftplugin.vim
else
source /usr/share/vim/vimcurrent/ftplugin.vim
endif
syntax sync fromstart
let python_highlight_all=1
" --- non-vundle plugins
source /home/me/.vim/plugin_loadManually/cr-bs-del-space-tab.vim
"source /home/me/.vim/plugin_loadManually/bufkill.vim
source /home/me/.vim/plugin_loadManually/unite.vim
"- fix up the runtime path AGAIN
if has('nvim')
let &runtimepath='~/.config/nvim,/usr/share/nvim/runtime' . ',' . &runtimepath
endif
" ----- VAM plugin manager (w/ lazy loading) ---------------------
" set nocompatible | filetype indent plugin on | syn on
"
" fun! SetupVAM()
" let c = get(g:, 'vim_addon_manager', {})
" let g:vim_addon_manager = c
" let c.plugin_root_dir = expand('$HOME', 1) . '/.vim/vim-addons'
"
" " Force your ~/.vim/after directory to be last in &rtp always:
" " let g:vim_addon_manager.rtp_list_hook = 'vam#ForceUsersAfterDirectoriesToBeLast'
"
" " most used options you may want to use:
" " let c.log_to_buf = 1
" " let c.auto_install = 0
" let &rtp.=(empty(&rtp)?'':',').c.plugin_root_dir.'/vim-addon-manager'
" if !isdirectory(c.plugin_root_dir.'/vim-addon-manager/autoload')
" execute '!git clone --depth=1 git://github.com/MarcWeber/vim-addon-manager '
" \ shellescape(c.plugin_root_dir.'/vim-addon-manager', 1)
" endif
"
" " This provides the VAMActivate command, you could be passing plugin names, too
" call vam#ActivateAddons([], {})
" endfun
" call SetupVAM()
" VAMActivate github:tomtom/tcomment_vim
" VAMActivate github:keith/tmux.vim
" VAMActivate github:junegunn/vim-easy-align
" VAMActivate github:joonty/vdebug
" VAMActivate github:christoomey/vim-tmux-navigator
" VAMActivate github:
" VAMActivate github:
"--- modifying plugins
" auto linting: only run these linters
let g:ale_linters = {
\ 'javascript': ['eslint'],
\ 'perl' : ['perl -c', 'perlcritic'],
\ 'python' : ['pylint']
\}
" disble for a filetype with []
"let g:ale_linters = {'javascript': []}
" Always have the lh side 'gutter' open
" let g:ale_sign_column_always = 1
let g:ale_enabled = 0
let g:ale_lint_on_enter = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_insert_leave = 1
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_max_buffer_history_size = 10
let g:ale_lint_on_text_changed = 'never'
" E, W, I to mark errors
let g:ale_set_signs = 1
" - vdebug
inoremap <F6> <esc><F6>
" --- tmux and vim
" this is a hack to stop backspace being wrong
" when 1. using tmux and vim, and
" 2. using the vim-tmux-navigator plugin
" it is suggested in the vim-tmux-navigator readme
nnoremap <silent> <BS> :TmuxNavigateLeft<cr>
" --- I want NO scripts running on each keystroke
"" for the infinitely moronic plugins that operate on" EVERY! keypress. stupidity unbounded
au! CursorMovedI
au! CursorMoved
"--- F3 shows the syntax highlightintg of an element
nnoremap <F3> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" . " FG:" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"fg#")<CR>
" leave until finished "Learning Vimscript the hard way'
au VimEnter * echo "\>\^\-\^\<"
" ========== (2) === all, general options ============================
"
" ----- testing startup, debugging ------------------------------------
" version 1: tried and got log file
"let g:startup_profile_csv = "/tmp/viStartupProfile.csv"
"runtime macros/startup_profile.vim
" version 2: could not get to work
"profile start "/tmp/viStartupProfile.txt"
"set verbose=2
"----- Appearance (other than status line) -----------------------------
" colorscheme
" NEVER EVER include any vim-scripts dir as ALL the moronic scripts will be
" included into vim.
let g:change_colourscheme_on_mode = 0
colorscheme darkdevel
" NOTE: I have editied this colorscheme
" use syntax enable rather than syntax on
" stupid fucking old wives tale for messy vim
if !exists("g:syntax_on")
syntax enable
endif
autocmd BufWinEnter,BufNew * normal :syntax enable
" source /usr/share/nvim/runtime/syntax/syntax.vim
" tabs and linebreaks and indents
set tabstop=4
set shiftwidth=0 " if 0, then tabstop will be used
set autoindent
set wrap " must be on for the linebreak to work (no <CR>)
set linebreak
set brk=\ \ !@*-+;:,./?
set noexpandtab
" startup : no line numbers
set nonumber
set norelativenumber
" min width of the column of line numbers
set numberwidth=3
" stops the # comments being forced to the first column
" see help: smartindent (this is spelt out in the text)
" the ^H was inserted with CTRL-V CTRL-H, after disabling the CRTL-V == paste
" inoremap # X#
set cinkeys-=#
" --- page scrolls when near the bottom or top
" use 1000 or s.t. to force to always in the middle
set scrolloff=5
" cursor colours are set in ColoursBasedOnMode( )
" --- show specific chars for each white-space char
" this needs a toggle key, or only on in specific files
"set noexpandtab list
"let &listchars = 'tab:| '
" let &listchars = 'tab:| ,trail:_'
" highlight "GOTCHA" just like TODO
" match todo /GOTCHA/
" match todo /TO DEBUG/
" match todo /TO FIX/
" match todo /HERE:/
if has('nvim')
" the first of these is deprecated
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1
set guicursor=n-v-c:block-Cursor/lCursor-blinkon0,i-ci:ver25-Cursor/lCursor,r-cr:hor20-Cursor/lCursor
" true color in terminals
" set termguicolors
endif
"------ status line ---------------------------------------------------
"- command line and status line
set modeline
set showcmd " Show (partial) command in status line.
set ruler " show the cursor position all the time
"enable status line always
hi statusline ctermfg=white ctermbg=blue
set laststatus=2 " always display status line
" - v1
" cf the default statusline: %<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
" format markers:
" %< truncation point
" %n buffer number
" %f relative path to file
" %m modified flag [+] (modified), [-] (unmodifiable) or nothing
" %r readonly flag [RO]
" %y filetype [ruby]
" %= split point for left and right justification
" %-35. width specification
" %l current line number
" %L number of lines in buffer
" %c current column number
" %V current virtual column number (-n), if different from %c
" %P percentage through buffer
" %) end of width specification
"set statusline=%f%m%r%h%w[%n]\ [T=%Y]\ %=[R=%l]%=[C=%c][%p%%]
set statusline=%f%m%r%h%w[%n]\ [T=%Y]\ %=[\ %l\ %c\ ][\ %p%%\ ]
" - v2
set statusline=%<%f%#Visual#\ %y%m%w%=%l\/%-6L\ %0*%3c\
" ----- colours -----------------------------------------------------
" set background=dark " calls syntax/syncolors which calls heaps
set t_Co=256 " No
" Disable Background Color Erase (BCE) so that color schemes work
" properly within 256-color terminals
if &term =~ '256color'
set t_ut=
endif
autocmd BufWinEnter,BufNew * call ColoursBasedOnMode('n')
autocmd InsertEnter * call ColoursBasedOnMode('i')
autocmd InsertLeave * call ColoursBasedOnMode('n')
" noremap R :startreplace<CR><bar>:call ColoursBasedOnMode('r')<CR>
" inoremap ;; <c-o>:call ToModeWithColourChange('n')<c-o>h<CR>
" inoremap <ESC> <c-o>:call ToModeWithColourChange('n')<CR>
" inoremap <C-C> <c-o>:call ToModeWithColourChange('n')<CR>
" nnoremap i :call ToModeWithColourChange('i')<CR>
" nnoremap s :call ToModeWithColourChange('s')<CR>
" nnoremap S :call ToModeWithColourChange('S')<CR>
" nnoremap A :call ToModeWithColourChange('A')<CR>
" nnoremap I :call ToModeWithColourChange('I')<CR>
" nnoremap R :call ToModeWithColourChange('R')<CR>
" nnoremap C :call ToModeWithColourChange('C')<CR>
" nnoremap o :call ToModeWithColourChange('o')<CR>
" nnoremap O :call ToModeWithColourChange('O')<CR>
" nnoremap cw :call ToModeWithColourChange('cw')<CR>
" nnoremap ciw :call ToModeWithColourChange('ciw')<CR>
" nnoremap ciW :call ToModeWithColourChange('ciW')<CR>
" nnoremap cis :call ToModeWithColourChange('cis')<CR>
" nnoremap cip :call ToModeWithColourChange('cip')<CR>
" nnoremap cib :call ToModeWithColourChange('cib')<CR>
" nnoremap ciB :call ToModeWithColourChange('ciB')<CR>
" nnoremap caw :call ToModeWithColourChange('caw')<CR>
" nnoremap caW :call ToModeWithColourChange('caW')<CR>
" nnoremap cas :call ToModeWithColourChange('cas')<CR>
" nnoremap cap :call ToModeWithColourChange('cap')<CR>
" nnoremap cab :call ToModeWithColourChange('cab')<CR>
" nnoremap caB :call ToModeWithColourChange('caB')<CR>
" lskdjffldkdkgdgdkff
"----- backup ------------------------------------------------------
" this is a default. to be updated per file type
autocmd BufEnter,VimEnter * let b:buDir = "/work/BACKUP/vimBackups/all/"
" this is a default, to be updated per file type
au BufEnter,VimEnter * let b:buFilename = "some_unsaved_file"
au BufWritePre,BufFilePost,BufWinEnter * let b:buFilename = expand('%:t') " ideal
" BufEnter : looks like only when first entering the buffer, not every time?
" from help BufNew, same for BufUnload
" NOTE: When this autocommand is executed, the
" current buffer "%" may be different from the
" buffer being created "<afile>".
" --- autosave
set updatetime=60000
au! CursorHoldI,CursorHold,BufLeave * silent! :update
" only triggered once, until reset by some cursor or keyboard action
" --- backup
" autocmd CursorHold,CursorHoldI,BufUnload,FileAppendPost * silent :call AutoBackup()
autocmd CursorHold,CursorHoldI,BufWrite,BufUnload * :call AutoBackup()
" Do not run on every BufLeave : too much (?)
" the BufUnload is NOT triggered when closing a file, and when leaving vim.
" BufLeave is NOT run on :q leaving vim/ a vim file
" Do not call repeatidly
autocmd BufAdd,BufEnter * let b:lastBuTime="dog"
autocmd BufAdd,BufEnter * let b:lastBuFN ="cat"
function! AutoBackup()
" buftype holds \"help\", \"quickfix\" ... indicating special buffers
if !empty(&buftype)
" :echo "not backing-up this file as bufftype is ".&buftype
"sleep 1
return
endif
" do not make backups of read-only files
if &readonly != 0
" :echo "the readonly flag is ".&readonly." so no auto-backup made"
" sleep 10
return
endif
" not more than one BU / minute / file
let b:newBuTime=strftime('%Y-%b-%d__%H:%M')
let b:newBuFN=b:buFilename
if (b:newBuTime == b:lastBuTime) && (b:newBuFN == b:lastBuFN)
return
endif
let b:lastBuTime = b:newBuTime
let b:lastBuFN = b:newBuFN
" ok, make a backup
silent execute ':write! >> '.b:buDir.'vim_bu_'.strftime('%Y-%b-%d__%H:%M:%S').'_'.b:buFilename.'.bu.txt '
echo 'just made a backup'
" sleep 1
endfunction
" this stops vim-forced syncing
if !has('nvim')
set swapsync=""
endif
" a more detailed autosave is https://github.com/907th/vim-auto-save.git
"----- global, meta keyboard, keystroke modifications --------------
"if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
" set fileencodings=utf-8,latin1
"endif
set encoding=utf8
set fileencodings=utf8
set keymap=sdm_tk " in $HOME/.vim/keymap/
source ~/.config/nvim/keymap/sdm_tk_utf-8.vim
set bs=2 " allow backspacing over everything in insert mode
" remove the normal mode C-o jumps in history
nnoremap <C-o> <left><right>
" ----- shortcuts, special combinations, customizations ---------------
" kill all beeps
set vb t_vb=
" enable the mouse in terminals
"The mouse can be enabled for different modes:
" n Normal mode
" v Visual mode
" i Insert mode
" c Command-line mode
" h all previous modes when editing a help file
" a all previous modes
" r for |hit-enter| and |more-prompt| prompt
" the 'v' was making it go auto-select on move
set mouse=ncih
"--- quick search replace :s always pre-formatted
" nnoremap :S :%s,,,g<Left><Left><Left>
" vnoremap :S :s,,,g<Left><Left><Left>
"- ;; make ;; also leave insert mode
vnoremap ;; <C-C>
inoremap ;; <C-C>
if has('nvim')
tnoremap ;; <C-\><C-n>
tnoremap <esc> <C-\><C-n>
endif
" make jk also leave insert mode
" vmap jk <C-C>
" imap jk <C-C>l
"- ;w Fast saving
nnoremap <leader>w :wa!<cr>
vnoremap <leader>w <C-C>:wa!<cr>
inoremap <leader>w <c-o>:wa!<cr>
"- ;q Fast save-and-quit <C-C> to ensure that it works
nnoremap <leader>q <C-C>:wa!<cr>:qa<cr>
vnoremap <leader>q <C-C>:wa!<cr>:qa<cr>
imap <leader>q <C-C><leader>q " imap so that the ;q works
"- ;e Fast editing of the .vimrc
"map <leader>e :!sudo nvim /etc/vim/vimrc<cr>
"- ;ev easy editing of vimrc " I don't use this:
"nnoremap <leader>ev :vsplit /etc/vim/vimrc<cr>
"- Q fast scratch-macro qq...do it...q Q:play it
nnoremap Q @q
vnoremap Q :norm @q<cr>
"--- ;d ;t insert date & time
inoremap <leader>d <C-R>=strftime("%Y-%m-%d")<CR>
nnoremap <leader>d i<C-R>=strftime("%Y-%m-%d")<CR><C-[>ll
inoremap <leader>t <C-R>=strftime("%k:%M")<CR>
nnoremap <leader>t i<C-R>=strftime("%k:%M")<CR><C-[>ll
"--- ;r show relative numbers
inoremap <leader>r <c-o>:set invnumber<bar>:set invrelativenumber<CR>
nnoremap <leader>r :set invnumber<bar>:set invrelativenumber<CR>
" --- UPPERCASE the current word in insert mode
inoremap <c-u> <esc>mzviwU`zi
"---- *** makes the bullet '•'
" iabbrev *** •<tab><BS><tab>
" iabbrev ;* •<tab><BS><tab>
function! Insert_n_Dot()
:startinsert
call feedkeys("•")
call feedkeys("\<tab>",'n')
:stopinsert
return
endfunction
"nmap ;* :call Insert_n_Dot( )
"<bar>call feedkeys('\<DEL>',n')<cr>
"nmap ;* i•<tab><esc><right>
inoremap ;* •<tab>
nnoremap ;* i• <esc><right>
"----- movement customizations ------------------------------------
"--- j k l h
" in NORMAL and VISUAL mode, make the move keys go straight up & down
nnoremap j gj
vnoremap k gk
vnoremap <up> gk
vnoremap <down> gj
vnoremap <end> g<End>
nnoremap j gj
nnoremap k gk
nnoremap <up> gk
nnoremap <down> gj
nnoremap <end> g<End>
" L and H go to the start and the end of the line
nnoremap L $
nnoremap H ^
vnoremap L $
vnoremap H ^
"--- CTRL-U CTRL-D in insert mode
inoremap <C-U> <C-O><C-U>
inoremap <C-D> <C-O><C-D>
" mover teh current line up or down
nnoremap - ddjP
nnoremap _ ddkP
" and $ and ^ go one space left and right
" nnoremap $ L
" nnoremap ^ H
" vmap $ L
" vmap ^ H
" omap $ L
" omap ^ H
"--- make ctrl + arrows work properl
" map  xi
" map! OA ka
" map! Ob ja
" map! Oc la
" map! Od k
" ^[ == Ctrl-V, Ctrl-[
" ^? == Ctrl-V, BackSpace
" set t_ku=OA
" set t_kd=OB
" set t_kr=OC
" set t_kl=OD
"
" ^[OA generated by pressing Ctrl-V and [Up] key.
" ^[OB generated by pressing Ctrl-V and [Down] key.
" ^[OC generated by pressing Ctrl-V and [Right] key.
" ^[OD generated by pressing Ctrl-V and [Left] key.
"in INSERT mode, get the vim default up/down behaviour
" the shift-arrow gets replaced by ^[[a and ^[[b
"imap <S-up> <C-o>gk
"imap <S-down> <C-o>gj
"imap <S-end> <C-o>g<End>
" --- moving while editing
" non-retarded simple movements.
"set ve=all " cursor can be anywhere, even where no text
" " block: all in visualmode; onemore: just one char past eol
set virtualedit=block,onemore
nnoremap $ $l
" READ THIS --> there is a SPACE char after the 'f'
nnoremap e f
" eol deletes
"map <BS> <C-H>
set backspace=eol,start,indent
" don't use :fixdel as it fucks up all kinds of simple editing
"--- When opening a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal! g'\"" |
\ endif
"--- ;j ;k moving a line or block
" nnoremap <leader>j :m .+1<CR>==
" nnoremap <leader>k :m .-2<CR>==
" inoremap <leader>j <Esc>:m .+1<CR>==gi
" inoremap <leader>k <Esc>:m .-2<CR>==gi
" vnoremap <leader>j :m '>+1<CR>gv=gv
" vnoremap <leader>k :m '<-2<CR>gv=gv
"--- inter window, inter-pane movements
" move windows with Alt + hjkl
inoremap <M-h> <C-o><C-w>h
inoremap <M-j> <C-o><C-w>j
inoremap <M-k> <C-o><C-w>k
inoremap <M-l> <C-o><C-w>l
nnoremap <M-h> <C-w>h
nnoremap <M-j> <C-w>j
nnoremap <M-k> <C-w>k
nnoremap <M-l> <C-w>l
" incl to/from a terminal window
if has("nvim")
tnoremap <M-h> <C-\><C-n><C-w>h
tnoremap <M-j> <C-\><C-n><C-w>j
tnoremap <M-k> <C-\><C-n><C-w>k
tnoremap <M-l> <C-\><C-n><C-w>l
" start nvim term in insert mode
autocmd BufEnter term://* startinsert
endif
"--- CTRL-J, CTRL-K (map)cycle through windows WITHIN A PANE
nnoremap <C-J> :bp<CR>
nnoremap <C-K> :bn<CR>
inoremap <C-J> <C-o>:bp<CR>
inoremap <C-K> <C-o>:bn<CR>
"--- move between tabs: doesn't work
nnoremap <C-Left> gt<CR>
nnoremap <C-Right> gT<CR>
inoremap <C-Left> <C-o>gt<CR>
inoremap <C-Right> <C-o>gT<CR>
"--- Window operations : ctrl-w as window operations ONLY
inoremap <C-w> <C-o><C-W>
inoremap <C-W> <C-o><C-W>
" close a window, keep the frame open
" No: use :BD for this (plugin)
"map <C-d> <C-o>:q<CR><C-w>v<C-J>
" ----- editing customizations -----------------------------------
"--- Search and matching :
nnoremap N Nzz " search will center on the line it's found in.
nnoremap n nzz
set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
set incsearch " Incremental search
set complete=.,w,b,u,t " searching for ctrl-P (NO 'i' -recursive incl)
" highlight search
" hlsearch is on at startup
set hlsearch " highlight all matching search words
" hlsearch is off in insert mode; on in normal mode
au InsertEnter * :setlocal nohlsearch
au InsertLeave * :setlocal hlsearch
"- ;l remove any search highlighting
" could poss do i_CTRL-X_CTRL-V to do this one " command
noremap <silent><leader>l :set hlsearch! hlsearch?<CR>
inoremap <silent><leader>l <c-o>;l<CR>
noremap <silent><leader>L /sldkfjsldkfj<CR>
inoremap <silent><leader>L <c-o>;L<CR>
" no active search string on opening a new file
autocmd BufNewFile,BufNew,BufRead * let @/ = 'sdkfjlsdfj879hhhafkjhk872983l'
" show all of the tags related to a word
" ;t someword retruns all of the tags, references to that word
nnoremap <leader>t :ltag<space>/ \| lop<left><left><left><left><left><left>
"---copy and paste
"
"selection only includes the text the cursor moved over, NOT text UNDER cursor
"default value is "inclusive": include the character under the cursor
set selection=exclusive
" - CTRL-V copy paste Ctrl-V
" WARNING: THIS OVERRIDES THE CTRL-V's insert-special-char FUNCTION !!!
" To insert special chars (once each year):
" 1. comment out the two mappings below
" 2. restart Vim
" 3. insert the special char
" 4. un-comment these lines, again, in this: vimrc
" ( 5. restart vim )
"
" use the same clipboard as all other apps, no "+g
"try the '+' register instead of '*'
set cb=unnamedplus
inoremap <C-v> <C-o>"*p<c-o>:set nopaste<CR><c-o>:set showmode<CR>
nnoremap <C-v> "*p:set nopaste<CR>:set showmode<CR>
"- gb: select last paste in visual mode
nnoremap <expr> gb '`[' . strpart(getregtype(), 0, 1) . '`]'
set nopaste
" - ;y ;p and ;P - copy and paste to system clipboard
nnoremap <Leader>y "+y
nnoremap <Leader>p "+p
nnoremap <Leader>P "+P
vnoremap y "+y
vnoremap p "+p
vnoremap P "+P
" yc for "yank character"
nnoremap yc yl
set breakindent " next line start at the same indent --> aligned
" --- bullet lists:
setlocal comments=fnb:*,fb:-->,fb:•,fb:#
" b blank required after comment leader
" n nesting of comments - * - comments here
" f only first line has leader, the rest spaces: <--- whole paragraph notes
" fb:*, a comment type that starts with * and the * must be followed by a
" blank and is only on the first line of the comment.
" NOTE: at one time I thopught 'f' FUCKS line continuation
" NOTE: only '-->' makes whole-paragraph notes
" GOTCHA : it is formatlistpat that aligns AFTER the bullet
" formatlistpat implements the 'n' of the formatoptions string
" default: a number plus one of ]:,)}\t or space ... then any character
" let &formatlistpat='^\s*\d\+[\]:.)}\t ]\s*'
" default OR * or - followed by a tab or space
" let &formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|[*-][\t ]\)\s*'
" Recognise lists like 1), 1., a), a., and so on
" Note that | need to be escaped AND preceeded by a literal backslash
" set formatlistpat=^\\s*\\([0-9]\\+\\\|[a-z]\\)[\\].:)}]\\s\\+
" My attempt:
" ANY combiniation of - and > will be recognised as number list and
" the sceond line should be indented to the text
" doesn't work:
"let &formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|\-\-\>[\t ]\)\s*'
" doesnt' work
let &formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|\-\-\>[\t ]\)\s*'
" doesn't work
let &formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|[-\>]\+[\t ]\)\s*'
" doesn't work:
let &formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|-->[\t ]\)\s*'
" let &formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|\-\-\>[\t ]\)\s*'
" let &formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|\-\-\>[\t ]\)\s*'
" let &formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|\-\-\>[\t ]\)\s*'
" let &formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|\-\-\>[\t ]\)\s*'
" let &formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|\-\-\>[\t ]\)\s*'
" let &formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|\-\-\>[\t ]\)\s*'
" let &formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|\-\-\>[\t ]\)\s*'
" let &formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|\-\-\>[\t ]\)\s*'
setlocal formatoptions+=n
"--- F7 spelling F7
inoremap <F7> <C-o>:set invspell spelllang=en_gb<CR>
nnoremap <F7> :set invspell spelllang=en_gb<CR>
inoremap <leader>Z <C-o>z=
nnoremap <leader>Z z=
" add words to my custom spellfile (as correctly spelt words)
inoremap <leader>a <C-o>zg
nnoremap <leader>a zg
" for some reason the file ~/.vim/spell/en.utf-8.add is used instead ???
set spellfile="/home/me/.vim/customVimSpellingWords.utf-8.add"
au! CursorMovedI " for the infinitely moronic plugins that operate on
au! CursorMoved " EVERY! keypress. stupidity unbounded
" - spelling corrections
iab techncial technical
iab documentaion documentation
iab upwork Upwork
" ----- custom setups for different file types -------------------------
" jump to help screen for the word under the cursor
" interferred with other plugins (the 'h') and didnt' use
"autocmd FileType vim,help setlocal keywordprg=:help
" detect filetypes, make the filetype event be triggered for a new file
" filetype on
autocmd BufNewFile,BufNew * let b:sdm_setup = 'not set'
" --- final determination of filetypes
" should be done by ftdetect scripts
autocmd BufRead */share/vim/*/doc/* setlocal filetype=help
autocmd BufNewFile,BufRead *.notes,*/bench/notes/* setlocal filetype=text
autocmd BufRead,BufNewFile *.csv,*.dat setlocal filetype=csv
autocmd BufNewFile,BufReadPre,BufNew,BufRead *.pll setlocal filetype=perl
autocmd BufNewFile,BufReadPre,BufNew,BufRead *.wordlist let b:sdm_setup = 'sdm_wordList'
autocmd BufRead */share/vim/*/doc/* setlocal filetype=help
"autocmd BufRead /etc/* setfiletype sh
" au FileType perl let b:delimitMate_autoclose=1
" runtime! autoload_manually/delimitMate.vim " different
" runtime! plug_loadManually/delimitMate.vim " different
" --- before calling the setup functions
" - file skeletons
" proofread time recording files *.time
autocmd BufNewFile *.time 0r ~/.vim/file_skeletons/skeletonFile.time
" some reason, can not be in the Setup_perl
autocmd BufNewFile *.pll 0r ~/.vim/file_skeletons/minimal_skeleton.pl
autocmd BufNewFile *.pl 0r ~/.vim/file_skeletons/skeleton.pl
autocmd BufNewFile *.py 0r ~/.vim/file_skeletons/minimal_skeleton.pythonx
" default, also for blank buffers
"setfiletype unknown " triggering all kinds of stuff.
" --- the setup functions
autocmd Filetype mail call Setup_mail_buffers()
autocmd Filetype text call Setup_text_buffers()
autocmd Filetype perl call Setup_perl_buffers()
autocmd Filetype python call Setup_python_buffers()
autocmd Filetype c call Setup_C____buffers()
autocmd Filetype cpp call Setup_cpp__buffers()
autocmd Filetype sql call Setup_sql__buffers()
autocmd Filetype csv call Setup_csv__buffers()
autocmd Filetype vim call Setup_vim__buffers()
autocmd Filetype help call Setup_help_buffers()
autocmd Filetype sh call Setup_sh___buffers()
autocmd Filetype debsources call Setup_sh___buffers()
autocmd Filetype processing call Setup_processing_buffers()
autocmd Filetype javascript call Setup_js__buffers()
autocmd Filetype vba call Setup_vba__buffers()
autocmd Filetype html call Setup_html_buffers()
autocmd Filetype xhtml call Setup_html_buffers()
autocmd Filetype man call Setup_man__buffers()
"autocmd Filetype ??? call Setup_???__buffers()
autocmd BufNewFile,BufReadPre,BufNew,BufRead *.wordlist call Setup_wordlist_file()
autocmd BufRead,BufNew *.vba.gz call Setup_vba__buffers( )
autocmd Filetype unknown call Setup_unknown_filetype()
"autocmd BufNewFile * call Setup_unknown_filetype( )
" another filetype has been set
" assumption: all other types will be coding files ( TODO fix this )
" autocmd BufRead,BufNew,BufNewFile *
" \if (&b:sdm_setup == 'not set') |
" \ call SetCodingTextFormatOptions( ) |
" \ let b:sdm_AnotherFiletype_noSetup = 1 |
" \endif
"
" no filetype has been set
autocmd BufRead,BufNewFile *
\if (&ft == 'unknown') || (&ft == '') |
\ set background=dark |
\ call Setup_unknown_filetype() |
\endif
"autocmd Filetype * call Setup_unknown_filetype()
"autocmd Filetype unknown call Setup_unknown_filetype()
" ========== (4) === the set_XXX_buffers() funciton ==========================
"
"
" ---
function Setup_mail_buffers()
if !exists("g:syntax_on")
syntax enable
endif
set background=dark
runtime syntax/mail.vim " had to call this to get mail colors.
call SetNonCodingTextFormatOptions()
call SetupToggleAutoFormatting()
let b:buDir = "/work/BACKUP/vimBackups/email/"
let b:buFilename = "email"
setlocal tw=76
setlocal fo-=r " no comment continuation
setlocal fo+=t " do the wrap-at-line-length thing (in emails)
setlocal fo+=a " DO auto manage paragraphs in
" setlocal fo-=a " DO NOT auto manage paragraphs in
setlocal fo+=tca " Hack: to get the options in the correct order
" for the ctrl-f add-remove ... hack
"- spelling
setlocal spell spelllang=en_gb " also normal, mutt email
imap z= <C-o>z=
"- toggle spelling
" special name-replace keys for mutt
map <leader>1 1G/^From: /e+1<CR>Di
\ Stephen McGregor <[email protected]><Esc>
map <leader>2 1G/^From: /e+1<CR>Di
\ Stephen McGregor <[email protected]><Esc>
map <leader>3 1G/^From: /e+1<CR>Di
\ Stephen McGregor <[email protected]><Esc>
map <leader>4 1G/^From: /e+1<CR>Di
\ Stephen McGregor <[email protected]><Esc>
map <leader>5 1G/^From: /e+1<CR>Di
\ Stephen McGregor <[email protected]><Esc>
let b:sdm_setup = "sdm email"
endfunction
"---
function Setup_text_buffers()
set background=dark
" filetype indent on
" filetype plugin on
call SetNonCodingTextFormatOptions()
call SetupMultiWindow()
call SetupToggleAutoFormatting()
let b:buDir = "/work/BACKUP/vimBackups/text/"
setlocal fo-=a " no automange lines
" --- spelling:
" no spell checking for textfile (other than *.ttt)
autocmd BufNewFile,BufRead *.txt setlocal nospell
" but spell check *ttt files
autocmd BufNewFile,BufRead *.ttt setlocal spell
autocmd BufNewFile,BufRead *.ttt setlocal spell spelllang=en_gb
" cursor line colours set in ColourBasedOnMode() now
" remove any cursor moved commands
au! CursorMovedI
au! CursorMoved
let b:sdm_setup = "sdm text"
endfunction
"---
function Setup_perl_buffers()
set background=dark
" syntax on
"!PERLIO=:utf8 <-- want to add this to ENV
" runtime! autoload_manually/perlsupportgui.vim
" runtime! plugin_loadManually/perl-support.vim
" runtime! autoload_manually/delimitMate.vim " different
" runtime! plug_loadManually/delimitMate.vim " different
setlocal equalprg=perltidy\ -st
" runtime! plugin_loadManually/pod.vim " not sure
au FileType perl let b:delimitMate_autoclose=1
if has ('nvim')
source /usr/share/nvim/runtime/compiler/perl.vim
source /usr/share/nvim/runtime/ftplugin/perl.vim
source /usr/share/nvim/runtime/indent/perl.vim
source /usr/share/nvim/runtime/syntax/perl.vim
else
source /usr/share/vim/vimcurrent/compiler/perl.vim
source /usr/share/vim/vimcurrent/ftplugin/perl.vim
source /usr/share/vim/vimcurrent/indent/perl.vim
source /usr/share/vim/vimcurrent/syntax/perl.vim
endif
" do I even need these? I don't use them
" let g:Perl_MapLeader = '\' " ok, this is not my normal leader
" source /home/me/.vim/autoload_manually/perlsupportgui.vim
" source /home/me/.vim/plugin_loadManually/perl-support.vim
" runtime! autoload_manually/perlsupportgui.vim
" runtime! plugin_loadManually/perl-support.vim
call SetCodingTextFormatOptions()
call SetupMultiWindow()
call Setup_cscope()
let b:buDir = "/work/BACKUP/vimBackups/coding/"
" - sytax highlighting
syntax sync fromstart
let perl_include_pod = 1 "include pod.vim syntax file with perl.vim
"let perl_extended_vars = 1 "highlight complex expressions such as @{[$x, $y]}
"let perl_string_as_statement = 1
" see :help syntax-highlighting, :help ft-perl-syntax
" these are uncertain solutions to syntax failing on perl
" when scrolling
let perl_no_sync_on_sub = 0
let perl_no_sync_on_global_var = 0
let perl_sync_dist = 500 "use more context for highlighting"
" - fomatting, autoindenting
" perltidy on selected block and '='
au filetype perl setlocal equalprg=perltidy\ -st
" perltidy on whole file
imap <leader>pt <ESC>:%! perltidy<CR>
nmap <leader>pt :%! perltidy<CR>
" on selected section of file
vmap <leader>pt <ESC>:'<,'>! perltidy<CR>
" no indenting # comments
setlocal nocindent
set cinkeys -=#
set cinoptions+=L0
" apparently this works inoremap # X^H#
" ^H is entered with CTRL-V CTRL-H.
set background=dark " hack
au! CursorMovedI
au! CursorMoved
let b:sdm_setup = "sdm perl"
endfunction
"
"---
function Setup_C____buffers()
set background=dark
call SetCodingTextFormatOptions()
call SetupMultiWindow()
call Setup_cscope()
source /home/me/.vim/autoload_manually/delimitMate.vim
" " ;n inserts a comment
" imap <leader>n <C-o>mz<C-o>I// <esc>`z
" map <leader>n mzI// <esc>`z
" " ;N inserts a bigger comment
" imap <leader>N <C-o>mz<C-o>I// --- <esc>`z
" map <leader>N mzI// --- <esc>`z
" " ;n comments all selected lines in visual mode
" vmap <silent> <leader>n :norm i// <ESC>
" remove any cursor moved commands
au! CursorMovedI
au! CursorMoved
let b:buDir = "/work/BACKUP/vimBackups/coding/"
let b:sdm_setup = "sdm C code"
endfunction
"
"---
function Setup_cpp__buffers()
set background=dark
call SetCodingTextFormatOptions()
call SetupMultiWindow()
call Setup_cscope()
source /home/me/.vim/autoload_manually/delimitMate.vim
" " ;n inserts a comment
" imap <leader>n <C-o>mz<C-o>I// <esc>`z
" map <leader>n mzI// <esc>`z
" " ;N inserts a bigger comment
" imap <leader>N <C-o>mz<C-o>I// --- <esc>`z
" map <leader>N mzI// --- <esc>`z
" " ;n comments all selected lines in visual mode
" vmap <silent> <leader>n :norm i// <ESC>
" remove any cursor moved commands
au! CursorMovedI
au! CursorMoved
let b:buDir = "/work/BACKUP/vimBackups/coding/"
let b:sdm_setup = "sdm cpp"
endfunction
"
"---
function Setup_sql__buffers()
set background=dark
call SetCodingTextFormatOptions()
call SetupMultiWindow()
let b:buDir = "/work/BACKUP/vimBackups/coding/"
" remove any cursor moved commands
au! CursorMovedI
au! CursorMoved
let g:sql_type_default = 'mysql'
let b:sdm_setup = "sdm sql"
endfunction
"
"---
function Setup_csv__buffers()
set background=dark
syntax sync fromstart
runtime! plugin_loadManually/csv.vim
"call InitCSV( )
" --- standard stuff
call SetCodingTextFormatOptions()
call SetupMultiWindow()
" -----------------
" --- for the CSV columns plugin
"aug CSV_Editing
" au!
au BufRead,BufNew *.csv,*.dat :%ArrangeColumn
au BufRead,BufNew *.csv,*.dat set noro
au BufWritePre *.csv,*.dat :%UnArrangeColumn
"aug end
" au FileType csv :let b:csv_strict_columns = 1
" au FileType csv :let b:csv_delim='\t'
" au FileType csv :let g:csv_autocmd_arrange = 1
" au FileType csv :colorscheme distinguished
" au Filetype csv hi CSVColumnEven ctermfg=white ctermbg=darkgray
" au Filetype csv hi CSVColumnOdd ctermfg=black ctermbg=white
let b:csv_strict_columns = 1
let b:csv_delim='\t'
"let g:csv_autocmd_arrange = 1
hi CSVColumnEven ctermfg=white ctermbg=darkgray
hi CSVColumnOdd ctermfg=black ctermbg=white
" here ctermbg is the BACKGROUND colour for the EVEN columns
" here ctermbg is the FOREGROUND colour for the ODD columns
" -- look into this later
" set background=dark
" set t_Co=256 " necessary for 256 colour colorschemes
" set t_Co=16 " ok if the solarized terminal is used
" colorscheme distinguished
" ----
" NOTE: in the insertmode-replacemode ColoursBasedOnMode function
" the cursorline change has been taken out for filetype=csv
" - closing the file
autocmd BufWritePre *.csv, *.dat %UnArrangeColumn
" -------------------------------
"runtime! csv.vim
"call ArrangeColumn( ) " can only get it to do the current row
":ArrangeColumn
"call :ArrangeColumn( )
"Header 3 " traps the cursor in the header
set noro
let b:buDir = "/work/BACKUP/vimBackups/text/"
let b:sdm_setup = "sdm csv"
endfunction
"---
function Setup_vim__buffers()
set background=dark
call SetNonCodingTextFormatOptions()
call SetupMultiWindow()
call Setup_syntax_highlighting()
setlocal formatoptions=lcr
let b:buDir = "/work/BACKUP/vimBackups/text/"
" " ;n inserts a comment
" imap <leader>n <C-o>mz<C-o>I" <esc>`z
" map <leader>n mzI" <esc>`z
" " ;N inserts a bigger comment
" imap <leader>N <C-o>mz<C-o>I"--- <esc>`z
" map <leader>N mzI"--- <esc>`z
" ;n comments all selected lines in visual mode
" vmap <silent> <leader>n :norm i" <ESC>
" remove any cursor moved commands
au! CursorMovedI
au! CursorMoved
let b:sdm_setup = "sdm vim"
endfunction
"
"---
function Setup_processing_buffers()
set background=dark
call SetNonCodingTextFormatOptions()
call SetupMultiWindow()
let processing_doc_path="/usr/local/bin/processingDirectory/reference"
let b:buDir = "/work/BACKUP/vimBackups/coding/"
let b:sdm_setup = "sdm processing"
endfunction
"---
function Setup_help_buffers()
if !exists("g:syntax_on")
syntax enable
endif
let b:sdm_setup = "sdm help"
endfunction
" ---
function Setup_sh___buffers()
call SetCodingTextFormatOptions()
call SetupMultiWindow()
set background=dark
call Setup_syntax_highlighting()
set background=dark " hack
let b:buDir = "/work/BACKUP/vimBackups/coding/"
let b:sdm_setup = "sdm sh"
endfunction
" ---
function Setup_unknown_filetype()
set background=dark
call SetupToggleAutoFormatting( )
let b:buDir = "/work/BACKUP/vimBackups/text/"
let b:sdm_setup = "sdm unknown filetype"
" to have another go at the filetype
source /usr/share/vim/vimcurrent/scripts.vim
endfunction
" ---
function Setup_js__buffers()
set background=dark
runtime! ftplugin/javascript.vim
runtime! indent/javascript.vim
runtime! syntax/javascript.vim
runtime! autoload/javascriptcomplete.vim
call SetCodingTextFormatOptions()
call SetupMultiWindow()
runtime! autoload_manually/delimitMate.vim
" remove any cursor moved commands
au! CursorMovedI
au! CursorMoved
let b:buDir = "/work/BACKUP/vimBackups/coding/"
let b:sdm_setup = "sdm javascript"
endfunction
"---
function Setup_vba__buffers()
set background=dark
call SetupMultiWindow()
runtime! autoload_manually/delimitMate.vim
" remove any cursor moved commands
au! CursorMovedI
au! CursorMoved
so "/usr/share/vim/vimcurrent/plugin-manual/gzip.vim "
so "/usr/share/vim/vimcurrent/plugin-manual/vimballPlugin.vim"
let b:buDir = "/work/BACKUP/vimBackups/all/"
let b:sdm_setup = "sdm vba"
endfunction
"---
function Setup_html_buffers()
set background=dark
filetype detect
source $VIMRUNTIME/macros/matchit.vim
let b:match_debug = 1
au BufEnter *.html filetype detect " necessary to make matchit work
au BufRead *.html filetype detect
source $VIMRUNTIME/macros/matchTagAlways/plugin/MatchTagAlways.vim
source $VIMRUNTIME/macros/matchTagAlways/autoload/MatchTagAlways.vim
call SetCodingTextFormatOptions()
call SetupMultiWindow()
runtime! autoload_manually/delimitMate.vim
imap <leader>n <!-- --><c-o>6h
nmap <leader>n i<!-- --><esc>6hi
let b:buFilename = "some_unsaved_file"
let b:buFilename = expand('%:t') " ideal
let b:buDir = "/work/BACKUP/vimBackups/coding/"
let b:sdm_setup = "sdm html"
endfunction
function Setup_wordlist_file()
set background=dark
call SetNonCodingTextFormatOptions( )
call SetupMultiWindow( )
let b:buDir = "/work/BACKUP/vimBackups/text/"
imap <buffer> <Tab> <Tab><C-X><C-L>
set tabstop=37
" getting to the classification column
nmap ;. 0/<tab>\.<cr>la
imap ;. <esc>0/<tab>\.<cr>la
" putting 1, 2 or 3 in the classification column
nmap ;1 ;.1<esc>0j
imap ;1 ;.1<esc>0ji
nmap ;2 ;.2<esc>0j
imap ;2 ;.2<esc>0ji
nmap ;3 ;.3<esc>0j
imap ;3 ;.3<esc>0ji
au! CursorMovedI
au! CursorMoved
endfunction
" --- setup man files
function Setup_man__buffers()
set background=dark
call SetCodingTextFormatOptions() " for syntax highlighting
call SetupMultiWindow()
autocmd BufReadPost * if (&ft == 'man') | nmap q :quit | endif
autocmd BufLeave * if (&ft == 'man') | nunmap q | endif
let b:buDir = "/dev/null/"
let b:sdm_setup = "sdm man"
endfunction
" - setup python
function Setup_python_buffers()
set background=dark
call SetCodingTextFormatOptions()
call SetupMultiWindow()
source /home/me/.vim/autoload_manually/delimitMate.vim
" pytidy on whole file
imap <leader>pt <ESC>:%!/usr/bin/autopep8\ --max-line-length=200\ -<CR>
nmap <leader>pt :%!/usr/bin/autopep8\ --max-line-length=200\ -<CR>
" " on selected section of file
vmap <leader>pt <ESC>:'<,'>!/usr/bin/autopep8\ --max-line-length=200\ -<CR>
" for gq, == tidyups
setlocal formatprg=/usr/bin/autopep8\ --max-line-length=200\ -
" remove 80/70 char line limit
"let g:autopep8_args = "--aggressive --aggressive --max-line-length=200"
" ;pt --> python tidy
" nnoremap <buffer> <silent> <leader>pt :call autopep8#clean()<CR>
let b:buDir = "/work/BACKUP/vimBackups/coding/"
let b:sdm_setup = "sdm python"
endfunction
" - coding
"function Setup_???__buffers()
"
" set background=dark
" filetype plugin on " enables the /ftplugins for the filetype
" filetype indent on " enables /indent/this-file-type.vim
" call SetCodingTextFormatOptions()
" call SetupMultiWindow()
" runtime! autoload_manually/delimitMate.vim
"
" let b:buDir = "/work/BACKUP/vimBackups/coding/"
" let b:sdm_setup = "sdm ???"
"
"endfunction
"
" - coding
"function Setup_???__buffers()
"
" set background=dark
" filetype plugin on " enables the /ftplugins for the filetype
" filetype indent on " enables /indent/this-file-type.vim
" call SetCodingTextFormatOptions()
" call SetupMultiWindow()
" runtime! autoload_manually/delimitMate.vim
"
" let b:buDir = "/work/BACKUP/vimBackups/coding/"
" let b:sdm_setup = "sdm ???"
"
"endfunction
"
" ========== (5) === utility functions used elsewhere ==========================
"
"
" function! ToModeWithColourChange(toMode)
" if a:toMode==#'n' " ==# : case sensitive string match
" :stopinsert
" call ColoursBasedOnMode('n')
" return
" endif
"
" if a:toMode==#'i'
" :startinsert
" call ColoursBasedOnMode('i')
" return
" endif
"
" if a:toMode==#'R' " R : Replace mode
" :startreplace
" call ColoursBasedOnMode('r')
" return
" endif
"
" if a:toMode==#'A'
" :startinsert!
" call ColoursBasedOnMode('i')
" return
" endif
"
" if a:toMode==#'I'
" normal 0
" call feedkeys('I','n')
" call ColoursBasedOnMode('i')
" return
" endif
"
" if a:toMode==#'O'
" call feedkeys('O','n') " the letter 'O'
" call ColoursBasedOnMode('i')
" return
" endif
"
" if a:toMode==#'o'
" call feedkeys('o','n')
" call ColoursBasedOnMode('i')
" return
" endif
"
" if a:toMode==#'C'
" call feedkeys('C', 'n') " n : don't remap keys
" call ColoursBasedOnMode('i')
" return
" endif
"
" if a:toMode==#'s'
" call feedkeys('s', 'n') " n : don't remap keys
" call ColoursBasedOnMode('i')
" return
" endif
"
" if a:toMode==#'S'
" call feedkeys('S', 'n')
" call ColoursBasedOnMode('i')
" return
" endif
"
"
" if a:toMode==#'cw' " the ciX key mappings --> insert mode colours
" call feedkeys("cw",'n')
" call ColoursBasedOnMode('i')
" return
" endif
" if a:toMode==#'ciw' " the ciX key mappings --> insert mode colours
" call feedkeys("ciw",'n')
" call ColoursBasedOnMode('i')
" return
" endif
" if a:toMode==#'ciW'
" call feedkeys("ciW",'n')
" call ColoursBasedOnMode('i')
" return
" endif
" if a:toMode==#'cis'
" call feedkeys("cis",'n')
" call ColoursBasedOnMode('i')
" return
" endif
" if a:toMode==#'cip'
" call feedkeys("cib",'n')
" call ColoursBasedOnMode('i')
" return
" endif
" if a:toMode==#'ciB'
" call feedkeys("ciB",'n')
" call ColoursBasedOnMode('i')
" return
" endif
"
" if a:toMode==#'caw' " the caX key mappings --> insert mode colours
" call feedkeys("caw",'n')
" call ColoursBasedOnMode('i')
" return
" endif
" if a:toMode==#'caW'
" call feedkeys("caW",'n')
" call ColoursBasedOnMode('i')
" return
" endif
" if a:toMode==#'cas'
" call feedkeys("cas",'n')
" call ColoursBasedOnMode('i')
" return
" endif
" if a:toMode==#'cap'
" call feedkeys("cab",'n')
" call ColoursBasedOnMode('i')
" return
" endif
" if a:toMode==#'caB'
" call feedkeys("caB",'n')
" call ColoursBasedOnMode('i')
" return
" endif
" endfunction
"---
function SetCodingTextFormatOptions()
" FIRST syntax highlighting, then SECOND colorscheme
call Setup_syntax_highlighting()
"call SetupColorscheme() " solarized will corrupt if setup twice
" setlocal formatoptions=nqrlcj
setlocal formatoptions=nqrltj
" NEVER put 'a' in this !!!! (even if 'c' there)
" (Well, I have started to use 'a' again...)
" a - autofomat a paragraph whenever changed
" l - (limited autoformat) do not break lines or format long lines
" comments in help about making this work
" c - only comments are 'a' autoflowed
" = Bullets: autowrap and insert comment leader
" = ongoing comments (of comments)
" t - autowrap (of text)
" n - recognise numbered lists
" can format comments with gq
" r - auto insert comment (for bullets)
" o - auto insert after hitting o or O to insert
" w - any punct @ eol finishes paragraph
" 2 - use the SECOND line to setlocal para indent
" j - remove bullet (comment chars) when joining lines
" NOTE: the bulletlist charagters are just set once, not for differnt filetypes
" though, some filetypes will, of course, have to set their own options
setlocal browsedir=buffer
setlocal cindent " not really formatting
setlocal autowrite
setlocal tabstop=4
" to see non-printing characters like Tab & CR
"set listchars=tab:▸\ ,eol:¬
set listchars=tab:▸\
set nolist
" coding files should always be executeable
au BufWritePost *.pl,*.pll,*.sh,*.py silent execute ":!chmod a+x %"
" --- show brackets
" set showmatch " these highlight brackets
set matchpairs=(:) " without any moronic CursorMoved* commands
set matchpairs+=[:]
set matchpairs+={:}
set matchpairs+=<:>
set matchtime=3
au FileType * let b:delimitMate_matchpairs = "(:),[:],{:}"
" --- autoclosing quotes and brackets
" ino " ""<left>
" ino ' ''<left>
" ino ( ()<left>
" ino [ []<left>
" ino { {}<left>
ino {<CR> {<CR><CR>}<up>
endfunction
"------
function SetNonCodingTextFormatOptions()
syntax off
setlocal formatoptions=nqrlco
"setlocal formatoptions=nqrlto
setlocal tabstop=4
setlocal noexpandtab
setlocal browsedir=buffer
setlocal brk=\ \ !@*-+;:,./?
setlocal lbr
setlocal shiftwidth=0 " if zero, then tabstop will be used
setlocal wrap " must be on for the linebreak to work (no <CR>)
set linebreak
" absolutely NO auto-indenting for non-coding files
setlocal noautoindent
setlocal nocindent
setlocal nosmartindent
setlocal indentexpr=
" 2016-05-09 just making one global formatting option:
" then put in file-type specific customizations
"setlocal comments=nfb:*,fnb:-,fn:-->,bn:#,n:•
" b blank required after comment leader
" f only first line has leader, the rest spaces
" n nesting of comments - * - comments here
" at one time I thought 'f' FUCKS line continuation
" - HACK: this ins't being maintained from initial setup
" - cursor line colour
" highlight CursorLine ctermbg=Darkblue ctermfg=red
"hi clear CursorLine
" hi CursorLine cterm=underline ctermbg=15
"hi CursorLine gui=underline cterm=underline ctermfg=black ctermbg=yellow guifg=None
"hi CursorLine ctermbg=black ctermfg=darkblue
endfunction
" -----
function SetupToggleAutoFormatting()
"- toggle autoformatting
" source: http://vim.wikia.com/wiki/Toggle_auto-wrap
nmap ;F :setl sr! fo<C-R>=strpart("-+",&sr,1)<CR>=tc<CR>
imap ;F <C-o>:setl sr! fo<C-R>=strpart("-+",&sr,1)<CR>=tc<CR>
" #sdm# I added the 'a' at the end
nmap ;f :setl sr! fo<C-R>=strpart("-+",&sr,1)<CR>=tca<CR>
imap ;f <C-o>:setl sr! fo<C-R>=strpart("-+",&sr,1)<CR>=tca<CR>
endfunction
" -----
function SetupMultiWindow()
endfunction
" -----
function Setup_cscope()
if has("cscope")
setlocal csprg=/usr/bin/cscope
setlocal csto=0
setlocal cst
setlocal nocsverb
" add any database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add database pointed to by environment
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
setlocal csverb
endif
endfunction
"---
function Setup_syntax_highlighting()
" syntax on
" syntax sync fromstart
" set background=dark " hack: light bg from the syntax
endfunction
" these are Start Insert and Exit Insert
" they set the cursor shape
" these are console_codes(4)
"let &t_SI = "\<Esc>]50;CursorShape=1\x7"
"let &t_EI = "\<Esc>]50;CursorShape=0\x7"
" --- basic color changes dependent on mode
function ColoursBasedOnMode(mode)
" under the solarized colour scheme, the status line colours get swapped
" so I have had to pre-re-swap them here.
" statusline, modeline and prense of an empasised current line (cul) are done
" here.
" but color settings are being overridden in BOTH colorschemes.
" to get them to work, have to remove those settings from BOTH colorschemes
" getting the cursorline to underline is an example. had to remove the cursorline
" setting from BOTH of the colorschemes, then it underlined
" and THEN I had to remove it from root's version (vim-vundle-managed/...)
" see http://wiki.bash-hackers.org/scripting/terminalcodes
" tho make a change on (afeer) every colourscheme change, do s.t. like:
" autocmd ColorScheme * hi Search ctermfg=Red ctermbg=White cterm=NONE
" " --- termcap codes, see help termcap-cursor-color
" " these are console_codes(4)
" BUT: no good for neovim
"
" let &t_SI = "\<Esc>]12;yellow\x7"
" let &t_SR = "\<Esc>]12;red\x7"
" let &t_EI = "\<Esc>]12;blue\x7"
" solid underscore
" let &t_SI .= "\<Esc>[4 q"
" solid block
" let &t_EI .= "\<Esc>[1 q"
" 1 or 0 -> blinking block
" 3 -> blinking underscore
" Recent versions of xterm (282 or above) also support
" 5 -> blinking vertical bar
" 6 -> solid vertical bar
" --- replace mode
if a:mode ==# 'r'
" echo " ColoursBasedOnMode REPLACE mode"
" sleep 3
if g:change_colourscheme_on_mode
colorscheme desert
endif
" colorscheme superman
hi statusline ctermfg=red ctermbg=white
hi ModeMsg ctermbg=red ctermfg=white
" colours for line numbers and the cursor's current line's number
" no line numbers in replace mode
highlight LineNr ctermfg=160 ctermbg=white guifg=#303030
highlight CursorLineNr ctermfg=black ctermbg=160 gui=bold guifg=Yellow
" setlocal cul
redraw
"--- insert mode
elseif a:mode ==# 'i'
" echo " ColoursBasedOnMode insert mode"
" sleep 3
if g:change_colourscheme_on_mode
set background=dark
source /home/me/.vim/plugins_local_vundleManaged/vim-hybrid/colors/hybrid.vim
" text colours
hi Normal ctermbg=black
hi text ctermbg=black
endif
" curson line
set cursorline
" hi Cursorline ctermbg=black
" status line
hi statusline ctermfg=yellow ctermbg=black
hi ModeMsg ctermfg=black ctermbg=yellow
" visual
" no visual in insert mode
" line numbers
"set nonumber
"set norelativenumber
highlight LineNr ctermfg=226 ctermbg=232 guifg=#303030
highlight CursorLineNr ctermfg=black ctermbg=yellow gui=bold guifg=Yellow
" non-colour mode changes
let b:ale_enabled = 0
ALEDisable
" grey (default) comments when actually writing
highlight Comment ctermfg=DarkGray guifg=#646464 ctermbg=NONE guibg=NONE
redraw
" --- normal mode
elseif a:mode ==# 'n'
" echo " ColoursBasedOnMode normal mode"
" sleep 3
if g:change_colourscheme_on_mode
set background=dark
source /home/me/.vim/plugins_local_vundleManaged/vim-kalisi/colors/kalisi.vim
" text colours
hi Normal ctermbg=gray
hi text ctermbg=gray
endif
" couros line
set nocul
" status line
hi statusline ctermfg=white ctermbg=black
hi ModeMsg ctermfg=white ctermbg=black
" visual
highlight Visual ctermbg=white ctermfg=darkblue
" line numbers
"set nonumber
"set norelativenumber
highlight LineNr ctermfg=white guifg=#303030
highlight CursorLineNr ctermfg=black ctermbg=white gui=bold guifg=Yellow
" non-colour mode changes
let g:ale_enabled = 1
let b:ale_enabled = 1
ALEEnable
ALELint
ALEDetail
let g:ale_echo_cursor = 1
let g:ale_set_highlights = 1
let g:ale_echo_cursor = 1
let g:ale_lint_on_enter = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_insert_leave = 1
let g:ale_history_enabled = 1
let g:ale_history_log_output = 1
let g:ale_max_buffer_history_size = 10
let g:ale_lint_on_text_changed = 'never'
" E, W, I to mark errors
let g:ale_set_signs = 1
" nnoremap <Down> <Down>:ALEDetail<cr>
" nnoremap <Up> <Up>:ALEDetail<cr>
" nnoremap j <Down>:ALEDetail<cr>
" nnoremap k <Up>:ALEDetail<cr>
" yellow comments when reading
highlight Comment ctermfg=yellow guifg=#646464 ctermbg=NONE guibg=NONE
redraw
" --- error
else
echo "Bad parameter " . a:mode ." passed to ColoursBasedOnMode"
sleep 10
endif
if !exists("g:syntax_on")
syntax enable
endif
"source /usr/share/vim/vim80/syntax/syntax.vim
endfunction
"---- this gets done to all that haven't been set up
" this is required to have novel filetypes get syntax highlighting AND solarized
" call Setup_unknown_filetype( )
" ============= reference =============================================
" --- varible types
" (nothing) In a function: local to a function; otherwise: global
" buffer-variable b: Local to the current buffer.
" window-variable w: Local to the current window.
" tabpage-variable t: Local to the current tab page.
" global-variable g: Global.
" local-variable l: Local to a function.
" script-variable s: Local to a :source'ed Vim script.
" function-argument a: Function argument (only inside a function).
" vim-variable v: Global, predefined by Vim.
"--- about mapping
" map - Normal, Visual, Operator-pending
" nmap - Normal
" vmap - Visual
" omap - Operator-pending : after a : / or in the middle of a command
" map! - Insert & Command-line
" imap - Insert
" cmap - Command-line
"
"the "noremap" command. This basically tells Vim not to look for another keyboard mapping after loading the current one.
" --- specific colour targets
" - the first of every group is the default for the group
" highlight Normal ctermbg=None
" highlight Normal ctermbg=darkgray
" highlight Comment ctermfg=none ctermbg=none
" highlight Comment ctermfg=lightyellow " ctermbg=darkgray
"
" highlight Statement ctermfg=green " ctermbg=darkgray
" highlight Conditional ctermfg=blue " ctermbg=darkgray
" highlight Repeat ctermfg=blue " ctermbg=darkgray
" highlight Label ctermfg=blue " ctermbg=darkgray
" highlight Keyword ctermfg=blue " ctermbg=darkgray
"
" highlight Constant ctermfg=red " ctermbg=darkgray
" highlight String ctermfg=red " ctermbg=darkgray
" highlight Character ctermfg=red " ctermbg=darkgray
" highlight Number ctermfg=red " ctermbg=darkgray
" highlight Boolean ctermfg=red " ctermbg=darkgray
" highlight Float ctermfg=red " ctermbg=darkgray
"
" highlight Type ctermfg=magenta " ctermbg=darkgray
" highlight Todo ctermfg=red ctermbg=yellow
" highlight Error ctermfg=white ctermbg=red
" highlight Visual ctermbg=white ctermfg=black
" ======================= now ... =================================
"
"
" everything in RTP/plugin/**/*.vim is loaded:
" everything in /usr/share/nvim/runtime/plugin/* is loaded
" /.hw/home/me/.config/nvim/plugin/*
" /.hw/home/me/.vim/plugins_local_vundleManaged/* AGAIN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment