~gpanders/dotfiles

5a9dcc4e7be1b0fa4c8963c29322e1cc22b98a7a — Greg Anders 2 years ago ca69601
Restructure vim directory to take advantage of autoloading features

See: https://vimways.org/2018/from-vimrc-to-vim/
M vim/.gitignore => vim/.gitignore +3 -1
@@ 1,3 1,5 @@
.vim/.netrwhist
.vim/plug
.vim/session
.vim/.netrwhist
.vim/pack
.vim/cache

A vim/.vim/after/ftplugin/c.vim => vim/.vim/after/ftplugin/c.vim +24 -0
@@ 0,0 1,24 @@
" C
if &filetype !=# 'c'
  finish
endif

" Set comment string
setlocal commentstring=//%s

" Include macros in completion
setlocal complete+=d

" Set include pattern
setlocal include=^\\s*#\\s*include

" Include headers on Unix
if has('unix')
  setlocal path+=/usr/include
endif

if executable('clang-format')
  setlocal formatprg=clang-format
endif

let b:undo_ftplugin .= '|setlocal commentstring< complete< include< path<'

M vim/.vim/after/ftplugin/cpp.vim => vim/.vim/after/ftplugin/cpp.vim +19 -5
@@ 1,10 1,24 @@
" C / C++
setlocal shiftwidth=2
setlocal tabstop=2
setlocal softtabstop=2
" C++
if &filetype !=# 'cpp'
  finish
endif

" Set comment string
setlocal commentstring=//%s
setlocal cindent

" Include macros in completion
setlocal complete+=d

" Set include pattern
setlocal include=^\\s*#\\s*include

" Include headers on Unix
if has('unix')
  setlocal path+=/usr/include
endif

if executable('clang-format')
  setlocal formatprg=clang-format
endif

let b:undo_ftplugin .= '|setlocal commentstring< complete< include< path<'

M vim/.vim/after/ftplugin/crontab.vim => vim/.vim/after/ftplugin/crontab.vim +6 -0
@@ 1,3 1,9 @@
" crontab
if &filetype !=# 'crontab'
  finish
endif

setlocal nobackup
setlocal nowritebackup

let b:undo_ftplugin .= '|nobackup< nowritebackup<'

M vim/.vim/after/ftplugin/help.vim => vim/.vim/after/ftplugin/help.vim +4 -0
@@ 1,3 1,7 @@
if &filetype !=# 'help'
  finish
endif

noremap <silent> <buffer> <CR> g<C-]>

" Make help in vim more like a pager

M vim/.vim/after/ftplugin/mail.vim => vim/.vim/after/ftplugin/mail.vim +2 -1
@@ 1,7 1,8 @@
setlocal noautoindent
setlocal formatoptions+=wa
setlocal wrapmargin=0
setlocal textwidth=78
setlocal nonumber
setlocal digraph
setlocal nolist

let b:undo_ftplugin .= '|setlocal fo< wm< tw< nu< dg< list<'

M vim/.vim/after/ftplugin/python.vim => vim/.vim/after/ftplugin/python.vim +4 -3
@@ 1,7 1,8 @@
" Python specific settings
setlocal shiftwidth=4
setlocal tabstop=4
setlocal softtabstop=4
if &filetype !=# 'python'
  finish
endif

setlocal keywordprg=pydoc

" gz opens a split window one-third the height of the main window with a

A vim/.vim/after/ftplugin/qf.vim => vim/.vim/after/ftplugin/qf.vim +5 -0
@@ 0,0 1,5 @@
if &filetype !=# 'qf'
  finish
endif

nnoremap <silent> <buffer> q :q<CR>

M vim/.vim/after/ftplugin/vim.vim => vim/.vim/after/ftplugin/vim.vim +6 -0
@@ 1,2 1,8 @@
" Vim
if &filetype !=# 'vim'
  finish
endif

setlocal foldmethod=marker

let b:undo_ftplugin .= '|setlocal fdm<'

A vim/.vim/after/indent/mail.vim => vim/.vim/after/indent/mail.vim +1 -0
@@ 0,0 1,1 @@
setlocal noautoindent

A vim/.vim/after/indent/python.vim => vim/.vim/after/indent/python.vim +3 -0
@@ 0,0 1,3 @@
setlocal shiftwidth=4
setlocal tabstop=4
setlocal softtabstop=4

