micro icon indicating copy to clipboard operation
micro copied to clipboard

How to Justify selected text ?

Open ghost opened this issue 1 year ago • 5 comments

What is the equivalent of Nano's ^J for justifying text in Micro ?

Screenshot_20240220-094758.png

Also Thank you very very much for creating a beautiful text editor like this. ❤️

ghost avatar Feb 20 '24 04:02 ghost

I believe it is a work for plugin (If you are about hard wrap which persist in the file). @taconi does prettier https://github.com/taconi/plugin-channel/issues/37 solves this?

If you need softwrap you can use softwrap and wordwrap options

dustdfg avatar Mar 18 '24 16:03 dustdfg

The prettier plugin uses the prettier tool and I know that it formats markdown files, maybe this plugin with some config help to solve this. The other plugin with the same name also uses prettier if the other one helps.

You can also use the manager plugin to create your own formatters:

-- ~/.config/micro/init.lua
MANAGER_FORMATTERS_ENABLED = true

formatters = {
  -- yarn global add markdownlint-cli
  { cmd = 'markdownlint --dot --fix %f', onSave = true, filetypes = { 'markdown' } },
}

taconi avatar Mar 18 '24 19:03 taconi

Seems kinda annoying that the solution is to install a plugin that depends on a tool written in node.js. I tried to write a plug-in that would do that, but could not figure how to access util.StringWidth from Lua code (which would be necessary to figure out how long a string is, because Lua's string functions don't care about UTF-8).

slashdevslashurandom avatar Apr 19 '24 17:04 slashdevslashurandom

I tried to write a plug-in that would do that, but could not figure how to access util.StringWidth from Lua code (which would be necessary to figure out how long a string is, because Lua's string functions don't care about UTF-8).

We can add exporting util.StringWidth to Lua, if needed. It should be trivial to implement.

Or perhaps you can get by with using the buffer cursor's GetVisualX() method, which uses util.StringWidth underneath?

dmaluka avatar Apr 21 '24 14:04 dmaluka

That sounds like it would be a reasonable addition in general, as, for example, anyone who would want to write a plug-in that prints or outputs a table would also want to know the width of strings of text.

slashdevslashurandom avatar Apr 22 '24 18:04 slashdevslashurandom