]> code.delx.au - dotfiles/blobdiff - .vim/commenter.vim
Convert tabs to spaces
[dotfiles] / .vim / commenter.vim
index 5e63cf4e866288c91188d96b0845248df530bce1..8c8dd9f12fe5f7721063505c6c0ab43f9d7810de 100644 (file)
@@ -6,95 +6,95 @@ imap <C-_> <ESC>:call ToggleCommentify()<CR>j
 " often as you need. 
 
 function! ToggleCommentify()
-       let lineString = getline(".")
-       if strlen(lineString) == 0
-               " don't comment empty lines
-               return
-       endif
+    let lineString = getline(".")
+    if strlen(lineString) == 0
+        " don't comment empty lines
+        return
+    endif
 
-       let isCommented = strpart(lineString,0,3)
-       let commentSymbol = ''
-                               
-       let commentMapping = {
-               \'###': [
-                       \'conf',
-                       \'debsources',
-                       \'exports',
-                       \'fstab',
-                       \'make',
-                       \'mplayerconf',
-                       \'muttrc',
-                       \'perl',
-                       \'procmail',
-                       \'python',
-                       \'readline',
-                       \'ruby',
-                       \'screen',
-                       \'sh',
-                       \'sshconfig',
-                       \'sudoers',
-                       \'terminfo',
-                       \'vrml',
-                       \'xf86conf',
-               \],
+    let isCommented = strpart(lineString,0,3)
+    let commentSymbol = ''
+                
+    let commentMapping = {
+        \'###': [
+            \'conf',
+            \'debsources',
+            \'exports',
+            \'fstab',
+            \'make',
+            \'mplayerconf',
+            \'muttrc',
+            \'perl',
+            \'procmail',
+            \'python',
+            \'readline',
+            \'ruby',
+            \'screen',
+            \'sh',
+            \'sshconfig',
+            \'sudoers',
+            \'terminfo',
+            \'vrml',
+            \'xf86conf',
+        \],
 \
-               \'///': [
-                       \'c',
-                       \'cpp',
-                       \'java',
-                       \'javascript',
-                       \'objc',
-                       \'ox',
-                       \'php',
-               \],
+        \'///': [
+            \'c',
+            \'cpp',
+            \'java',
+            \'javascript',
+            \'objc',
+            \'ox',
+            \'php',
+        \],
 \
-               \'"""': [
-                       \'vim',
-               \],
+        \'"""': [
+            \'vim',
+        \],
 \
-               \'!!!': [
-                       \'xdefaults',
-               \],
+        \'!!!': [
+            \'xdefaults',
+        \],
 \
-               \'%%%': [
-                       \'matlab',
-                       \'tex',
-               \],
+        \'%%%': [
+            \'matlab',
+            \'tex',
+        \],
 \
-               \'---': [
-                       \'sql',
-                       \'haskell',
-               \]
-       \}
+        \'---': [
+            \'sql',
+            \'haskell',
+        \]
+    \}
 
-       for commentChar in keys(commentMapping)
-               for name in commentMapping[commentChar]
-                       if &filetype == name
-                               let commentSymbol = commentChar
-                       endif
-               endfor
-       endfor
+    for commentChar in keys(commentMapping)
+        for name in commentMapping[commentChar]
+            if &filetype == name
+                let commentSymbol = commentChar
+            endif
+        endfor
+    endfor
 
-       if commentSymbol == ''
-               execute 'echo "ToggleCommentify has not (yet) been implemented for the file-type " . &filetype'
-       else
-               if isCommented == commentSymbol
-                       " if the line is already commented, uncomment
-                       call UnCommentify(commentSymbol)
-               else
-                       " if the line is uncommented, comment
-                       call Commentify(commentSymbol)
-               endif
-       endif
+    if commentSymbol == ''
+        execute 'echo "ToggleCommentify has not (yet) been implemented for the file-type " . &filetype'
+    else
+        if isCommented == commentSymbol
+            " if the line is already commented, uncomment
+            call UnCommentify(commentSymbol)
+        else
+            " if the line is uncommented, comment
+            call Commentify(commentSymbol)
+        endif
+    endif
 endfunction
 
 function! Commentify(commentSymbol)
-       execute ':s+^+'.a:commentSymbol.'+'
-       nohlsearch
+    execute ':s+^+'.a:commentSymbol.'+'
+    nohlsearch
 endfunction
-       
+    
 function! UnCommentify(commentSymbol)
-       execute ':s+'.a:commentSymbol.'++'
-       nohlsearch
+    execute ':s+'.a:commentSymbol.'++'
+    nohlsearch
 endfunction