D vim/.vim/after/plugin/ack.vim => vim/.vim/after/plugin/ack.vim +0 -9
@@ 1,9 0,0 @@
if executable('rg')
  let g:ackprg = 'rg -S --vimgrep'
elseif executable('ag')
  let g:ackprg = 'ag -S --vimgrep'
endif

let g:ack_use_dispatch = 0

noremap <C-K> :Ack!<space>

D vim/.vim/after/plugin/capslock.vim => vim/.vim/after/plugin/capslock.vim +0 -1
@@ 1,1 0,0 @@
imap <C-C> <Plug>CapsLockToggle

A vim/.vim/after/plugin/obsession.vim => vim/.vim/after/plugin/obsession.vim +3 -0
@@ 0,0 1,3 @@
if exists(':Obsession')
  silent! packadd prosession
endif

A vim/.vim/autoload/pack_install.vim => vim/.vim/autoload/pack_install.vim +69 -0
@@ 0,0 1,69 @@
if !has('packages')
  " Requires vim's native package management feature
  finish
endif

function! pack_install#Install(opt, ...) abort
  for pkg in a:000
    let [author, repo] = split(pkg, "/")
    let author = substitute(author, "\(^vim\-\|[-.]vim$\)", "", "g")
    let repo = substitute(repo, "\(^vim\-\|[-.]vim$\|\.git$\)", "", "g")
    let dir = "~/.vim/pack/" . author . "/" . (a:opt ? "opt" : "start") . "/" . repo
    silent! clear
    silent execute "!git clone https://github.com/" . pkg . " " .dir
    silent! execute "helptags " . dir . "/doc"
    echom "Installed package: " . author . "/" . repo
  endfor
endfunction

function! pack_install#Remove(...) abort
  for pkg in a:000
    let [author, repo] = split(pkg, "/")
    let author = substitute(author, "\(^vim\-\|[-.]vim$\)", "", "g")
    let repo = substitute(repo, "\(^vim\-\|[-.]vim$\)", "", "g")
    silent! clear
    if isdirectory($HOME . "/.vim/pack/" . author . "/opt/" . repo)
      if confirm("Remove package ~/.vim/pack/" . author . "/opt/" . repo . "?", "&Yes\n&No", 2) == 1
        silent execute "!rm -rf ~/.vim/pack/" . author . "/opt/" . repo
        echom "Removed package: " . author . "/" . repo
      endif
    elseif isdirectory($HOME . "/.vim/pack/" . author . "/start/" . repo)
      if confirm("Remove package ~/.vim/pack/" . author . "/start/" . repo . "?", "&Yes\n&No", 2) == 1
        silent execute "!rm -rf ~/.vim/pack/" . author . "/start/" . repo
        echom "Removed package: " . author . "/" . repo
      endif
    else
      echom "Package not found: " . author . "/" . repo
    endif
  endfor
endfunction

function! pack_install#List() abort
  let start_packs = []
  let opt_packs = []
  let authors = []
  let paths = globpath($HOME . "/.vim/pack", "*", 0, 1)
  for path in paths
    let author = split(path, "/")[-1]
    for pkg in globpath(path, "start/*", 0, 1)
      let pkg_name = split(split(pkg, author)[-1], "/")[-1]
      let start_packs += [author . "/" . pkg_name]
    endfor
    for pkg in globpath(path, "opt/*", 0, 1)
      let pkg_name = split(split(pkg, author)[-1], "/")[-1]
      let opt_packs += [author . "/" . pkg_name]
    endfor
  endfor

  echom "Installed packages:"
  echom "start/"
  for pkg in start_packs
    echom "    " . pkg
  endfor
  echom ""
  echom "opt/"
  for pkg in opt_packs
    echom "    " . pkg
  endfor
endfunction


A vim/.vim/plugin/pack_install.vim => vim/.vim/plugin/pack_install.vim +9 -0
@@ 0,0 1,9 @@
if exists('g:loaded_pack_install') || !has('packages')
  finish
endif
let g:loaded_pack_install = 1

command! -nargs=+ PackInstall call pack_install#Install(0, <f-args>)
command! -nargs=+ PackInstallOpt call pack_install#Install(1, <f-args>)
command! -nargs=+ PackRemove call pack_install#Remove(<f-args>)
command! -nargs=0 Packages call pack_install#List()

