]> code.delx.au - dotfiles/blobdiff - .vim/abbrs2vim.py
Convert tabs to spaces
[dotfiles] / .vim / abbrs2vim.py
index ea77fb73b67ffd50f342ebe78c16ed8ce7572c56..a2a37f5f04bdc07f17dda02391e2df465c5ba9c3 100644 (file)
@@ -13,31 +13,31 @@ macros["EMAIL"] = lambda: EMAIL or os.environ.get("EMAIL", "~/.vim/abbrs2vim.py"
 
 vimdir = os.path.join(os.environ.get("HOME"), ".vim")
 try:
-       outfilename = os.path.join(vimdir, "abbrsout.vim")
-       outfile = open(outfilename, "w")
+    outfilename = os.path.join(vimdir, "abbrsout.vim")
+    outfile = open(outfilename, "w")
 except IOError:
-       print >> sys.stderr, "Couldn't open output file for writing: %s" % outfilename
-       sys.exit(1)
+    print >> sys.stderr, "Couldn't open output file for writing: %s" % outfilename
+    sys.exit(1)
 
 abbrsdir = os.path.join(vimdir, "abbrs")
 if not os.path.isdir(abbrsdir):
-       print >> sys.stderr, "Could not find directory with abbreviations: %s" % abbrsdir
-       sys.exit(1)
+    print >> sys.stderr, "Could not find directory with abbreviations: %s" % abbrsdir
+    sys.exit(1)
 
 for abbrfile in os.listdir(abbrsdir):
-       abbr = open(os.path.join(abbrsdir, abbrfile), "r").read()
-       for macro in macros.keys():
-               if abbr.find(macro) >= 0:
-                       abbr = abbr.replace(macro, macros[macro]())
-       abbr = abbr.replace("\n", "\r")
-       # Put into paste mode and take out of paste mode
-       abbr = "iab %s \x1b:set paste\ri%s\x1b:set nopaste\r" % (abbrfile.rsplit('.', 1)[0], abbr)
-       if abbr.find("___") >= 0:
-               # Then search for ___ to place the cursor there
-               abbr += "gg\r/___\x1b:nohlsearch\n"
-       else:
-               # Leave the cursor in insert mode
-               abbr += "a\n"
-       outfile.write(abbr)
+    abbr = open(os.path.join(abbrsdir, abbrfile), "r").read()
+    for macro in macros.keys():
+        if abbr.find(macro) >= 0:
+            abbr = abbr.replace(macro, macros[macro]())
+    abbr = abbr.replace("\n", "\r")
+    # Put into paste mode and take out of paste mode
+    abbr = "iab %s \x1b:set paste\ri%s\x1b:set nopaste\r" % (abbrfile.rsplit('.', 1)[0], abbr)
+    if abbr.find("___") >= 0:
+        # Then search for ___ to place the cursor there
+        abbr += "gg\r/___\x1b:nohlsearch\n"
+    else:
+        # Leave the cursor in insert mode
+        abbr += "a\n"
+    outfile.write(abbr)