Monday, February 28, 2011

vi rc file from a guy in italy

http://retis.sssup.it/~scordino/code/vimrc

" Note: how to edit remote files:
"
" vim scp://user@machine/file_in_home_directory
" vim scp://user@machine//absolute_path/filename

" OMNICPPCOMPLETE /==========================================================
set nocp " non vi compatible mode
filetype plugin on " enable plugins
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
set completeopt=menu,menuone
let OmniCpp_MayCompleteDot = 1 " autocomplete with .
let OmniCpp_MayCompleteArrow = 1 " autocomplete with ->
let OmniCpp_MayCompleteScope = 1 " autocomplete with ::
let OmniCpp_SelectFirstItem = 2 " select first item (but don't insert)
let OmniCpp_NamespaceSearch = 2 " search namespaces in this and included files
let OmniCpp_ShowPrototypeInAbbr = 1 " show function prototype in popup window


" CTAGS /====================================================================
" add current directory's generated tags file to available tags
set tags=~/.vim/stdtags,~/.vim/stltags,tags,.tags,../tags
" map <ctrl>+F12 to generate ctags for current folder:
map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR><CR>




" COLUMNS AND ALIGNMENT /====================================================

" Number of columns after which wrap to the next line (using a value less or
" equal to 80 the file can be read also from shell).
autocmd FileType tex,txt set textwidth=75

set spelllang=en_us
map <F12> :setlocal spell!<cr>



set tabpagemax=40

" Options for gvim
if has("gui_running")

 " Number of lines (rows)
 set lines=45

 " Number of columns of the GUI (using more than textwidth we can
 " read also the files written by other people). 
   set co=80
endif

" ======================= Other options ===================================
set history=700

set autoread

"set ignorecase

" No errorbell
set vb t_vb=

" No backup
set nobackup

" State bar always visible
set laststatus=2


"set cinoptions>=8

" Syntax highlighting
syn on

" Coloured search
set hlsearch

" Incremental search
set incsearch 

" Shows correspondent brackets
set showmatch
"... for 5 tenths of second
set matchtime=5

" Jumps automatically to the last edited line
 autocmd BufRead *,.* :normal '"

" Automatic indentation
" set noautoindent
set autoindent

" set cindent
set nocindent 

" Numbers for programming files
autocmd FileType c,h,cpp,php,hpp,java,py set number
autocmd FileType c,h,cpp,php,hpp,java,py set co=85

" ======================= Indentation ===================================


"Indentation is 3 spaces
set sw=8 ts=8

" We don't want the tab equal to spaces
set noexpandtab

" The tab is equal to the size of 8 spaces for programming
autocmd FileType c,h,cpp,php,hpp,java,py set shiftwidth=8 
autocmd FileType c,h,cpp,php,hpp,java,py set tabstop=8
autocmd FileType c,h,cpp,php,hpp,java,py set softtabstop=8


" Tab works as follows:
" - On programming files: indent
" - On other files: wrapping
map <tab> gqq
vmap <tab> gq
autocmd FileType c,h,cpp,php,hpp,java,py map <tab> ==
autocmd FileType c,h,cpp,php,hpp,java,py vmap <tab> =


" ========================== My main keys ===========================


" F1 shows the next file (buffer)
" F2 shows the previous file (buffer)
if has("gui_running")
 map <F1> :tabp<CR>
 map <F2> :tabn<CR>
else
 map <F1> :bn!<CR>
 map <F2> :bp!<CR>
endif


" F3 switches between two windows after a split
 map <F3> <c-w>w


" F4 folds
 vmap <F4> zf

" F5 unfolds
 map <F5> zd

" F6 does indentation of code
map <F6> ==
vmap <F6> =

" F7 wraps text 
map <F7> gqq
vmap <F7> gq


" F11 autocompletes words
imap <F11> <c-p>



" ========================== ctags ===========================


"set tags+=./tags

" Alt-1 searches a tag
map <a-1> :tj 

" Alt-2 goes to a ctag
map <a-2> :tn<CR>

" Alt-3 returns from a ctag
map <a-3> :tp<CR>

" Alt-4 goes to a ctag
map <a-4> g<c-]> 

" Alt-5 returns from a ctag
map <a-5> <c-t> 

