Vimrc
Vimrc
Vimrc
" For all key mappings like ', .' to reload vimrc
let maplocalleader=','
Must be the last oneEnvironment variables are expanded when opening the file, n
ot when setting the option
" r
Removable media. The argument is a string
" s
Maximum size of an item in Kbyte
" }}}4 COMMENTED OUT
let &viminfo="%200,'200,/800,h,<500,:500,s150,r/tmp,r" . expand("$BKDIR") . "/.v
im/tmp,n" . expand("$BKDIR") ."/.vim/.vinfo"
if len(pat) > 0
let s = join(pat, '\|')
exec 'syntax match ExtraWhitespace "'.s.'" containedin=A
LL'
else
syntax clear ExtraWhitespace
endif
if len(bad) > 0|echo 'ShowWhitespace ignored: '.bad|endif
endfunction
" ==============================================================================
================================================================================
=============
" BACKUP, FILE OPTIONS {{{2
" ==============================================================================
==
set backup
" Make a backup before overwriting a file. Le
ave it around after the file has been successfully written.
set backupcopy=auto " When writing a file and a backup is made, this option tell
s how it's done. This is a comma separated list of words. - value: yes,no,auto
- no:rename the file and write a new one
set swapfile
set swapsync=fsync
"}}}2 BACKUP, FILE OPTIONS
" BASIC SETTINGS "{{{2
" ==============================================================================
==
set nocompatible
" vim, not vi.. must be first, because it change
s other options as a side effect
set modeline
set statusline=%M%h%y\ %t\ %F\ %p%%\ %l/%L\ %=[%{&ff},%{&ft}]\ [a=\%03.3b]\ [h=\
%02.2B]\ [%l,%v]
set title titlelen=150 titlestring=%(\ %M%)%(\ (%{expand(\"%:p:h\")})%)%(\ %a%)\
-\ %{v:servername}
"set tags=tags;/
set ttyfast
" we have a fast terminal
set scrolljump=5
" when scrolling up down, show at least 5 lines
"set ttyscroll=999
" make vim redraw screen instead of scrolling when the
re are more than 3 lines to be scrolled
"set tw=500
set undolevels=10
set updatecount=250
set whichwrap+=b,s,<,>,h,l,[,]
" backspaces and cursor keys wra
p to
"set wildignore+=*.o,*~,.lo,*.exe,*.bak " ignore object files
"set wildmenu
" menu has tab c
ompletion
"set wildmode=longest:full
" *wild* mode
set nowrap
set autoindent smartindent
set autoread
set cursorline
"set enc=utf-8 fenc=utf-8
set history=3000
e history
set noautowrite
next
set noexpandtab
set noruler
r
set nospell
set nohidden
a tab (I use tabs more than buffers)
set pastetoggle=<F11>
set scrolloff=3
set shiftwidth=3
set showcmd
ng
set showfulltag
set showmode
set sidescroll=2
rizontal scrolling
set sidescrolloff=2
set noguipty
set splitright
set splitbelow
set restorescreen=on " restore screen contents when vim exits - disable withset
t_ti= t_te=
"set sessionoptions=word,blank,buffers,curdir,folds,globals,help,localoptions,re
size,sesdir,tabpages,winpos,winsize
set winheight=25
set winminheight=1
" minimal value for window height
"set winheight=30
" set the minimal window height
set equalalways
set eadirection=both
set hlsearch
set laststatus=2
set tabstop=4
set softtabstop=4
set shiftwidth=3
set switchbuf=usetab
set commentstring=#%s
set tabpagemax=55
set showtabline=2
set smarttab
set foldmethod=marker
set foldenable
set foldcolumn=6
f the numbered lines
set incsearch
"set ignorecase
set sc
when pattern has upper case characters
set smartcase
ercase
set showmatch
set diffopt=filler,iwhite
set stal=2
"}}}1 OPTIONS
l bell
if filereadable(expand("$VIMRUNTIME/colors/askapachecode.vim"))
colorscheme askapachecode
elseif filereadable(expand("$HOME/.vim/colors/askapachecode.vim"
))
colorscheme askapachecode
else
colorscheme default
endif
filetype indent plugin on
syntax on
else
" things like cfdisk, crontab -e, visudo, vless, etc.
set term=linux
set t_Co=8
syntax off
filetype indent plugin off
endif
endif
"}}}1
tion. Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim). Also don't do it when
the mark is in the first line, that is the default position when opening a file.
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$")
| exe "normal! g`\"" | endif
" CLEARMATCHES ON BUFWINLEAVE {{{3
au BufWinLeave * call clearmatches()
" STRIP TRAILING WHITESPACE {{{3
autocmd BufWritePre *.cpp,*.hpp,*.i :call StripTrailingWhitespac
e()
" AA_ZZZ LAST MOD {{{3
autocmd BufWritePre,FileWritePre,TabLeave zzz_askapache-bash.sh
ks|call LastModAAZZZ()|'s
" SET VIM SETTINGS FOR AA_ZZZ SCRIPTS {{{3
autocmd BufRead /etc/ZZZ/*.sh,.bash_profile,.bash_login,.bashrc,
.bash_login_user,.bash_logout setlocal ts=4 sw=3 ft=sh foldmethod=marker tw=500
foldcolumn=7
" INSERT CURRENT DATE AND TIME IN A *.SH FILE WHEN WRITING IT {{
{3
autocmd BufWritePre,FileWritePre *.*
ks|call LastMod()|'s
printf(&commentstring,
printf(&commentstring,
printf(&commentstring,
printf(&commentstring,
filetype to apache
"}}}4
" COMMENTED OUT MAPS {{{6
"map <C-S-]> gt
"map <C-S-[> gT
"map <C-1> 1gt
"map <C-2> 2gt
"map <C-3> 3gt
"map <C-4> 4gt
"map <C-5> 5gt
"map <C-6> 6gt
"map <C-7> 7gt
"map <C-8> 8gt
"map <C-9> 9gt
"map <C-0> :tablast<CR>
" correct type-o's on exit
" nmap q: :q
" save and build
" nmap <LocalLeader>wm :w<cr>:make<cr>
" Also map user-defined omnicompletion as Ctrl+k
"inoremap <C-k> <C-x><C-u>
" Y yanks from cursor to $
"map Y y$
" for yankring to work with previous mapping:
"function! YRRunAfterMaps()
" nnoremap Y :<C-U>YRYankCount 'y$'<CR>
"endfunction
" toggle list mode
"nmap <LocalLeader>tl :set list!<cr>
" toggle paste mode
"nmap <LocalLeader>pm :set paste!<cr>
" toggle wrapping
"nmap <LocalLeader>ww :set wrap!<cr>
" change directory to that of current file
"nmap <LocalLeader>cd :cd%:p:h<cr>
" change local directory to that of current file
"nmap <LocalLeader>lcd :lcd%:p:h<cr>
" correct type-o's on exit
"nmap q: :q
" save and build
"nmap <LocalLeader>wm :w<cr>:make<cr>
" open all folds
"nmap <LocalLeader>o :%foldopen!<cr>
" close all folds
"nmap <LocalLeader>c :%foldclose!<cr>
Changing Case
guu
: lowercase line
gUU
: uppercase line
Vu
: lowercase line
VU
: uppercase line
g~~
: flip case line
vEU
: Upper Case Word
vE~
: Flip Case Word
ggguG
: lowercase entire file
" Titlise Visually Selected Text (map for .vimrc)
vmap ,c :s/\<\(.\)\(\k*\)\>/\u\1\L\2/g<CR>
" Title Case A Line Or Selection (better)
vnoremap <F6> :s/\%V\<\(\w\)\(\w*\)\>/\u\1\L\2/ge<cr> [N]
" titlise a line
nmap ,t :s/.*/\L&/<bar>:s/\<./\u&/g<cr> [N]
" Uppercase first letter of sentences
:%s/[.!?]\_s\+\a/\U&\E/g
" :r file " read text from file and insert below current line
" :so $VIMRUNTIME/syntax/hitest.vim
"}}}2
" HELP HELP {{{3
"
"
P
"
"
"
"
"
--------------------------------:helpg pattern
search grep!! --- JUM
TO OTHER MATCHES WITH: >
:help holy-grail
:help all
:help termcap
:help user-toc.txt
Table of contents of the User Manual. >
:help :subject
Ex-command "subject", for instance the following:
>
" :help :help
Help on getting help. >
" :help CTRL-B
Control key <C-B> in Normal mode. >
" :help 'subject'
Option 'subject'. >
" :help EventName
Autocommand event "EventName"
" :help pattern<Tab>
Find a help tag starting with "pattern". Repeat
<Tab> for others. >
" :help pattern<Ctrl-D>
See all possible help tag matches "pattern" at on
ce. >
"
:cn
next match >
"
:cprev, :cN
previous match >
"
:cfirst, :clast
first or last match >
"
:copen, :cclose
open/close the quickfix window; pr
ess <Enter> to jump to the item under the cursor
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
--------------------------------F
- create a fold from matching parenthesis
fm
- (zm) more folds
fl - (zr) less/reduce folds
fo
- open all folds (zR)
fc
- close all folds (zM)
ff - (zf) - create a fold
fd
- (zd) - delete fold at cursor
zF
- create a fold N lines
zi
- invert foldenable
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
COMMANDS {{{3
--------------------------------:runtime! plugin/**/*.vim - load plugins
:so $VIMRUNTIME/syntax/hitest.vim
" view highlight options
:so $VIMRUNTIME/syntax/colortest.vim