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

Noob questions #419

Closed
janwirth opened this issue Oct 3, 2015 · 19 comments
Closed

Noob questions #419

janwirth opened this issue Oct 3, 2015 · 19 comments

Comments

@janwirth
Copy link
Contributor

janwirth commented Oct 3, 2015

Hey,
it's me again. Just getting started using this for my projects. But still have a few questions.

  • how do i enable line-wrapping/use autowrap?
  • what is '-draft' and how do I use it?
  • is there a central place for documentation that one could query?
  • are there any guides on writing a syntax highlighter?

Maybe an FAQ section inside the wiki would make sense to provide a quick entry for nubs. This could later be used to write a documentation that is more end-user focused.

@mawww
Copy link
Owner

mawww commented Oct 3, 2015

Hello,

  • autowrapping is provided by the autowrap.kak script (which should be loaded by default), enable it for a buffer with the autowrap-enable command, that you probably want to put in a hook (for example if you want to always enable autowrap, add hook global WinCreate .* %{ autowrap-enable } in your kakrc. the autowrap_column option controls the column on which to autowrap.
  • -draft is a switch given to :exec and :eval commands, which tells them to run in a copy of the current context, so that the original state is preserved. Thats useful for scripts that dont want to modify user selections.
  • the README file is the centralized documentation (for now)
  • there is a syntax highlighting section in the README file, along with reading an existing highlighter that should give you a good idea of how highlighting works.

The wiki is world writable, so do not hesitate to add information you found useful in it. I tend to be a little too familiar with Kakoune to see whats missing there.

@janwirth
Copy link
Contributor Author

janwirth commented Oct 3, 2015

Okey, so

  • I dug into this already and it seems to be not working, on any of my terminal emulators. I am running el capitan beta, but whatever, you know this better than me. it's a gif!
    https://gyazo.com/9f645053190e294718494169a484f2e4
  • draft is for creating a preprocessed version of your actual buffer, that is being replaced on defined hooks, right? So you can process your code programmatically, for example line wrapping by inserting a \n at the nth character?
    I will dig into the readme and wiki. Maybe a platform for everything kakoune would popularize this piece of software a little more. I really like it.

@mawww
Copy link
Owner

mawww commented Oct 3, 2015

  • autowrap-enable will enable as you type wrapping, there is not "display only" line wrapping implemented (yet)
  • draft execute in a "draft" context, which is a copy of the client context. Among other things, the current list of selections is stored in the context, so by working on a copy of the client context, we can avoid touching modifying user selections. An example would be to comment current line, you could use exec I//<space><esc> however that will change the current user selection (as if he typed the keys himself). If you do exec -draft I//<space><esc> then the keys are executed in a copy, the buffer is still modified, but the user selections will be preserved.

@lenormf
Copy link
Contributor

lenormf commented Oct 4, 2015

Hi @FranzSkuffka, I'm going to expand on @maww's explanation of the autowrap thing.

If you want to wrap lines as you type them, then :autowrap-enable will do just that (however, it will not automatically reformat the entire paragraph if you add words in the middle of a line). If you want to be able to format a particular bit of text, you can select it and use :autowrap-selection, it will break lines that contain more than autowrap_column characters (you don't need to enable autowrapping to use this function).

Unlike with other editors, kakoune's autowrapping current implementation is a passive one: it will just make sure that the text/selection you feed it fit in autowrap_column columns, and insert newline characters if needs be. What it will not do (as of today) is ensure that your entire buffer is correctly formatted, you can use standard tools like fmt if that's what you want.

@janwirth
Copy link
Contributor Author

janwirth commented Oct 5, 2015

Wow, thanks for this explanation. I will just dump this into the wiki i guess. Have now idea about how to use fmt with kakoune! Can you point me someplace to get started?

@janwirth
Copy link
Contributor Author

janwirth commented Oct 5, 2015

More pressing: I read the section about registers: Is it possible to yank to the system register? I have two tmux panes open and would like to copy from one kak to another.

@alexherbo2
Copy link
Contributor

Yes. Using a system clipboard tool such xsel.

To yank: <a-|> xsel --input --clipboard <ret>

To paste: ! xsel --output --clipboard <ret>

@mawww
Copy link
Owner

mawww commented Oct 5, 2015

If your kak panes are from the same session (either created through :new or explicitly by running in client mode kak -c <session>), registers are shared, so copy paste should work directly, without needing to use the system clipboard.

@janwirth
Copy link
Contributor Author

janwirth commented Oct 5, 2015

When I used autowrap-section on a paragraph and wrote it, it wrote the linebreaks to the file too. Is this intended? I expected kak to write the original buffer and not the draft. Or is autowrap not operating in draft mode?

On OSX, the alt-key does not seem to work.

@mawww
Copy link
Owner

mawww commented Oct 5, 2015

Hum, seems there is a misunderstanding here, autowrap is not a display thing, it does modify the buffer, draft context dont prevent buffer modification, they prevent user selections/current mode from being modified (a draft context is the similar to what happens when you use two clients on the same buffer, try to do :new and then do some modifications in one client, you'll see the other client buffer change, but its selections wont change (they will just adapt to relevant buffer changes)).

line wrapping as a display only thing is not implemented (yet) in kakoune.

@janwirth
Copy link
Contributor Author

janwirth commented Oct 5, 2015

so what about a layer that does exactly this? like that, we could greatly extend kakoune!
apart from that, one thing that bothered me about vim is having to make movements blindly. here it is the same, but with creating the selections. I find it hard to count lines/words for making movements/selections like 7x or 5w. Is there any trick behind this? Or do you just have to get used to it?

@mawww
Copy link
Owner

mawww commented Oct 5, 2015

A special highlighter function could handle line wrapping, however up to now there have always been a 1:1 relation between displayed line and buffer line, and I expect some code to be broken if this assertion does not hold anymore.

Regarding selections, as Kakoune displays them, you should not have to count, you can just do 5 hit on W to add 5 words in the selection (just stop when you see the selection is good), or 5 hits on w to select the 5th word from current cursor (similarly, just stop when the word selected it the one you want).

@lenormf
Copy link
Contributor

lenormf commented Oct 6, 2015

@FranzSkuffka

Have now idea about how to use fmt with kakoune! Can you point me someplace to get started?

Sure, make a selection (% to select the entire buffer), then hit the | key (it will replace the current selection by the output of the selection piped to a given command), type in fmt --width=72 and your entire selection will be wrapped to 72 columns. The fmt command does more than just raw wrapping, read the manpage to use the flags that fit your usecase.

@janwirth
Copy link
Contributor Author

janwirth commented Oct 7, 2015

I'm sure things will fall into place! I can use this elegant piece of software productively now. Thank you for your patience and support. Will contribute when I see an Opportunity.

@janwirth janwirth closed this as completed Oct 7, 2015
@janwirth
Copy link
Contributor Author

janwirth commented Oct 7, 2015

How can I recover a session?
When writing my project thesis today I think I closed my tab accidentally. How do I recover this session?

@janwirth janwirth reopened this Oct 7, 2015
@alexherbo2
Copy link
Contributor

It’s lost I think. :/

Kakoune server does not keep running if there is no connected client, unless the -d (daemon mode) switch is specified at command-line.

A solution is to use the daemon mode from Kakoune or a program with the detach functionality like tmux or dtach.

@mawww
Copy link
Owner

mawww commented Oct 8, 2015

If kakoune crashed, then you will have some recovery files generated, looking at the code however, I am afraid Kakoune currently considers a SIGHUP (which is what it will get if you close you terminal) as a graceful quit, and hence wont try to backup modified files. That should be changed, If Kakoune quits due to SIGHUP, it definitely should write backup files for every unsaved buffer.

In your case, I am afraid you lost the unsaved work.

@mawww
Copy link
Owner

mawww commented Oct 8, 2015

Added support for detecting that case, backup files should now be generated on SIGHUP, and the autorestore.kak script should kick in, directly reloading the backup version next time you open the file.

@mawww mawww closed this as completed Oct 8, 2015
@janwirth
Copy link
Contributor Author

janwirth commented Oct 9, 2015

after looking twice, I realised there was some kind fo backup file which i just could open using kak.
So no data lost. Don't know how I got there.

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