Advertisement
alaestor

[VIM] file association script

Sep 29th, 2017
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.59 KB | None | 0 0
  1. @ECHO OFF
  2. @REM this script requires admin permissions
  3. net session >nul 2>&1
  4. IF ERRORLEVEL 1 (GOTO:ERROR_AdminPermissions)
  5.  
  6. @ECHO.
  7. @ECHO.
  8. @ECHO Beginning association script...
  9.  
  10. @REM save previous associations and filetypes
  11. @ECHO Creating a reference of existing associations...
  12. @ECHO ON
  13. assoc > "OLD_assoc.cfg"
  14. ftype > "OLD_ftype.cfg"
  15. @ECHO OFF
  16.  
  17. @REM cmdline args for desired editor
  18. SET MyEditor="C:\Programs\Vim\vim80\gvim.exe" "%%1"
  19. SET src_cmd=%MyEditor%
  20. SET txt_cmd=%MyEditor%
  21.  
  22. @REM source extensions
  23. @ECHO.
  24. @ECHO Association source file types
  25. assoc .c=srcfile
  26. assoc .cpp=srcfile
  27. assoc .cs=srcfile
  28. assoc .cxx=srcfile
  29. assoc .h=srcfile
  30. assoc .json=srcfile
  31. assoc .make=srcfile
  32. assoc .mk=srcfile
  33. assoc .php=srcfile
  34. assoc .pl=srcfile
  35. assoc .ps=srcfile
  36. assoc .py=srcfile
  37. assoc .r=srcfile
  38. assoc .rc=srcfile
  39. assoc .res=srcfile
  40. assoc .scp=srcfile
  41. assoc .scr=srcfile
  42. assoc .tup=srcfile
  43. assoc .xml=srcfile
  44. assoc .y=srcfile
  45. assoc .yxx=srcfile
  46.  
  47. @REM text extensions
  48. @ECHO.
  49. @ECHO Association text file types
  50. assoc .cfg=txtfile
  51. assoc .config=txtfile
  52. assoc .git=txtfile
  53. assoc .gitattributes=txtfile
  54. assoc .gitignore=txtfile
  55. assoc .gitmodules=txtfile
  56. assoc .inf=txtfile
  57. assoc .ini=txtfile
  58. assoc .log=txtfile
  59. assoc .settings=txtfile
  60. assoc .txt=txtfile
  61.  
  62. @REM make filetype<->cmd association
  63. @ECHO.
  64. @ECHO Associating editor with filetypes
  65. ftype srcfile=%src_cmd%
  66. ftype txtfile=%txt_cmd%
  67.  
  68. @ECHO.
  69. @ECHO.
  70. @ECHO Finished.
  71. GOTO:END
  72.  
  73. :ERROR_AdminPermissions
  74. @ECHO This script requires elevated permissions.
  75. @ECHO Please run this script in an admin shell.
  76.  
  77. :END
  78. @ECHO.
  79. @PAUSE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement