]> code.delx.au - dotfiles/commitdiff
Vim config improvements
authorJames Bunton <jamesbunton@delx.net.au>
Sun, 8 Jul 2007 09:01:17 +0000 (19:01 +1000)
committerJames Bunton <jamesbunton@delx.net.au>
Sun, 8 Jul 2007 09:01:17 +0000 (19:01 +1000)
 * Grab email address from the environment variables
 * On vim first run, generate the abbrsout.vim file
 * Made CTRL-n/p do something useful
 * Split commenter into a separate file

.vim/abbrs/ccopy.c
.vim/abbrs/pycopy.py
.vim/abbrs2vim.py
.vim/abbrsout.vim [deleted file]
.vim/commands.vim
.vim/commenter.vim [new file with mode: 0644]
.vimrc

index b30498b78c2d1d5453eda33c1b33c5a7b814fa6b..27f2e9aa182dc3f268a65ddb184fae743434fda9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright YEAR NAME <EMAIL>
+/* Copyright YEAR EMAIL
  * Licensed for distribution under the GPL version 2.
  *
  * ___Program purpose...
index a14139af58a02110fb85bbb88dc9addec8db2a57..cf711611a114b7fc1f888a5c242b6d304b77da09 100644 (file)
@@ -1,3 +1,3 @@
-# Copyright YEAR NAME <EMAIL>
+# Copyright YEAR EMAIL
 # Licensed for distribution under the GPL version 2, check COPYING for details
 # ___Program purpose
index 5e8e9a74af9760f1e44623f1c3469050542029b5..57b387ac4e6f77005a75d1fd5ddf0985db2e0e3c 100644 (file)
@@ -2,11 +2,13 @@
 
 import time, os, os.path, sys
 
+# To override the defaults, set these variables
+EMAIL = ""
+
 macros = {}
 macros["YDATE"] = lambda: time.strftime("%Y-%m-%d")
 macros["YEAR"]  = lambda: time.strftime("%Y")
-macros["NAME"]  = lambda: "Put your name in ~/.vim/abbrs2out.vim"
-macros["EMAIL"] = lambda: "Then run that script"
+macros["EMAIL"] = lambda: EMAIL or os.environ.get("EMAIL")
 
 
 vimdir = os.path.join(os.environ.get("HOME"), ".vim")
diff --git a/.vim/abbrsout.vim b/.vim/abbrsout.vim
deleted file mode 100644 (file)
index 8b13789..0000000
+++ /dev/null
@@ -1 +0,0 @@
-
index ddac8c5b272c62ec4a5f98796d3b2ca267b0cc1b..ded7fad658e84a73d87ccaea7f1678a1a48185ac 100644 (file)
@@ -4,42 +4,11 @@ command! -nargs=+ Calc :r! python -c "from math import *; print <args>"
 " Unhighlight search results
 map <C-l> :nohlsearch<CR>:redraw!<CR>
 
-" Commenting of lines! Stolen & modified from vim.org's ToggleCommentify
-map <C-c> :call ToggleCommentify()<CR>j
-imap <C-c> <ESC>:call ToggleCommentify()<CR>j
-" The nice thing about these mapping is that you don't have to select a visual block to comment 
-" ... just keep the CTRL-key pressed down and tap on 'c' as often as you need. 
+" Map Y to be consistent with D, C, etc
+noremap Y y$
 
-function! ToggleCommentify()
-       let lineString = getline(".")
-       if lineString != $                                                                      " don't comment empty lines
-               let isCommented = strpart(lineString,0,3)               " getting the first 3 symbols
-               let fileType = &ft                                                              " finding out the file-type, and specifying the comment symbol
-               if fileType == 'ox' || fileType == 'java' || fileType == 'cpp' || fileType == 'c' || fileType == 'php'
-                       let commentSymbol = '///'
-               elseif fileType == 'vim'
-                       let commentSymbol = '"""'
-               elseif fileType == 'python' || fileType == 'sh'
-                       let commentSymbol = '###'
-               else
-                       execute 'echo "ToggleCommentify has not (yet) been implemented for this file-type"'
-                       let commentSymbol = ''
-               endif
-               if isCommented == commentSymbol                                 
-                       call UnCommentify(commentSymbol)                        " if the line is already commented, uncomment
-               else
-                       call Commentify(commentSymbol)                          " if the line is uncommented, comment
-               endif
-       endif
-endfunction
+" CTRL-n and CTRL-p to go forwards and backwards through files
+nnoremap <C-n> :next<CR>
+nnoremap <C-p> :prev<CR>
 
-function! Commentify(commentSymbol)    
-       execute ':s+^+'.a:commentSymbol.'+'
-       nohlsearch
-endfunction
-       
-function! UnCommentify(commentSymbol)  
-       execute ':s+'.a:commentSymbol.'++'
-       nohlsearch
-endfunction
 
diff --git a/.vim/commenter.vim b/.vim/commenter.vim
new file mode 100644 (file)
index 0000000..10aab96
--- /dev/null
@@ -0,0 +1,39 @@
+" Commenting of lines! Stolen & modified from vim.org's ToggleCommentify
+map <C-c> :call ToggleCommentify()<CR>j
+imap <C-c> <ESC>:call ToggleCommentify()<CR>j
+" The nice thing about these mapping is that you don't have to select a visual block to comment 
+" ... just keep the CTRL-key pressed down and tap on 'c' as often as you need. 
+
+function! ToggleCommentify()
+       let lineString = getline(".")
+       if lineString != $                                                                      " don't comment empty lines
+               let isCommented = strpart(lineString,0,3)               " getting the first 3 symbols
+               let fileType = &ft                                                              " finding out the file-type, and specifying the comment symbol
+               if fileType == 'ox' || fileType == 'java' || fileType == 'cpp' || fileType == 'c' || fileType == 'php'
+                       let commentSymbol = '///'
+               elseif fileType == 'vim'
+                       let commentSymbol = '"""'
+               elseif fileType == 'python' || fileType == 'sh'
+                       let commentSymbol = '###'
+               else
+                       execute 'echo "ToggleCommentify has not (yet) been implemented for this file-type"'
+                       let commentSymbol = ''
+               endif
+               if isCommented == commentSymbol                                 
+                       call UnCommentify(commentSymbol)                        " if the line is already commented, uncomment
+               else
+                       call Commentify(commentSymbol)                          " if the line is uncommented, comment
+               endif
+       endif
+endfunction
+
+function! Commentify(commentSymbol)    
+       execute ':s+^+'.a:commentSymbol.'+'
+       nohlsearch
+endfunction
+       
+function! UnCommentify(commentSymbol)  
+       execute ':s+'.a:commentSymbol.'++'
+       nohlsearch
+endfunction
+
diff --git a/.vimrc b/.vimrc
index 5da7d0f48febe4850c45663ab8c65b78b14479e9..a227de2ff7e117f7982b673cc88f949aa0acf25f 100644 (file)
--- a/.vimrc
+++ b/.vimrc
@@ -15,6 +15,10 @@ source ~/.vim/display.vim
 source ~/.vim/mouse.vim
 source ~/.vim/indent.vim
 source ~/.vim/search.vim
-source ~/.vim/abbrsout.vim
 source ~/.vim/commands.vim
+source ~/.vim/commenter.vim
+if !filereadable(expand("~/.vim/abbrsout.vim"))
+       !python ~/.vim/abbrs2vim.py
+endif
+source ~/.vim/abbrsout.vim