Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Justify selected text ? #3147

Open
ghost opened this issue Feb 20, 2024 · 5 comments
Open

How to Justify selected text ? #3147

ghost opened this issue Feb 20, 2024 · 5 comments

Comments

@ghost
Copy link

ghost commented Feb 20, 2024

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. ❤️

@dustdfg
Copy link
Contributor

dustdfg commented Mar 18, 2024

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

If you need softwrap you can use softwrap and wordwrap options

@taconi
Copy link
Contributor

taconi commented Mar 18, 2024

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' } },
}

@slashdevslashurandom
Copy link

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).

@dmaluka
Copy link
Collaborator

dmaluka commented Apr 21, 2024

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?

@slashdevslashurandom
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants