SHARE
TWEET

VIM Settings

carefulnow Nov 14th, 2017 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # reset to vim-defaults
  2. if &compatible          # only if not set before:
  3.   set nocompatible      # use vim-defaults instead of vi-defaults (easier, more user friendly)
  4. endif
  5.  
  6. # display settings
  7. set background=dark     # enable for dark terminals
  8. set nowrap              # dont wrap lines
  9. set scrolloff=2         # 2 lines above/below cursor when scrolling
  10. set number              # show line numbers
  11. set showmatch           # show matching bracket (briefly jump)
  12. set showmode            # show mode in status bar (insert/replace/...)
  13. set showcmd             # show typed command in status bar
  14. set ruler               # show cursor position in status bar
  15. set title               # show file in titlebar
  16. set wildmenu            # completion with menu
  17. set wildignore=*.o,*.obj,*.bak,*.exe,*.py[co],*.swp,*~,*.pyc,.svn
  18. set laststatus=2        # use 2 lines for the status bar
  19. set matchtime=2         # show matching bracket for 0.2 seconds
  20. set matchpairs+=<:>     # specially for html
  21.  
  22. # editor settings
  23. set esckeys             # map missed escape sequences (enables keypad keys)
  24. set ignorecase          # case insensitive searching
  25. set smartcase           # but become case sensitive if you type uppercase characters
  26. set smartindent         # smart auto indenting
  27. set smarttab            # smart tab handling for indenting
  28. set magic               # change the way backslashes are used in search patterns
  29. set bs=indent,eol,start # Allow backspacing over everything in insert mode
  30.  
  31. set tabstop=4           # number of spaces a tab counts for
  32. set shiftwidth=4        # spaces for autoindents
  33. #set expandtab           # turn a tabs into spaces
  34.  
  35. set fileformat=unix     # file mode is unix
  36. #set fileformats=unix,dos    # only detect unix file format, displays that ^M with dos files
  37.  
  38. # system settings
  39. set lazyredraw          # no redraws in macros
  40. set confirm             # get a dialog when :q, :w, or :wq fails
  41. set nobackup            # no backup~ files.
  42. set viminfo='20,\"500   # remember copy registers after quitting in the .viminfo file -- 20 jump links, regs up to 500 lines'
  43. set hidden              # remember undo after quitting
  44. set history=50          # keep 50 lines of command history
  45. set mouse=v             # use mouse in visual mode (not normal,insert,command,help mode
  46.  
  47.  
  48. # color settings (if terminal/gui supports it)
  49. if &t_Co > 2 || has("gui_running")
  50.   syntax on          # enable colors
  51.   set hlsearch       # highlight search (very useful!)
  52.   set incsearch      # search incremently (search while typing)
  53. endif
  54.  
  55. # paste mode toggle (needed when using autoindent/smartindent)
  56. map <F10> :set paste<CR>
  57. map <F11> :set nopaste<CR>
  58. imap <F10> <C-O>:set paste<CR>
  59. imap <F11> <nop>
  60. set pastetoggle=<F11>
  61.  
  62. # Use of the filetype plugins, auto completion and indentation support
  63. filetype plugin indent on
  64.  
  65. # file type specific settings
  66. if has("autocmd")
  67.   # For debugging
  68.   #set verbose=9
  69.  
  70.   # if bash is sh.
  71.   let bash_is_sh=1
  72.  
  73.   # change to directory of current file automatically
  74.   autocmd BufEnter * lcd %:p:h
  75.  
  76.   # Put these in an autocmd group, so that we can delete them easily.
  77.   augroup mysettings
  78.     au FileType xslt,xml,css,html,xhtml,javascript,sh,config,c,cpp,docbook set smartindent shiftwidth=2 softtabstop=2 expandtab
  79.     au FileType tex set wrap shiftwidth=2 softtabstop=2 expandtab
  80.  
  81.     # Confirm to PEP8
  82.     au FileType python set tabstop=4 softtabstop=4 expandtab shiftwidth=4 cinwords=if,elif,else,for,while,try,except,finally,def,class
  83.   augroup END
  84.  
  85.   augroup perl
  86.     # reset (disable previous 'augroup perl' settings)
  87.     au!  
  88.  
  89.     au BufReadPre,BufNewFile
  90.     \ *.pl,*.pm
  91.     \ set formatoptions=croq smartindent shiftwidth=2 softtabstop=2 cindent cinkeys='0{,0},!^F,o,O,e' " tags=./tags,tags,~/devel/tags,~/devel/C
  92.     # formatoption:
  93.     #   t - wrap text using textwidth
  94.     #   c - wrap comments using textwidth (and auto insert comment leader)
  95.     #   r - auto insert comment leader when pressing <return> in insert mode
  96.     #   o - auto insert comment leader when pressing 'o' or 'O'.
  97.     #   q - allow formatting of comments with "gq"
  98.     #   a - auto formatting for paragraphs
  99.     #   n - auto wrap numbered lists
  100.     #  
  101.   augroup END
  102.  
  103.  
  104.   # Always jump to the last known cursor position.
  105.   # Don't do it when the position is invalid or when inside
  106.   # an event handler (happens when dropping a file on gvim).
  107.   autocmd BufReadPost *
  108.     \ if line("'\"") > 0 && line("'\"") <= line("$") |
  109.     \   exe "normal g`\"" |
  110.     \ endif
  111.  
  112. endif # has("autocmd")
RAW Paste Data
Top