A vim/.vim/plugin/scroll_next.vim => vim/.vim/plugin/scroll_next.vim +30 -0
@@ 0,0 1,30 @@
"
" scroll_next.vim: Mapping to scroll a page forward until the buffer's end,
" and then to go to the :next buffer in the argument list.
"
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
if exists('g:loaded_scroll_next') || &compatible
  finish
endif
if v:version < 600
  finish
endif
let g:loaded_scroll_next = 1

" Check visibility of last line (Vim >=7.0) or cursor presence on last line
" and flick to :next if appropriate, or just page forward with PageDown
function! s:ScrollNext() abort
  if line('.') == line('$')
        \ || line('w$') == line('$')
    silent! next
  else
    execute "normal! \<PageDown>"
  endif
endfunction

" Mapping setup
nnoremap <silent> <unique>
      \ <Plug>(ScrollNext)
      \ :<C-U>call <SID>ScrollNext()<CR>

M vim/.vim/plugins.vim => vim/.vim/plugins.vim +3 -0
@@ 54,6 54,9 @@ Plug 'ludovicchabant/vim-gutentags'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' }
Plug 'junegunn/fzf.vim'

Plug 'junegunn/limelight.vim'
Plug 'junegunn/goyo.vim'

" Vim language server client
" Plug 'neoclide/coc.nvim', { 'tag': '*', 'do': { -> coc#util#install() }}
Plug 'prabirshrestha/async.vim'

M vim/.vim/vimrc => vim/.vim/vimrc +136 -98
@@ 1,11 1,11 @@
" Source plugins list
source $HOME/.vim/plugins.vim
" Greg Anders (gpanders)'s vimrc <https://github.com/gpanders/dotfiles.git>

" Set the leader key
let mapleader = ','
let maplocalleader = '\'

" Set color scheme {{{

" Set background if $TERMBG is set, otherwise let vim decide
if $TERMBG == 'light'
  set background=light


@@ 20,9 20,15 @@ if has('termguicolors')
else
  let g:solarized_use16 = 1
  let g:onedark_termcolors = 16
endif

silent! packadd! onedark
silent! colorscheme onedark

if !exists('g:colors_name')
  set bg=dark
endif
colorscheme onedark

" }}}

" Sudo save


@@ 32,7 38,9 @@ cnoreabbrev w!! w !sudo tee > /dev/null %
set tabstop=2              " Tab width
set softtabstop=2          " Tab width
set shiftwidth=2           " Tab width
set autoindent             " Auto indent
set expandtab              " Use spaces instead of tabs
set incsearch              " Show search matches as they are typed
set number                 " Show line numbers
set hidden                 " Hide buffers instead of closing them
set ignorecase             " Make searching case insensitive


@@ 51,9 59,16 @@ set colorcolumn=80         " Show column at 80 characters
set noswapfile             " Disable swap file
set foldmarker=\ {{{,\ }}} " Make default fold marker have a space
set modeline               " Enable vim modelines
set virtualedit+=block     " Enable virtual editing in visual block mode
set lazyredraw             " Don't redraw the screen during batch execution
set linebreak              " Set lines at word boundaries
set include=               " Let filetypes set this value themselves

set path-=/usr/include     " Let filetypes set this value themselves
set path+=**               " Search current directory's whole tree

set path=.,**              " Add all subdirectories to path
set wildcharm=<C-Z>
set wildmode=longest,full
set wildignorecase
set wildignore=*.swp,*.bak
set wildignore+=*.pyc,*.class,*.sln,*.Master,*.csproj,*.csproj.user,*.cache,*.dll,*.pdb,*.min.*


@@ 88,29 103,37 @@ set statusline+=%5*\ %(%l:%c%V%)\            " Line and column number
" Set User1-9 highlight groups for statusline
" These are used by adding %N* to the statusline, where {N} is 1-9
" The following uses the solarized color scheme
if g:colors_name ==# 'solarized8'
  if &background ==# 'light'
    hi User1 ctermfg=15 ctermbg=11 guifg=#fdf6e3 guibg=#657b83
    hi User2 ctermfg=15 ctermbg=14 guifg=#fdf6e3 guibg=#93a1a1
    hi User3 ctermfg=11 ctermbg=7 guifg=#657b83 guibg=#eee8d5
    hi User4 ctermfg=15 ctermbg=14 guifg=#fdf6e3 guibg=#93a1a1
    hi User5 ctermfg=15 ctermbg=11 guifg=#fdf6e3 guibg=#657b83
  else
    hi User1 ctermfg=8 ctermbg=12 guifg=#002b36 guibg=#839496
    hi User2 ctermfg=8 ctermbg=10 guifg=#002b36 guibg=#586e75
    hi User3 ctermfg=12 ctermbg=0 guifg=#839496 guibg=#073642
    hi User4 ctermfg=8 ctermbg=10 guifg=#002b36 guibg=#586e75
    hi User5 ctermfg=8 ctermbg=12 guifg=#002b36 guibg=#839496
if exists('g:colors_name')
  if g:colors_name ==# 'solarized8'
    if &background ==# 'light'
      hi User1 ctermfg=15 ctermbg=11 guifg=#fdf6e3 guibg=#657b83
      hi User2 ctermfg=15 ctermbg=14 guifg=#fdf6e3 guibg=#93a1a1
      hi User3 ctermfg=11 ctermbg=7 guifg=#657b83 guibg=#eee8d5
      hi User4 ctermfg=15 ctermbg=14 guifg=#fdf6e3 guibg=#93a1a1
      hi User5 ctermfg=15 ctermbg=11 guifg=#fdf6e3 guibg=#657b83
    else
      hi User1 ctermfg=8 ctermbg=12 guifg=#002b36 guibg=#839496
      hi User2 ctermfg=8 ctermbg=10 guifg=#002b36 guibg=#586e75
      hi User3 ctermfg=12 ctermbg=0 guifg=#839496 guibg=#073642
      hi User4 ctermfg=8 ctermbg=10 guifg=#002b36 guibg=#586e75
      hi User5 ctermfg=8 ctermbg=12 guifg=#002b36 guibg=#839496
    endif
  elseif g:colors_name ==# 'onedark'
    hi User1 cterm=reverse gui=reverse
    hi User2 ctermbg=237 guibg=#3e4452
    hi User3 ctermfg=145 ctermbg=235 guifg=#abb2bf guibg=#282c34
    hi User4 ctermbg=237 guibg=#3e4452
    hi User5 cterm=reverse gui=reverse
  endif
elseif g:colors_name ==# 'onedark'
  hi User1 cterm=reverse gui=reverse
  hi User2 ctermbg=237 guibg=#3e4452
  hi User3 ctermfg=145 ctermbg=235 guifg=#abb2bf guibg=#282c34
  hi User4 ctermbg=237 guibg=#3e4452
  hi User5 cterm=reverse gui=reverse
endif
" }}}

" Enable persistent undo
if has('persistent_undo')
  set undofile
  set undodir^=~/.vim/cache/undo//
endif

" Insert mode mappings {{{

" jk in Insert mode escapes to Normal mode


@@ 124,6 147,10 @@ inoremap <C-U> <Esc>gUiw`]a

" Delete forward in insert mode
inoremap <C-L> <Del>

" Enable caps lock mode from vim-capslock
inoremap <C-C> <Plug>(CapsLockToggle)

" }}}

" Normal mode mappings {{{


@@ 131,6 158,10 @@ inoremap <C-L> <Del>
" Save by pressing <leader>w
nnoremap <silent> <leader>w :w<CR>

" Navigate through wrapped lines individually
nnoremap <silent> j gj
nnoremap <silent> k gk

" Make :tjump easier
nnoremap g] g<C-]>



@@ 139,7 170,7 @@ noremap Q gq

" Use <C-K> in Normal mode to use grepprg
" Define a custom command to wrap :grep with :silent, :copen, and :redraw
command! -nargs=+ -complete=file -bar -bang Grep silent! grep<bang> <args>|copen|redraw!
command! -nargs=+ -complete=file -bar -bang Grep silent! botright grep<bang> <args>|copen|redraw!
nnoremap <C-K> :Grep!<space>

" Buffer shortcuts


@@ 155,16 186,19 @@ nnoremap <silent> <leader>9 :b9<CR>
nnoremap <silent> <leader>0 :b10<CR>

" List buffers and put :b on the command line
noremap <leader>b :buffers<CR>:b <C-Z><S-Tab>
noremap <leader>B :buffers<CR>:sb <C-Z><S-Tab>
noremap <leader>b :buffers<CR>:b<Space>
noremap <leader>B :buffers<CR>:sb<Space>

" Augment [I and ]I to place an :ij prompt below results for easy jumping
noremap [I [I:ij  <C-R><C-W><S-Left><Left>
noremap ]I ]I:ij  <C-R><C-W><S-Left><Left>
noremap [I [I:ij<Space> <C-R><C-W><S-Left><Left>
noremap ]I ]I:ij<Space> <C-R><C-W><S-Left><Left>

" Augment [D and ]D to place an :dj prompt below results for easy jumping
noremap [D [D:dj  <C-R><C-W><S-Left><Left>
noremap ]D ]D:dj  <C-R><C-W><S-Left><Left>
noremap [D [D:dj<Space> <C-R><C-W><S-Left><Left>
noremap ]D ]D:dj<Space> <C-R><C-W><S-Left><Left>

" Remap & to preserve substitution flags
nnoremap <silent> & :&&<CR>

" Open quickfix list and place :cc on the prompt
noremap <leader>cl :clist<CR>:sil cc<space>


@@ 176,28 210,47 @@ nnoremap <leader>f :find *
nnoremap <leader>t :tabfind *
nnoremap <leader>j :tjump /
nnoremap <leader>p :ptjump /
nnoremap <leader>k :marks<CR>:norm! `

