]> oss.titaniummirror.com Git - smckown/dotfiles.git/commitdiff
vim: add vimrc-secure
authorR. Steve McKown <rsmckown@gmail.com>
Thu, 14 Jan 2016 19:51:22 +0000 (12:51 -0700)
committerR. Steve McKown <rsmckown@gmail.com>
Thu, 14 Jan 2016 19:51:29 +0000 (12:51 -0700)
This vimrc is called specifically by the dmenu pass script that allows
edit of a password entry to prevent its contents to be stored anywhere.

vim/vimrc-secure [new file with mode: 0644]

diff --git a/vim/vimrc-secure b/vim/vimrc-secure
new file mode 100644 (file)
index 0000000..90d7f90
--- /dev/null
@@ -0,0 +1,166 @@
+" smckown .vimrc file
+
+" Tricky to get a nice terminal color scheme that works well in both vim and
+" gvim.  Step 1 is to ensure that vi knows the underlying device is 256 color
+" capable.  The solution of setting xterm:
+"   TERM=xterm-256color in .bashrc:
+"   if [[ $TERM == xterm && $COLORTERM == gnome* ]]; then
+"     export TERM=xterm-256color
+"   fi
+" ... works for vi, but seems to cause problems with the terminal pager.
+" Setting t_Co at the very top of vimrc so all the plugins see the setting
+" seems to be working the best.
+set t_Co=256
+
+filetype off
+
+" Set the correct font for gvim
+if has("gui_running")
+  if has("gui_gtk2")
+    set guifont=DejaVu\ Sans\ Mono\ for\ Powerline\ 9
+  elseif has("gui_macvim")
+    set guifont=Menlo\ Regular:h14
+  elseif has("gui_win32")
+    set guifont=Consolas:h11:cANSI
+  endif
+endif
+
+" Local listchars def if utf-8 terminal.  Otherwise sensible defaults are OK.
+if &termencoding ==# 'utf-8' || &encoding ==# 'utf-8'
+  "let &listchars = tab:»·,trail:·
+  let &listchars = "tab:»·,trail:\u2423,extends:\u21c9,precedes:\u21c7,nbsp:\u26ad"
+endif
+
+" Disable certain keys that aren't very helpful
+nnoremap <F1> <ESC>
+inoremap <F1> <ESC>
+vnoremap <F1> <ESC>
+nnoremap <up> <nop>
+nnoremap <down> <nop>
+nnoremap <left> <nop>
+nnoremap <right> <nop>
+inoremap <up> <nop>
+inoremap <down> <nop>
+inoremap <left> <nop>
+inoremap <right> <nop>
+vnoremap <up> <nop>
+vnoremap <down> <nop>
+vnoremap <left> <nop>
+vnoremap <right> <nop>
+
+" Try out <space> as <leader>
+map <space> <leader>
+
+" Make tabs and trailing spaces visible.  Show them and special chars in gray.
+highlight NonText ctermfg=gray guifg=gray
+highlight SpecialKey ctermfg=gray guifg=gray
+set list
+
+" Set default indent policy.  smarttab, roundshift enabled by sensible
+set softtabstop=2 shiftwidth=2 expandtab
+
+" cinoptions for code formatting
+set cinoptions=t0,U1,k2s,j1,J1
+
+" Local netrw hide list.  Sensible default shows .o files, etc.
+let g:netrw_list_hide = '\~$,^tags$,\.swp$,\.o$,\.pyc$,\.class$'
+
+" Preferred local settings
+"set visualbell noerrorbells           " Bells set to visual only
+set novisualbell noerrorbells          " Bells set to visual only
+set number                             " Use con to toggle numbers
+set relativenumber                     " Use cor to toggle relative numbers
+"set mouse=a                           " Enable mouse (thinkpad scroll)
+set scrolloff=5                                " Cursor offset from screen top/bottom
+set hidden                             " Don't warn when hiding a changed buffer
+set modeline                           " Best not to allow per-file override
+if exists('+cursorline')
+  " unimpaired.vim adds change option: coc toggles cursorline
+  "hi CursorLine cterm=NONE,underline  " Underline makes '_' and ' ' alike
+  "set cursorline                      " Highlight current line
+  "nnoremap <leader>c :set cursorline!<CR>
+endif
+
+" Search options
+" unimpaired.vim adds change option: coh toggles hlsearch
+set ignorecase smartcase nohlsearch
+
+" Ignore files
+set wildignore=*.swp,*.bak,*.o,*.pyc,*.class,*.a,*.so
+
+" Mapping for paste toggle
+nnoremap <F2> :set invpaste paste?<CR>
+set pastetoggle=<F2>
+
+" Use Q for formatting the current paragraph (or selection)
+vmap Q gq
+nmap Q gqap
+
+" Spell check
+" unimpaired.vim adds change option: cos toggles spell
+"nmap <silent> <leader>s :set spell!<CR> :set spell?<CR>
+set spelllang=en
+
+" The simpler solution to the above, which generates a column
+if exists('+colorcolumn')
+  if v:version >= 703
+    " Set color column relative to defined textwidth.
+    " Highlights the column immediately after the last valid.
+    set colorcolumn=+1
+  else
+    set colorcolumn=80
+  endif
+else
+  au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
+endif
+
+nnoremap <leader>W :call <SID>StripTrailingWhitespace()<CR>
+function! <SID>StripTrailingWhitespace()
+  " Save last search, and cursor position.
+  let _s=@/
+  let l = line(".")
+  let c = col(".")
+  " Perform the substitution.
+  %s/\s\+$//e
+  " Restore last search and cursor position.
+  let @/=_s
+  call cursor(l, c)
+endfunction
+
+" Implement 'cot' -- Toggle formatoption 't' -- wrap texts to textwidth
+nnoremap cot :call ToggleFormatOptionT()<CR>
+function! ToggleFormatOptionT()
+  let tmp = substitute(&formatoptions, 't', '', '')
+  if &formatoptions == tmp
+    set fo+=t
+    :echo "Enable text wrap"
+  else
+    set fo-=t
+    :echo "Disable text wrap"
+  endif
+endfunction
+
+" Implement 'coa' -- Toggle formatoption 'a' -- auto-wrap paragraphs
+nnoremap coa :call ToggleFormatOptionA()<CR>
+function! ToggleFormatOptionA()
+  let tmp = substitute(&formatoptions, 'a', '', '')
+  if &formatoptions == tmp
+    set fo+=a
+    :echo "Enable auto-wrap paragraphs"
+  else
+    set fo-=a
+    :echo "Disable auto-wrap paragraphs"
+  endif
+endfunction
+
+" Set secure features
+set nobackup
+set nowritebackup
+set noundofile
+set noswapfile
+set viminfo=""
+set noshelltemp
+set history=0
+set nomodeline
+set secure
+