is it possible to set tab width and indentation for different file types
individually? For example:

ini, dat, txt - 0
js, java - 2
css, html, xml - 4
haskell, python - 8

Yes, it is possible. I am using following lua code for this purpose. Put it into your SciTEStartup.lua. It is bit long, but quite universal.

lexers = {
  [1] = "null",
  [2] = "python",
  [3] = "cpp",
  [4] = "hypertext",
  [5] = "xml",
  [6] = "perl",
  [7] = "sql",
  [8] = "vb",
  [9] = "props",
  [10] = "errorlist",
  [11] = "makefile",
  [12] = "batch",
  [14] = "latex",
  [15] = "lua",
  [16] = "diff",
  [17] = "conf",
  [18] = "pascal",
  [19] = "ave",
  [20] = "ada",
  [21] = "lisp",
  [22] = "ruby",
  [23] = "eiffel",
  [24] = "eiffelkw",
  [25] = "tcl",
  [26] = "nncrontab",
  [27] = "bullant",
  [28] = "vbscript",
  [29] = "asp",
  [30] = "php",
  [31] = "baan",
  [32] = "matlab",
  [33] = "scriptol",
  [34] = "asm",
  [35] = "cppnocase",
  [36] = "fortran",
  [37] = "f77",
  [38] = "css",
  [39] = "pov",
  [40] = "lout",
  [41] = "escript",
  [42] = "ps",
  [43] = "nsis",
  [44] = "mmixal",
  [45] = "clarion",
  [46] = "clarionnocase",
  [47] = "lot",
  [48] = "yaml",
  [49] = "tex",
  [50] = "metapost",
  [51] = "powerbasic",
  [52] = "forth",
  [54] = "octave",
  [55] = "mssql",
  [56] = "verilog",
  [57] = "kix",
  [58] = "gui4cli",
  [59] = "specman",
  [60] = "au3",
  [61] = "apdl",
  [62] = "bash",
  [63] = "asn1",
  [64] = "vhdl",
  [65] = "caml",
  [66] = "blitzbasic",
  [67] = "purebasic",
  [68] = "haskell",
  [69] = "phpscript",
  [70] = "tads3",
  [71] = "rebol",
  [72] = "smalltalk",
  [73] = "flagship",
  [74] = "csound",
  [75] = "freebasic",
}

function setup_tabs()
  lexer = editor.Lexer
  if lexers[lexer] then
    if props["tabsize." .. lexers[lexer]]~="" then
      editor.TabWidth = props["tabsize." .. lexers[lexer]]
    else
      editor.TabWidth = props["tabsize"]
    end
    if props["indent.size." .. lexers[lexer]]~="" then
      editor.Indent   = props["indent.size." .. lexers[lexer]]
    else
      editor.Indent   = props["indent.size"]
    end
    if props["use.tabs." .. lexers[lexer]]~="" then
      editor.UseTabs  = props["use.tabs." .. lexers[lexer]] == 1
    else
      editor.UseTabs  = props["use.tabs"]
    end
    if props["find.files." .. lexers[lexer]]~="" then
      props["find.files"] = props["find.files." .. lexers[lexer]]
    end
  end
end

function OnOpen()
  setup_tabs()
end

function OnSwitchFile()
  setup_tabs()
end

-------------------- cut

As you can see from code, it changes properties use.tabs, indent.size and tabsize according to current lexer. Then you can set your preference simply in SciTEUser.properties:

tabsize.cpp=4
indent.size.cpp=4
use.tabs.cpp=0

tabsize.lua=2
indent.size.lua=2
use.tabs.lua=0

-- Roman

_______________________________________________
Scite-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scite-interest

Reply via email to