nnoremap <leader>F :find <C-R>=expand('%:h').'/*'<CR>
nnoremap <leader>T :tabfind <C-R>=expand('%:h').'/*'<CR>

" <leader>ev opens .vimrc in new window
nnoremap <leader>ev :vsplit $MYVIMRC<CR>
" <Bslash>e opens .vimrc in new window
nnoremap <Bslash>e :<C-U>vsplit $MYVIMRC<CR>

" <leader>sv sources .vimrc
nnoremap <leader>sv :source $MYVIMRC<CR>
" <Bslash>s sources .vimrc
nnoremap <Bslash>s :<C-U>source $MYVIMRC<CR>

" Toggle between normal and relative numbering
nnoremap <leader>r :call NumberToggle()<CR>

" Navigate through wrapped lines individually
nnoremap <silent> j gj
nnoremap <silent> k gk
" Space bar scrolls the screen
nnoremap <Space> <PageDown>
if &loadplugins
  nmap <Space> <Plug>(ScrollNext)
endif

" Clear search buffer with <C-L>
nnoremap <silent> <C-L> :<C-U>nohlsearch<Bar>diffupdate<CR><C-L>
vnoremap <silent> <C-L> :<C-U>nohlsearch<Bar>diffupdate<CR>gv<C-L>

" \c changes directory to current buffer's directory
nnoremap <silent> <Bslash>c :<C-U>cd %:h<CR>:echo 'Changed directory to ' . expand('%:p:h')<CR>

" Use space bar to toggle folds
nnoremap <space> za
" \l changes local buffer directory to current buffer's directory
nnoremap <silent> <Bslash>l :<C-U>lcd %:h<CR>:echo 'Changed local directory to ' . expand('%:p:h')<CR>

" Clear search buffer with <C-N>
nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
" \: execute line in command mode
nnoremap <Bslash>: ^"zyg_:<C-R>z<CR>
" \! execute line as shell command
nnoremap <Bslash>! ^"zyg_:!<C-R>z<CR>

" \y shows contents of registers
nnoremap <Bslash>y :<C-U>registers<CR>

" \q runs gq over the whole buffer
nnoremap <Bslash>q m'1GgqG`'

" \= runs = over the whole buffer
nnoremap <Bslash>= m'1G=G`'

" }}}



@@ 209,64 262,53 @@ vnoremap # y?\V<C-R>"<CR>
" Use ripgrep or ag as grepprg if available
if executable('rg')
  " Use rg over grep
  set grepprg=rg\ --vimgrep\ --hidden
  set grepprg=rg\ --vimgrep\ -S\ --hidden
elseif executable('ag')
    " Use ag over grep
    set grepprg=ag\ --vimgrep\ --hidden
  " Use ag over grep
  set grepprg=ag\ --vimgrep\ -S\ --hidden
endif
set grepformat='%f:%l:%c:%m,%f:%l:%m'

" Relative numbering {{{
function! NumberToggle()
  if (&relativenumber == 1)
    set nornu
    set number
  else
    set rnu
  endif
endfunc
" }}}

