Guest User

Untitled

a guest
Apr 16th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 18.40 KB | None | 0 0
  1. " Rev 103
  2.  
  3.  
  4.  
  5. " ==============================
  6. " General Setup
  7. " ==============================
  8.  
  9. " Disable compatibility with vi (must come first)
  10. set nocompatible
  11.  
  12. " Restore screen contents when exiting Vim
  13. set restorescreen
  14.  
  15. " Enable the mouse for all modes
  16. set mouse=a
  17.  
  18. " Hide mouse while typing text
  19. set mousehide
  20.  
  21. " Use all abbreviations in messages
  22. set shortmess=a
  23.  
  24. " Preferably use Unix file format
  25. set fileformats=unix,dos
  26.  
  27. " Display line numbers in front of each line
  28. set number
  29.  
  30. " Never report changes
  31. set report=10000
  32.  
  33. " Display commands in the bottom right corner as they are typed
  34. set showcmd
  35.  
  36. " Size of the history
  37. set history=150
  38.  
  39. " Use a higher timeout for mappings, so that keycodes will time out first
  40. set timeout ttimeoutlen=40 timeoutlen=45
  41.  
  42. " Don't keep backups
  43. set nobackup
  44. set writebackup
  45.  
  46. " Use <Tab> for command-line completion
  47. set wildchar=<Tab>
  48.  
  49. " Display a list of matches when using command-line completion
  50. set wildmenu
  51. set wildmode=full
  52. set wildignore=*.o,*.obj,*.pyc,*.pyo,*.swp,.sconsign.dblite
  53.  
  54. " Disable any kind of bell
  55. set t_vb=
  56. set noerrorbells
  57. set novisualbell
  58.  
  59. " Smoother redraws
  60. set ttyfast
  61.  
  62. " Do not redraw when running macros
  63. set lazyredraw
  64.  
  65. " Title of the window
  66. set title
  67. set titlestring=%F\ %m
  68.  
  69. " Abbrev for tabs
  70. cnoreabbrev tt tabnew
  71. cnoreabbrev tc tabclose
  72. cnoreabbrev tp tabprevious
  73. cnoreabbrev tn tabnext
  74.  
  75. " ==============================
  76. " Text edition
  77. " ==============================
  78.  
  79. " Syntax highlighting
  80. syntax on
  81.  
  82. " Don't cut lines
  83. set textwidth=0
  84.  
  85. " Don't put two spaces after . ? ! when joining lines
  86. set nojoinspaces
  87.  
  88. " Tab width
  89. set shiftwidth=4
  90. set softtabstop=4
  91.  
  92. " Uncomment to Insert spaces insteads of tabs
  93. " set expandtab
  94.  
  95. " Allow the backspace key to delete anything in insert mode
  96. set backspace=indent,eol,start
  97.  
  98. " Display trailing spaces using ~ characters and tabs with -> characters
  99. set listchars=tab:<-,trail:~
  100.  
  101. " Don't break words
  102. set linebreak
  103.  
  104. " Display as many lines as possible
  105. set display=lastline
  106.  
  107. " Always keep 20 lines above and below the cursor if possible
  108. set scrolloff=20
  109.  
  110. " Virtual editing in block mode
  111. set virtualedit=block
  112.  
  113.  
  114.  
  115. " ==============================
  116. " Searching/Replacing
  117. " ==============================
  118.  
  119. " Incremental search
  120. set incsearch
  121.  
  122. " Highlight search terms
  123. set hlsearch
  124.  
  125. " Ignore case when searching, but only if all letters are lowercase
  126. set smartcase
  127. set ignorecase
  128.  
  129. " Wrap search when EOF is reached
  130. set wrapscan
  131.  
  132. " Always replace all occurrences on a line, not just the first one
  133. set gdefault
  134.  
  135.  
  136.  
  137. " ==============================
  138. " Insert mode completion
  139. " ==============================
  140.  
  141. " Don't show possible completions that don't match the case of existing text
  142. set infercase
  143.  
  144. " Don't show more than 10 items in the popup menu
  145. set pumheight=10
  146.  
  147. " Where to look for possible completions
  148. set complete=.,w,u,b,kspell
  149.  
  150. " How to show and insert possible completions
  151. set completeopt=menu,longest
  152.  
  153.  
  154.  
  155. " ==============================
  156. " Status line
  157. " ==============================
  158.  
  159. " Always display the status line
  160. set laststatus=2
  161.  
  162. " Show the current editing status
  163. set showmode
  164.  
  165. " Human readable file size
  166. fu! StatuslineFilesize()
  167.     let filesize = line2byte(line("$") + 1) - 1
  168.  
  169.     if filesize < 0
  170.         return ""
  171.     elseif filesize < 1024
  172.         return " | " . filesize . " Bytes"
  173.     elseif filesize < 1024*1024
  174.         return " | " . (filesize / 1024) . " kB"
  175.     else
  176.         return " | " . (filesize / (1024*1024)) . " MB"
  177.     endif
  178. endf
  179.  
  180.  
  181. " Format string
  182. set statusline=%t\ \|\ %L\ lines%{StatuslineFilesize()}\ %y%m%=L%-6l\ C%-2c
  183.  
  184. " ==============================
  185. " Template
  186. " ==============================
  187. function! LoadTemplate()
  188.       silent! 0r ~/.vim/tmpl.%:e
  189. endfunction
  190.  
  191. autocmd! BufNewFile * call LoadTemplate()
  192.  
  193. " ==============================
  194. " Tabs
  195. " ==============================
  196.  
  197. " Return the string used as the tabline
  198. fu! TabLine()
  199.  
  200.     let tabline = ''
  201.  
  202.     for i in range(tabpagenr('$'))
  203.  
  204.         let currtabnr  = i + 1
  205.         let currbuflst = tabpagebuflist(currtabnr)
  206.  
  207.         " Set the correct highlighting for the current tab
  208.         let tabline .= ((currtabnr == tabpagenr()) ? '%#TabLineSel#' : '%#TabLine#')
  209.  
  210.         " Tab number (for mouse clicks)
  211.         let tabline .= '%' . (currtabnr) . 'T'
  212.  
  213.         " Filename of the current window (no path)
  214.         let filename = bufname(currbuflst[tabpagewinnr(currtabnr) - 1])
  215.  
  216.         if filename != ''
  217.             let filename = fnamemodify(filename, ':t')
  218.         else
  219.             let filename = '[No Name]'
  220.         endif
  221.  
  222.         " Check whether one of the buffers has been modified
  223.         let bufmodified = ''
  224.  
  225.         for bufnr in range(len(currbuflst))
  226.             if getbufvar(currbuflst[bufnr], "&mod") == 1
  227.                 let bufmodified = ' [+]'
  228.                 break
  229.             endif
  230.         endfor
  231.  
  232.         " Number of buffers
  233.         let nbbuf = tabpagewinnr(currtabnr, '$')
  234.  
  235.         if nbbuf == 1
  236.             let nbbuf = ''
  237.         else
  238.             let nbbuf = ':' . nbbuf
  239.         endif
  240.  
  241.         " Name of the tab
  242.         if currtabnr == tabpagenr()
  243.             let tabline .= filename . nbbuf . bufmodified . '%#TabLine#  '
  244.         else
  245.             let tabline .= filename . nbbuf . bufmodified . '  '
  246.         endif
  247.  
  248.     endfor
  249.  
  250.     return tabline . '%#TabLineFill#%T'
  251.  
  252. endf
  253.  
  254.  
  255. " Shift the current tab to the left (direction == 0) or to the right (direction != 0)
  256. fu! ShiftTab(direction)
  257.     let tabpos = tabpagenr()
  258.  
  259.     if a:direction == 0
  260.         if tabpos == 1
  261.             exe 'tabm' . tabpagenr('$')
  262.         else
  263.             exe 'tabm' . (tabpos - 2)
  264.         endif
  265.     else
  266.         if tabpos == tabpagenr('$')
  267.             exe 'tabm ' . 0
  268.         else
  269.             exe 'tabm ' . tabpos
  270.         endif
  271.     endif
  272.  
  273.     return ''
  274. endf
  275.  
  276.  
  277. " Use a custom function to draw the tabline
  278. set tabline=%!TabLine()
  279.  
  280. " Shift the current tab to the left/right
  281. inoremap <silent> <C-S-Left>  <C-r>=ShiftTab(0)<CR>
  282. inoremap <silent> <C-S-Right> <C-r>=ShiftTab(1)<CR>
  283.  
  284. noremap <silent> <C-S-Left>  :call ShiftTab(0)<CR>
  285. noremap <silent> <C-S-Right> :call ShiftTab(1)<CR>
  286.  
  287. " Ctrl-t creates a new tab and opens the file explorer
  288. map  <silent> <C-t> :Texplore<CR>
  289. imap <silent> <C-t> <Esc><C-t>
  290.  
  291.  
  292.  
  293. " ==============================
  294. " File explorer
  295. " ==============================
  296.  
  297. " Prevent some files/directories from being listed
  298. let g:netrw_hide=1
  299. let g:netrw_list_hide='^\./$,^CVS/$,\.o$,\.pyc$,\.pyo$,\.swp$,^\.svn/$,^\.bzr/$,^\.sconsign.dblite$'
  300.  
  301. " Reuse the same window when opening a file
  302. let g:netrw_browse_split=0
  303.  
  304. " Always update directories' contents
  305. let g:netrw_fastbrowse=0
  306.  
  307. " Tree view
  308. let g:netrw_liststyle=3
  309.  
  310. " Highlight the current line
  311. let g:netrw_cursorline=1
  312.  
  313.  
  314.  
  315. " ==============================
  316. " Some functions used later on
  317. " ==============================
  318.  
  319. " See :help restore-cursor
  320. fu! RestoreCursorOnBufRead()
  321.     " Don't restore the cursor position for SVN commit logs
  322.     if line("'\"") > 0 && line("'\"") <= line("$") && bufname('%') != 'svn-commit.tmp'
  323.         exe "normal! g`\""
  324.     endif
  325. endf
  326.  
  327. " See :help restore-position
  328. fu! SaveCurPos()
  329.     execute "normal msHmtgg"
  330. endf
  331.  
  332.  
  333. " See :help restore-position
  334. fu! RestoreCurPos()
  335.     execute "normal 'tzt`s"
  336. endf
  337.  
  338.  
  339. " Reformat the file
  340. fu! FormatFile()
  341.     call SaveCurPos()
  342.     execute "normal gg=G"
  343.     call RestoreCurPos()
  344. endf
  345.  
  346.  
  347. " Remove trailing spaces
  348. fu! RemoveTrailingSpaces()
  349.     call SaveCurPos()
  350.     %s/\s\+$//e
  351.     call RestoreCurPos()
  352. endf
  353.  
  354.  
  355. " Remove trailing line feed characters
  356. fu! Dos2Unix()
  357.     call SaveCurPos()
  358.     execute ":%s/\r$//g"
  359.     call RestoreCurPos()
  360. endf
  361.  
  362.  
  363. " Comment the latest visual selection when applicable
  364. " If firstCol is 1, the comment is always put in the first column, no matter the indentation of the lines
  365. fu! Comment(firstCol)
  366.     call SaveCurPos()
  367.     if &filetype == "python" || &filetype == "zsh" || &filetype == "sh" || &filetype == "gnuplot" || &filetype == "make" || &filetype == "cfg"
  368.         if a:firstCol == 1
  369.             execute ":'<,'>s/^/# /"
  370.         else
  371.             execute ":'<,'>s/\\(^\\s*\\)/\\1\# /"
  372.         endif
  373.     elseif &filetype == "cpp" || &filetype == "c" || &filetype == "nesc" || &filetype == "java" || &filetype == "php"
  374.         if a:firstCol == 1
  375.             execute ":'<,'>s@^@// @"
  376.         else
  377.             execute ":'<,'>s@\\(^\\s*\\)@\\1// @"
  378.         endif
  379.     elseif &filetype == "tex" || &filetype == "bib"
  380.         if a:firstCol == 1
  381.             execute ":'<,'>s/^/% /"
  382.         else
  383.             execute ":'<,'>s/\\(^\\s*\\)/\\1% /"
  384.         endif
  385.     elseif &filetype == "css" || &filetype == "javascript"
  386.         execute ":'<-1put='/*'"
  387.         execute ":'>put='*/'"
  388.     elseif &filetype == "xml" || &filetype == "html" || &filetype == "ant"
  389.         execute ":'<-1put='<!--'"
  390.         execute ":'>put='-->'"
  391.     elseif &filetype == "vim"
  392.         if a:firstCol == 1
  393.             execute ":'<,'>s/^/\" /"
  394.         else
  395.             execute ":'<,'>s/\\(^\\s*\\)/\\1\" /"
  396.         endif
  397.     endif
  398.     call RestoreCurPos()
  399. endf
  400.  
  401.  
  402. " Insert a tab or complete the current word
  403. fu! CleverTab(mode)
  404.     if a:mode == 0 || strpart( getline('.'), 0, col('.')-1 ) =~ '^\s*$'
  405.         return "\<tab>"
  406.     elseif a:mode == 1
  407.         return "\<c-p>"
  408.     else
  409.         return "\<c-n>"
  410.     endif
  411. endf
  412.  
  413.  
  414. " Cycle between spell check off, on (English), and on (French)
  415. fu! CycleSpellChecking()
  416.     if &spell == 0
  417.         setlocal spelllang=en
  418.         setlocal spell
  419.         echo "Spell check on (English)"
  420.     elseif &spelllang == "en"
  421.         setlocal spelllang=fr
  422.         echo "Spell check on (French)"
  423.     else
  424.         setlocal nospell
  425.         echo "Spell check off"
  426.     endif
  427. endf
  428.  
  429.  
  430. " Eat the next character, see :help abbreviations
  431. fu! EatChar(pat)
  432.     let c = nr2char(getchar(0))
  433.     return (c =~ a:pat) ? '' : c
  434. endf
  435.  
  436.  
  437.  
  438. " ==============================
  439. " Commands
  440. " ==============================
  441.  
  442. com! Dos2Unix  :call Dos2Unix()
  443. com! Diff      vert new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis
  444. com! RcEdit    :e ~/.vimrc
  445. com! RcReload  :so ~/.vimrc
  446. com! RcTabEdit :tabnew ~/.vimrc
  447.  
  448.  
  449. " ==============================
  450. " Global mappings
  451. " ==============================
  452.  
  453. " Move between screen lines instead of real lines
  454. noremap <Up>   gk
  455. noremap <Down> gj
  456. noremap <Home> g<Home>
  457. noremap <End>  g<End>
  458.  
  459. inoremap <Up>   <C-o>gk
  460. inoremap <Down> <C-o>gj
  461. inoremap <Home> <C-o>g<Home>
  462. inoremap <End>  <C-o>g<End>
  463.  
  464. " Alt + Right/Left moves between sentences
  465. noremap <A-Right> )
  466. noremap <A-Left>  (
  467.  
  468. inoremap <A-Right> <C-O>)
  469. inoremap <A-Left>  <C-O>(
  470.  
  471. " Prevent the cursor from moving when escaping from insert mode
  472. " The second mapping forces Vim to wait during the full time out before applying the first one
  473. " Otherwise, the first mapping prevents extended keycodes to work in a terminal
  474. inoremap <Esc>      <Right><Esc>
  475. inoremap <Esc><Esc> <Esc>
  476.  
  477. " Make Y yanks from the cursor to the end of the line
  478. map Y y$
  479.  
  480. " Enter adds a line below the current one in command mode
  481. map <silent> <CR> o<ESC>
  482.  
  483. " Let space and backspace act the same as in insert mode
  484. map <silent> <Space>     i<Space><Esc>
  485. map <silent> <Backspace> X
  486.  
  487. " In visual mode, enclose the selection with the given character
  488. vnoremap <silent> ' s''<Esc>P
  489. vnoremap <silent> " s""<Esc>P
  490. vnoremap <silent> ( s()<Esc>P
  491. vnoremap <silent> { s{}<Esc>P
  492. vnoremap <silent> [ s[]<Esc>P
  493. vnoremap <silent> * s**<Esc>P
  494.  
  495. " <F2> cycles between all spell checking states
  496. map  <silent> <F2> :call CycleSpellChecking()<CR>
  497. imap <silent> <F2> <C-o><F2>
  498.  
  499. " <F3> reformats the file
  500. map  <silent> <F3> :call FormatFile()<CR>
  501. imap <silent> <F3> <C-o><F3>
  502.  
  503. " Ctrl-x clears highlight
  504. map  <silent> <C-x> :noh<CR>
  505. imap <silent> <C-x> <C-o><C-x>
  506.  
  507. " Ctrl-a selects everything
  508. map <C-a> ggVG
  509.  
  510. " Completion and tabs
  511. inoremap <silent> <tab>   <C-r>=CleverTab(2)<CR>
  512. inoremap <silent> <S-Tab> <C-r>=CleverTab(1)<CR>
  513. inoremap <silent> <C-Tab> <C-r>=CleverTab(0)<CR>
  514.  
  515. " Comment the visual selection
  516. vnoremap <silent> / <Esc>:call Comment(1)<CR>
  517.  
  518.  
  519.  
  520. " ==============================
  521. " Global abbreviations
  522. " ==============================
  523.  
  524. iab to=  TODO<C-O>V<Esc><C-R>=Comment(0)<CR><C-O>g_<Right>
  525. iab fix= FIXME<C-O>V<Esc><C-R>=Comment(0)<CR><C-O>g_<Right>
  526.  
  527.  
  528.  
  529. " ==============================
  530. " File types
  531. " ==============================
  532.  
  533. filetype on
  534. filetype indent on
  535.  
  536. " Set the correct file type for some files
  537. au BufRead,BufNewFile,BufFilePost *.nc        set filetype=nesc
  538. au BufRead,BufNewFile,BufFilePost *.plt       set filetype=gnuplot
  539. au BufRead,BufNewFile,BufFilePost sconstruct  set filetype=python
  540. au BufRead,BufNewFile,BufFilePost *.cls,*.tex set filetype=tex
  541.  
  542. " Define specific options for some file types
  543. au FileType xml             call ModeXML()
  544. au FileType css             call ModeCSS()
  545. au FileType tex             call ModeLaTeX()
  546. au FileType bib             call ModeBibTeX()
  547. au FileType help            call ModeHelp()
  548. au FileType python          call ModePython()
  549. au FileType vim,changelog   setlocal textwidth=0
  550. au FileType c,cpp,nesc,java call ModeJavaC()
  551.  
  552.  
  553.  
  554. " ==============================
  555. " XML mode
  556. " ==============================
  557.  
  558. fu! ModeXML()
  559.  
  560.    " Automatically close angle brackets
  561.    inoremap <buffer> <lt> <><Left>
  562.  
  563. endf
  564.  
  565.  
  566.  
  567. " ==============================
  568. " CSS mode
  569. " ==============================
  570.  
  571. fu! ModeCSS()
  572.  
  573.    " Automatically insert closing brackets
  574.    inoremap <buffer> { {<CR>}<Up><CR>
  575.  
  576. endf
  577.  
  578.  
  579.  
  580. " ==============================
  581. " LaTeX mode
  582. " ==============================
  583.  
  584. fu! ModeLaTeX()
  585.  
  586.    " Some abbreviations
  587.    iab <buffer> fig=    \begin{figure}<CR>\centering<CR><CR>\caption{}<CR>\label{fig:}<CR>\end{figure}<Up><Up><Up><C-R>=EatChar('\s')<CR>
  588.    iab <buffer> fig*=   \begin{figure*}<CR>\centering<CR><CR>\caption{}<CR>\label{fig:}<CR>\end{figure*}<Up><Up><Up><C-R>=EatChar('\s')<CR>
  589.    iab <buffer> subfig= \subfloat[]{\label{subfig:}\includegraphics[width=]{}}\hfil<C-O>6<Left><C-R>=EatChar('\s')<CR>
  590.    iab <buffer> tab=    \begin{table}<CR>\centering<CR>\caption{}<CR>\label{tab:}<CR><CR>\end{table}<Up><C-R>=EatChar('\s')<CR>
  591.    iab <buffer> item=   \begin{itemize}<CR>\item<CR>\end{itemize}<Up><End>
  592.    iab <buffer> enum=   \begin{enumerate}<CR>\item<CR>\end{enumerate}<Up><End>
  593.    iab <buffer> desc=   \begin{description}<CR>\item[]<CR>\end{description}<Up><End><Left><C-R>=EatChar('\s')<CR>
  594.    iab <buffer> sec=    \section{}<CR>\label{sec:}<Up><End><Left><C-R>=EatChar('\s')<CR>
  595.    iab <buffer> sub=    \subsection{}<CR>\label{subsec:}<Up><End><Left><C-R>=EatChar('\s')<CR>
  596.    iab <buffer> subsub= \subsubsection{}<CR>\label{subsubsec:}<Up><End><Left><C-R>=EatChar('\s')<CR>
  597.    iab <buffer> graph=  \includegraphics[]{}<Left><Left><Left><C-R>=EatChar('\s')<CR>
  598.    iab <buffer> center= \begin{center}<CR>\end{center}<Up><End><CR><C-R>=EatChar('\s')<CR>
  599.    iab <buffer> cite=   <BS>~\cite{}<Left><C-R>=EatChar('\s')<CR>
  600.    iab <buffer> eq=     \begin{equation}<CR><CR>\end{equation}<Up><C-R>=EatChar('\s')<CR>
  601.  
  602.    " Beamer document class
  603.    iab <buffer> col=  \begin{column}{}<CR>\end{column}<Up><End><Left><C-R>=EatChar('\s')<CR>
  604.    iab <buffer> cols= \begin{columns}<CR>\end{columns}<Up><End><CR><C-R>=EatChar('\s')<CR>
  605.  
  606.    " In visual mode, enclose the selection with the given character
  607.    vnoremap <buffer> <silent> $ s$$<Esc>P
  608.    vnoremap <buffer> <silent> ' s`'<Esc>P
  609.    vnoremap <buffer> <silent> " s``''<Esc><Left>P<Right>
  610.  
  611.    " F8 launches scons
  612.    map  <buffer> <silent> <F8> :up<CR>:!scons<CR>
  613.    imap <buffer> <silent> <F8> <C-O>:up<CR><C-O>:!scons<CR>
  614.  
  615. endf
  616.  
  617.  
  618.  
  619. " ==============================
  620. " BibTeX mode
  621. " ==============================
  622.  
  623. fu! ModeBibTeX()
  624.  
  625.    " Some abbreviations
  626.    iab <buffer> str=  @STRING{ = ""}<C-O>5<left><C-R>=EatChar('\s')<CR>
  627.    iab <buffer> proc= @INPROCEEDINGS{,<CR>author    = {},<CR>title     = {},<CR>booktitle = ,<CR>year      = ,<CR>month     = ,<CR>}<C-O>6<Up><End><Left><C-R>=EatChar('\s')<CR>
  628.    iab <buffer> art=  @ARTICLE{,<CR>author  = {},<CR>title   = {},<CR>journal = ,<CR>volume  = ,<CR>number  = ,<CR>pages   = {--},<CR>year    = ,<CR>}<C-O>8<Up><End><Left><C-R>=EatChar('\s')<CR>
  629.    iab <buffer> tech= @TECHREPORT{,<CR>author      = {},<CR>title       = {},<CR>year        = ,<CR>institution = ,<CR>}<C-O>5<Up><End><Left><C-R>=EatChar('\s')<CR>
  630.    iab <buffer> phd=  @PHDTHESIS{,<CR>author = {},<CR>title  = {},<CR>year   = ,<CR>school = ,<CR>}<C-O>5<Up><End><Left><C-R>=EatChar('\s')<CR>
  631.  
  632. endf
  633.  
  634.  
  635.  
  636. " ==============================
  637. " Help mode
  638. " ==============================
  639.  
  640. func! ModeHelp()
  641.  
  642.    " <CR> and <backspace> to navigate
  643.    map <buffer> <CR>        <C-]>
  644.    map <buffer> <Backspace> <C-O>
  645.  
  646. endfunc
  647.  
  648.  
  649.  
  650. " ==============================
  651. " C/C++/Java mode
  652. " ==============================
  653.  
  654. fu! ModeJavaC()
  655.  
  656.    " Better indentation function
  657.    setlocal cindent
  658.  
  659.    " Don't automatically open new comment lines
  660.     setlocal formatoptions-=r
  661.  
  662.     " Don't put preprocessor directives at the start of the line
  663.     setlocal cinkeys-=0#
  664.  
  665.     " Make sure to automatically format pasted text
  666.     noremap <buffer> p p=`]`]
  667.     noremap <buffer> P P=`]`]
  668.  
  669.     " Automatically insert closing brackets
  670.     inoremap <buffer> { {<CR>}<Up><CR>
  671.  
  672.     " Some abbreviations
  673.     iab <buffer> com= /**<CR><Home><Space>*<CR><Home>**/<Up>
  674.     iab <buffer> def= #ifndef<CR>#define <CR><CR>#endif<C-O>gg<End>
  675.  
  676. endf
  677.  
  678.  
  679.  
  680. " ==============================
  681. " Python mode
  682. " ==============================
  683.  
  684. fu! ModePython()
  685.  
  686.     " Some abbreviations
  687.     iab <buffer> hb=  #!/usr/bin/env python<CR><CR><C-R>=EatChar('\s')<CR>
  688.     iab <buffer> def= def ():<CR>"""  """<CR>pass<Up><Up><Left><Left><Left><C-R>=EatChar('\s')<CR>
  689.     iab <buffer> cls= class :<CR><CR>def __init__(self):<CR>""" Constructor """<CR>pass<Up><Up><Up><Up><Left><C-R>=EatChar('\s')<CR>
  690.  
  691. endf
  692.  
  693.  
  694. " ==============================
  695. " Miscellaneous
  696. " ==============================
  697.  
  698. " Remove trailing spaces when saving buffers
  699. au BufWrite * if ! &bin | call RemoveTrailingSpaces() | endif
  700.  
  701. " Restore cursor position when reading a buffer
  702. au BufReadPost * call RestoreCursorOnBufRead()
  703.  
  704. " Always change to the directory of the current file
  705. au BufEnter * lcd %:p:h
  706.  
  707. " :TOhtml configuration
  708. let use_xhtml = 1
  709. let html_use_css = 1
  710. let html_ignore_folding = 1
Add Comment
Please, Sign In to add comment