oni icon indicating copy to clipboard operation
oni copied to clipboard

Option To Toggle Line Wrapping

Open xeaone opened this issue 8 years ago • 4 comments

Oni Version: 0.3.6 Neovim Version (Linux only): 0.3.0 Operating System: Arch Linux

Issue: Is there away to toggle line wrapping? If not can I make this a feature request?

Expected behavior: Edit config file to disable line wrapping.

Actual behavior: Lines wrap correctly.

Steps to reproduce: Open a file with a line of characters that would go beyond the window.

P.S. This is an awesome project thank you for all your work. I am looking forward to supporting it in some capacity.

xeaone avatar Jul 06 '18 04:07 xeaone

Hello and welcome to the Oni repository! Thanks for opening your first issue here. To help us out, please make sure to include as much detail as possible - including screenshots and logs, if possible.

oni-bot avatar Jul 06 '18 04:07 oni-bot

Hey!

Did you want a way to toggle it live (ie a button that turns it on/off), or a config option for it?

If its a config option, you can set Neovim config options using "vim.setting. followed by the config name. In this case it would be:

    "vim.setting.wrap": false,

This is equivalent to calling :set nowrap in the commandline, or putting it in a neovim config.

If you wanted a toggle (that is a keybind to turn it on/off) you could use something like this in your config file:

export const activate = (oni: Oni.Plugin.Api) => {
    console.log("Config activated.")

    async function toggleWrap(oni: Oni.Plugin.Api) {
        const currentState = await oni.editors.activeEditor.neovim.eval("&wrap")

        if (currentState === 0) {
            oni.editors.activeEditor.neovim.command("set wrap")
        } else if (currentState === 1) {
            oni.editors.activeEditor.neovim.command("set nowrap")
        }
    }

    oni.input.bind("<s-c-x>", () => toggleWrap(oni))

Hope one of those helps!

CrossR avatar Jul 06 '18 10:07 CrossR

If you load your Neovim config in Oni ("oni.loadInitVim": true), you can just set this option/keybinding in your init.vim. Here's what I use:

" do not wrap long lines
set nowrap

" toggle line wrapping
nmap <F10> :set wrap! linebreak!<CR>

(Please make sure to read the doc about the loadInitVim option, as there could be conflicts with the default configuration ;) )

ybc37 avatar Jul 06 '18 11:07 ybc37

Thank you @CrossR. Yes I was looking for the config option. But the button is a cool idea to have also.

xeaone avatar Jul 06 '18 16:07 xeaone