" Pushing built-in commands beyond their limits {{{
" https://gist.github.com/Konfekt/d8ce5626a48f4e56ecab31a89449f1f0
function! <sid>CCR()
    if getcmdtype() isnot# ':'
      return "\<CR>"
    endif
    let cmdline = getcmdline()
    if cmdline =~# '\v^\s*(ls|files|buffers)!?\s*(\s[+\-=auhx%#]+)?$'
        " like :ls but prompts for a buffer command
        return "\<CR>:b"
    elseif cmdline =~# '\v/(#|nu%[mber])$'
        " like :g//# but prompts for a command
        return "\<CR>:"
    elseif cmdline =~# '\v^\s*(dli%[st]|il%[ist])!?\s+\S'
        " like :dlist or :ilist but prompts for a count for :djump or :ijump
        return "\<CR>:" . cmdline[0] . "j  " . split(cmdline, " ")[1] . "\<S-Left>\<Left>"
    elseif cmdline =~# '\v^\s*(cli|lli)%[st]!?\s*(\s\d+(,\s*\d+)?)?$'
        " like :clist or :llist but prompts for an error/location number
        return "\<CR>:sil " . repeat(cmdline[0], 2) . "\<Space>"
    elseif cmdline =~# '\v^\s*ol%[dfiles]\s*$'
        " like :oldfiles but prompts for an old file to edit
        set nomore
        return "\<CR>:sil se more|e #<"
    elseif cmdline =~# '^\s*changes\s*$'
        " like :changes but prompts for a change to jump to
        set nomore
        return "\<CR>:sil se more|norm! g;\<S-Left>"
    elseif cmdline =~# '\v^\s*ju%[mps]'
        " like :jumps but prompts for a position to jump to
        set nomore
        return "\<CR>:sil se more|norm! \<C-o>\<S-Left>"
    elseif cmdline =~ '\v^\s*marks\s*(\s\w+)?$'
        " like :marks but prompts for a mark to jump to
        return "\<CR>:norm! `"
    elseif cmdline =~# '\v^\s*undol%[ist]'
        " like :undolist but prompts for a change to undo
        return "\<CR>:u "
    else
        return "\<c-]>\<CR>"
    endif
  if getcmdtype() isnot# ':'
    return "\<CR>"
  endif
  let cmdline = getcmdline()
  if cmdline =~# '\v^\s*(ls|files|buffers)!?\s*(\s[+\-=auhx%#]+)?$'
    " like :ls but prompts for a buffer command
    return "\<CR>:b"
  elseif cmdline =~# '\v/(#|nu%[mber])$'
    " like :g//# but prompts for a command
    return "\<CR>:"
  elseif cmdline =~# '\v^\s*(dli%[st]|il%[ist])!?\s+\S'
    " like :dlist or :ilist but prompts for a count for :djump or :ijump
    return "\<CR>:" . cmdline[0] . "j  " . split(cmdline, " ")[1] . "\<S-Left>\<Left>"
  elseif cmdline =~# '\v^\s*(cli|lli)%[st]!?\s*(\s\d+(,\s*\d+)?)?$'
    " like :clist or :llist but prompts for an error/location number
    return "\<CR>:sil " . repeat(cmdline[0], 2) . "\<Space>"
  elseif cmdline =~# '\v^\s*ol%[dfiles]\s*$'
    " like :oldfiles but prompts for an old file to edit
    set nomore
    return "\<CR>:sil se more|e #<"
  elseif cmdline =~# '^\s*changes\s*$'
    " like :changes but prompts for a change to jump to
    set nomore
    return "\<CR>:sil se more|norm! g;\<S-Left>"
  elseif cmdline =~# '\v^\s*ju%[mps]'
    " like :jumps but prompts for a position to jump to
    set nomore
    return "\<CR>:sil se more|norm! \<C-o>\<S-Left>"
  elseif cmdline =~ '\v^\s*marks\s*(\s\w+)?$'
    " like :marks but prompts for a mark to jump to
    return "\<CR>:norm! `"
  elseif cmdline =~# '\v^\s*undol%[ist]'
    " like :undolist but prompts for a change to undo
    return "\<CR>:u "
  else
    return "\<c-]>\<CR>"
  endif
endfunction
cnoremap <expr> <CR> <sid>CCR()
" }}}


@@ 294,10 336,6 @@ augroup vimrc
    au TermOpen * startinsert
  endif

  " Press q to close certain windows
  au FileType qf nnoremap <silent> <buffer> q :q<CR>
  au FileType netrw nnoremap <silent> <buffer> qq :Rex<CR>

augroup END
" }}}