Re: Local-to-dir mcedit prefs or quick profiles?



On 2/20/17, wwp <subscript free fr> wrote:
I'm using mcedit to edit sources in many projects, some of them have
coding conventions that require [...] and some require [...]

What feature or best practice would you suggest in order to quickly
switch mcedit settings (general editor options) according to the file
location?

You can use mc^2 with a simple snippet like this:

    ui.Editbox.bind("<<load>>", function(edt)

      if edt.filename and edt.filename:find "/projects/lambda/" then
        ui.Editbox.options.tab_size = 4
        ui.Editbox.options.expand_tabs = true
      else
        ui.Editbox.options.tab_size = 8
        ui.Editbox.options.expand_tabs = false
      end

    end)

(For documentation, see [1])

(The 'else' case is needed because in MC the editor options are
global, not local to each edit buffer.)

mc^2 also comes with a modeline module (if you decide to use it just
remember to require() it before the snippet above so it doesn't
overwrite your settings).

[1] http://www.typo.co.il/~mooffie/mc-lua/docs/html/classes/ui.Editbox.html#ui.Editbox.options


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]