From 2513b4122356613f69fd7b6f36481ee0d44b190f Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Fri, 20 Jul 2018 01:29:10 +0200 Subject: [vim] cleanup vimrc Sometimes you have to use vim. --- vimrc | 114 +++++++++++++++--------------------------------------------------- 1 file changed, 26 insertions(+), 88 deletions(-) (limited to 'vimrc') diff --git a/vimrc b/vimrc index 8cfbadd..8886923 100644 --- a/vimrc +++ b/vimrc @@ -1,18 +1,3 @@ -" All system-wide defaults are set in $VIMRUNTIME/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. - -" Uncomment the next line to make Vim more Vi-compatible -" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous -" options, so any other options should be set AFTER setting 'compatible'. -"set compatible - -" Vim5 and later versions support syntax highlighting. Uncommenting the next -" line enables syntax highlighting by default. - " set shell to a more POSIX compatible shell if &shell =~# 'fish$' set shell=sh @@ -26,13 +11,10 @@ syntax enable set background=dark " dark | light " colorscheme solarized let g:solarized_termcolors=256 -hi Normal ctermbg=none set cursorline set colorcolumn=80 -" The following are commented out as they cause vim to behave a lot -" differently from regular Vi. They are highly recommended though. set showcmd " Show (partial) command in status line. set showmatch " Show matching brackets. set ignorecase " Do case insensitive matching @@ -41,9 +23,13 @@ set smartcase " Do smart case matching "set incsearch " Incremental search "set autowrite " Automatically save before commands like :next and :make "set hidden " Hide buffers when they are abandoned -"set mouse=a " Enable mouse usage (all modes) -set backup " Enable backup files -"set number " Enable line numbers +set number " Enable line numbers + + +set list +set listchars=tab:>.,trail:. +hi clear SpecialKey + " Return to last edit position when opening files (You want this!) autocmd BufReadPost * @@ -51,33 +37,14 @@ autocmd BufReadPost * \ exe "normal! g`\"" | \ endif -"""""""""""""""""""""""""""""" -" => Highlight Groups -"""""""""""""""""""""""""""""" -:highlight ExtraWhitespace ctermbg=red guibg=red - -"""""""""""""""""""""""""""""" -" => Visual mode related -"""""""""""""""""""""""""""""" -" Visual mode pressing * or # searches for the current selection -" Super useful! From an idea by Michael Naumann -vnoremap * :call VisualSelection('f', '') -vnoremap # :call VisualSelection('b', '') """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Text, tab and indent related """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -set expandtab "Use spaces instead of tabs -set smarttab "Be smart when using tabs ;) -set shiftwidth=4 "1 tab == 4 spaces set tabstop=4 -" Linebreak on 80 characters -set lbr -set tw=80 -set ai "Auto indent -set si "Smart indent -set wrap "Wrap lines +set autoindent +set smartindent + """""""""""""""""""""""""""""" " => Status line @@ -85,7 +52,19 @@ set wrap "Wrap lines " Always show the status line set laststatus=2 " Format the status line -set statusline=\ %{HasPaste()}%F%m%r%h\ \ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l +set statusline= +set statusline +=%1*\ %n\ %* "buffer number +set statusline +=%1*%{&ff}%* "file format +set statusline +=%2*%y%* "file type +set statusline +=%1*\ %<%F%* "full path +set statusline +=%3*%m%* "modified flag +set statusline +=%1*%=%5l%* "current line +set statusline +=%1*/%L%* "total lines +set statusline +=%1*%4v\ %* "virtual column number +" Color the status line +hi User1 ctermfg=245 ctermbg=235 +hi User2 ctermfg=61 ctermbg=235 +hi User3 ctermfg=160 ctermbg=235 """""""""""""""""""""""""""""" " => Custom commands @@ -95,50 +74,9 @@ command W w command WQ wq command Wq wq + """""""""""""""""""""""""""""" " => Custom macros """""""""""""""""""""""""""""" - -" select all -let @a="ggVG" -" activate spellcheck for german -let @l=":set spell\n:set spelllang=de\n" - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Helper functions -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -function! CmdLine(str) - exe "menu Foo.Bar :" . a:str - emenu Foo.Bar - unmenu Foo -endfunction - -function! VisualSelection(direction, extra_filter) range - let l:saved_reg = @" - execute "normal! vgvy" - - let l:pattern = escape(@", '\\/.*$^~[]') - let l:pattern = substitute(l:pattern, "\n$", "", "") - - if a:direction == 'b' - execute "normal ?" . l:pattern . "^M" - elseif a:direction == 'gv' - call CmdLine("Ack \"" . l:pattern . "\" " ) - elseif a:direction == 'replace' - call CmdLine("%s" . '/'. l:pattern . '/') - elseif a:direction == 'f' - execute "normal /" . l:pattern . "^M" - endif - - let @/ = l:pattern - let @" = l:saved_reg -endfunction - -" Returns true if paste mode is enabled -function! HasPaste() - if &paste - return 'PASTE MODE ' - en - return '' -endfunction - +let @a="ggVG" " select all +let @l=":set spell\n:set spelllang=de\n" " activate spellcheck for german -- cgit v1.2.3