" ======================== Comments =============================

map <F8> :call Comment()<CR>
map <F9> :call Uncomment()<CR>

" Comments range (handles multiple file types)
function! Comment() range
  if &filetype == "php" || &filetype == "css"
    execute ":" . a:firstline . "," . a:lastline . 's/^\(.*\)$/\/\* \1 \*\//'
  elseif &filetype == "html" || &filetype == "xml" || &filetype == "xslt" || &filetype == "xsd" || &filetype == "xhtml"
    execute ":" . a:firstline . "," . a:lastline . 's/^\(.*\)$/<!-- \1 -->/'
  elseif &filetype == "c" || &filetype == "cpp" || &filetype == "h"
    execute ":" . a:firstline . "," . a:lastline . 's/^\(.*\)$/\/* \1 *\//'
  else
    if &filetype == "java" || &filetype == "cs" 
      let commentString = "// "
    elseif &filetype == "vim"
      let commentString = '"'
    elseif &filetype == "tex" || &filetype == "bib"
      let commentString = "%% "
    elseif &filetype == "cmm"
      let commentString = ";; "
    else
      let commentString = "## "
    endif
    execute ":" . a:firstline . "," . a:lastline . 's,^,' . commentString . ','
  endif
endfunction

" Uncomments range (handles multiple file types)
function! Uncomment() range
  if &filetype == "php" || &filetype == "css" || &filetype == "html" || &filetype == "xml" || &filetype == "xslt" || &filetype == "xsd" || &filetype == "xhtml"
    " http://www.vim.org/tips/tip.php?tip_id=271
    execute ":" . a:firstline . "," . a:lastline . 's/^\([/(]\*\|<!--\) \(.*\) \(\*[/)]\|-->\)$/\2/'
  elseif &filetype == "cpp" || &filetype == "c" || &filetype == "h"
    execute ":" . a:firstline . "," . a:lastline . 's/^\([/(]\*\|\/\*\) \(.*\) \(\*[/)]\|\*\/\)$/\2/'
  else
    if &filetype == "java" || &filetype == "cs"
      let commentString = "// "
    elseif &filetype == "vim"
      let commentString = '"'
    elseif &filetype == "tex" || &filetype == "bib"
      let commentString = "%% "
    elseif &filetype == "cmm"
      let commentString = ";; "
    else
      let commentString = "## "
    endif
    execute ":" . a:firstline . "," . a:lastline . 's,^' . commentString . ',,'
  endif
endfunction

" ======================== Microsoft Word =============================

" reading Ms-Word documents (requires antiword)
autocmd BufReadPre *.doc set ro
autocmd BufReadPre *.doc set hlsearch!
autocmd BufReadPost *.doc %!antiword "%"


" ======================== Graphical options =============================

hi clear

" Status bar for shell
 hi StatusLine guifg=darkgrey guibg=darkred ctermfg=darkred
"hi StatusLine guifg=darkgrey guibg=blue ctermfg=blue

" Options for gvim
if has("gui_running")

 "Fonts used in gvim
 set guifont=Bitstream\ Vera\ Sans\ Mono\ 13
 set gfw=Bitstream\ Vera\ Sans\ Mono\ Bold\ 13

endif

" colo torte
 hi clear
 hi  DiffFile guibg=NONE guifg=grey50 gui=bold 
 hi DiffAdded guifg=red guibg=NONE gui=bold
 hi DiffRemoved guifg=orange guibg=NONE gui=bold


 " Gui background color
"  highlight Normal guibg=lightblue
" highlight Normal guibg=lightyellow
" highlight Normal guibg=#fffddd
" highlight Normal guibg=#99cccc
 " highlight Normal guibg=lightmagenta
 " highlight Normal guibg=lightgreen
" Modified for black
" highlight Normal guibg=#eeeeee
 highlight Normal guibg=white guifg=darkblue
" highlight Normal guibg=black guifg=white

"   highlight Visual guibg=black
   highlight Visual guibg=lightmagenta


 "Colour of the state bar
" Modified for black
" hi StatusLine guifg=darkgrey guibg=white ctermfg=darkcyan
" hi StatusLine gui=italic gui=bold guifg=darkred guibg=lightgrey ctermfg=magenta
 hi StatusLine gui=italic gui=bold guifg=darkred guibg=grey ctermfg=magenta

 "Colour of the search
