Guest User

Untitled

a guest
Jul 2nd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 3.88 KB | None | 0 0
  1. " Avoid the possibility of trojaned text files (FreeBSD advice)
  2. set nomodeline
  3.  
  4. " Enable mouse support in all modes
  5. "set mouse=a
  6.  
  7. " Search without case if lowercase
  8. set ignorecase smartcase
  9.  
  10. " Automatically indent new lines the same way as the line before
  11. set autoindent
  12.  
  13. " Make autoindent copy the existing indent structure
  14. set copyindent
  15.  
  16. " Do smart indention (cindent is to abusive as the default)
  17. "set smartindent
  18. " But do the cindent for .php files
  19. "au BufRead,BufNewFile *.php set cindent
  20.  
  21. set cindent
  22. "Fix indent of '#text' and 'text:' to not start at beginning of line
  23. set cinkeys=0{,0},!^F,o,O,e " default is: 0{,0},0),:,0#,!^F,o,O,e
  24.  
  25. " Briefly mark the other bracket when inserting one
  26. set showmatch
  27.  
  28. " Minimum number of lines on screen (so that we don't scroll to far down)
  29. set scrolloff=6
  30.  
  31. "Search while typing
  32. set incsearch
  33. " But don't highlight it
  34. set nohlsearch
  35.  
  36.  
  37. " Make backspace work the way it should on all systems
  38. set backspace=2
  39.  
  40.  
  41.  
  42. " Do the syntax highlight the way I want it.
  43. syntax on
  44. set bg=dark
  45. autocmd BufRead,BufNewFile *.php hi Comment ctermfg=Blue guifg=Blue
  46. " au BufRead,BufNewFile *.php set bg=light
  47.  
  48.  
  49. " Only do this part when compiled with support for autocommands
  50. if has("autocmd")
  51.   augroup js
  52.   autocmd!
  53.   " When editing a file, always jump to the last cursor position
  54.   autocmd BufReadPost *
  55.   \ if line("'\"") > 0 && line ("'\"") <= line("$") |
  56.   \   exe "normal! g'\"" |
  57.   \ endif
  58.   " don't write swapfile on most commonly used directories for NFS mounts or USB sticks
  59.   autocmd BufNewFile,BufReadPre /media/*,/mnt/* set directory=~/tmp,/var/tmp,/tmp
  60.   augroup END
  61. endif
  62.  
  63.  
  64.  
  65. "Toggle free-move mode with /w ( alltså § )
  66. noremap <silent> § :call ToggleWrap()<CR>
  67. function ToggleWrap()
  68.   if &wrap
  69.     echo "Wrap OFF"
  70.     setlocal nowrap
  71.     set virtualedit=all
  72.     silent! nunmap <buffer> <Up>
  73.     silent! nunmap <buffer> <Down>
  74.     silent! nunmap <buffer> <Home>
  75.     silent! nunmap <buffer> <End>
  76.     silent! iunmap <buffer> <Up>
  77.     silent! iunmap <buffer> <Down>
  78.     silent! iunmap <buffer> <Home>
  79.     silent! iunmap <buffer> <End>
  80.   else
  81.     echo "Wrap ON"
  82.     setlocal wrap linebreak nolist
  83.     set virtualedit=
  84.     setlocal display+=lastline
  85.     noremap  <buffer> <silent> <Up>   gk
  86.     noremap  <buffer> <silent> <Down> gj
  87.     noremap  <buffer> <silent> <Home> g<Home>
  88.     noremap  <buffer> <silent> <End>  g<End>
  89.     inoremap <buffer> <silent> <Up>   <C-o>gk
  90.     inoremap <buffer> <silent> <Down> <C-o>gj
  91.     inoremap <buffer> <silent> <Home> <C-o>g<Home>
  92.     inoremap <buffer> <silent> <End>  <C-o>g<End>
  93.   endif
  94. endfunction
  95.  
  96.  
  97.  
  98. " Allow to change encoding using F8
  99. function! ChangeFileencoding()
  100.         let encodings = ['iso-8859-1', 'utf-8', 'iso-8859-15']
  101.         let prompt_encs = []
  102.         let index = 0
  103.         while index < len(encodings)
  104.                 call add(prompt_encs, index.'. '.encodings[index])
  105.                 let index = index + 1
  106.         endwhile
  107.         let choice = inputlist(prompt_encs)
  108.         if choice >= 0 && choice < len(encodings)
  109.                 execute 'e ++enc='.encodings[choice].' %:p'
  110.         endif
  111. endf
  112. nmap <F8> :call ChangeFileencoding()<CR>
  113.  
  114.  
  115.  
  116. " Vim support file to switch on loading indent files for file types
  117. if exists("did_indent_on")
  118.   finish
  119. endif
  120. let did_indent_on = 1
  121.  
  122. augroup filetypeindent
  123.   au FileType * call s:LoadIndent()
  124.   func! s:LoadIndent()
  125.     if exists("b:undo_indent")
  126.       exe b:undo_indent
  127.       unlet! b:undo_indent b:did_indent
  128.     endif
  129.     let s = expand("<amatch>")
  130.     if s != ""
  131.       if exists("b:did_indent")
  132.         unlet b:did_indent
  133.       endif
  134.  
  135.       " When there is a dot it is used to separate filetype names.  Thus for
  136.       " "aaa.bbb" load "indent/aaa.vim" and then "indent/bbb.vim".
  137.       for name in split(s, '\.')
  138.         exe 'runtime! indent/' . name . '.vim'
  139.       endfor
  140.     endif
  141.   endfunc
  142. augroup END
Add Comment
Please, Sign In to add comment