" hi search guifg=yellow guibg=red gui=italic ctermfg=cyan ctermbg=red
" hi search guifg=red guibg=lightgreen gui=italic ctermfg=cyan ctermbg=red
 hi search guifg=red guibg=lightgreen gui=bold ctermfg=cyan ctermbg=red

 "Colour of the incremental search
 hi incsearch guifg=lightgreen guibg=red ctermfg=white ctermbg=red cterm=reverse

 hi LineNr guifg=grey50

 hi DiffAdd guifg=white guibg=blue
 hi DiffRemove guifg=white guibg=green
 hi DiffChange guifg=red



 "Colours of the keywords for programming
 autocmd FileType c,h,cpp,php,hpp,java :hi Number guifg=magenta
 autocmd FileType c,h,cpp,php,hpp,java :hi boolean guifg=magenta
 autocmd FileType c,h,cpp,php,hpp,java :hi Constant guifg=magenta
 autocmd FileType c,h,cpp,php,hpp,java :hi cConstant guifg=magenta
 autocmd FileType c,h,cpp,php,hpp,java :hi cppConstant guifg=magenta

 autocmd FileType c,h,cpp,php,hpp,java :hi Type guifg=red gui=none 
 autocmd FileType c,h,cpp,php,hpp,java :hi cType guifg=red 
 autocmd FileType c,h,cpp,php,hpp,java :hi cppType guifg=red 

 autocmd FileType * :hi Statement guifg=red gui=none 
 autocmd FileType c,h,cpp,php,hpp,java :hi Statement guifg=red 
 autocmd FileType c,h,cpp,php,hpp,java :hi cStatement guifg=red 
 autocmd FileType c,h,cpp,php,hpp,java :hi cppStatement guifg=red 

 autocmd FileType c,h,cpp,php,hpp,java :hi Structure guifg=red 
 autocmd FileType c,h,cpp,php,hpp,java :hi cStructure guifg=darkgreen 
 autocmd FileType c,h,cpp,php,hpp,java :hi cppStructure guifg=red 
   
 autocmd FileType c,h,cpp,php,hpp,java :hi String guifg=violet gui=italic
 autocmd FileType c,h,cpp,php,hpp,java :hi cString guifg=violet gui=italic
 autocmd FileType c,h,cpp,php,hpp,java :hi cppString guifg=violet gui=italic

 autocmd FileType * :hi Comment guifg=violet gui=italic
 autocmd FileType c,h,cpp,php,hpp,java :hi Comment guifg=grey30 gui=italic
 autocmd FileType c,h,cpp,php,hpp,java :hi cComment guifg=grey30 gui=italic
 autocmd FileType c,h,cpp,php,hpp,java :hi cppComment guifg=grey30 gui=italic

 "Fonts shown in tex files
 autocmd FileType tex,bib :hi texSection guifg=blue gui=bold
 autocmd FileType tex,bib :hi texComment guifg=darkcyan gui=italic


"endif



" Color settings for the cursor (different colors for insert mode)
" Modified for black
"highlight Cursor   guifg=white  guibg=black
"highlight Cursor   guifg=red  guibg=lightgreen
highlight Cursor   guifg=red  guibg=steelblue
highlight iCursor  guifg=white  guibg=steelblue

" Cursor shape (insert => vertical line)
"set guicursor=n-v-c:block-Cursor
set guicursor+=i:ver30-iCursor

" Blinking settings (normal mode => no blinking)
set guicursor+=n-v-c:blinkon0-Cursor
"set guicursor+=i:blinkwait500-iCursor 

if has("gui_kde")
 set guifont=Arial/14/-1/5/50/0/0/0/0/0
endif




Tuesday, February 22, 2011

gnome resource listing tool (disable automounting)

gconftool-2 -R /
the path can be such as /, /desktop, etc.

Disable Gnome Automounting


Under System->Users and Groups
then select your user, Advanced Settings (authenticate su)
then tab User Privileges, Access external storage devices automatically <check box>
might be the place to kill it.  I'm happy for now, but will try later.

It then may be on a per user basis.
Jim