1. 36
  1.  

  2. 8

    Although I have known about Kakoune for a while, I only recently found out that it’s licensed under Unlicense, which I find unsettling for legal reasons.

    Otherwise, I haven’t really used it much. How does it compare to vis? I have grown very fond of it for terminal editing, to the degree that I usually uninstall vim on all my machines to replace it with vis.

    1. 5

      I stopped off at vis (and sam) along the way from Vim to Kakoune. vis was fairly nice, but ultimately I found it really, really wanted you to move around and make selections with structural-regular-expressions language, and I never quite got the hang of it (quick, what’s the difference between +- and -+?)

      In contrast, Kakoune supports basically the same operations as SREs, but encourages you to move around and make selections with immediate, visual feedback — and it’s still easily scriptable, thanks to the “interactive keys are the scripting language” model the article describes.

      It’s a bit of a shame that Kakoune’s licensing civil disobedience excludes people who just want a nice text editor, but even if you can’t use Kakoune’s code I hope you (or other people) will steal its ideas and go on to make new, cool things.

      1. 6

        It’s a bit of a shame that Kakoune’s licensing civil disobedience excludes people who just want a nice text editor,

        Huh? I just looked at the UNLICENSE file; unless I’m missing something, it just drops Kakoune into the public domain. SQLite has the same thing going on.

        1. 3

          The issue is allegedly that it’s not possible to do that under every legal system. Germany seems to be an example where that could cause issues. CC0 handles this better by adding a “fallback” clause in case that it’s not possible.

          1. 4

            Legal systems are not laws of nature. If no one would ever take you to court or fine you for violating a law, that law does not apply to you. Unlicense, WTFPL, etc are great examples of this - extremely strong signals from author that they will not take any actions against you no matter what you do with the content under that license.

            1. 1

              Unlicensed, WTFPL, and even CC0 are banned by Google due to opinions by their legal team. While I don’t trust Google for a lot of things, I think it’s safe to trust their legal team thought about this and had their reasoning.

              1. 4

                But Google’s risk appetite should be pretty different than yours. The legal system hits everybody different.

                1. 1

                  What do you mean by this? Google’s legal team is going to be playing liability games in a paranoid way that is obviously irrelevant for anyone not engaged in corporate LARP.

                  Like, actually, no appeals to authority, no vague paranoia, what would actually go wrong if you used WTFPL or CC0 in Germany for a personal project?

                  1. 1

                    CC0 is fine in Germany, UNLICENSE is the problem.

                    But otherwise, you’re right. In most cases, nobody cares what license is being used (other than ideological reasons). A small hobby project might just as well have a self-contradictory license, and it wouldn’t be a practical problem. But depending on the scope of what is being done, there are always legal vultures, just like with patent trolls or people who blackmail torrent users, that might find a way to make some money from legal imperfections.

                    I’m not a legal expert, so I try not to bet on these kinds of things. If CC0 and UNLICENSE are functionally equivalent, signal the same message (“do what you want”) but one is less risky that the other, I’ll take the safer option.

          2. 2

            What does SRE stand for, in this case?

            1. 5

              “Structural regular expressions”, I’d wager?

              1. 5

                structural-regular-expressions

          3. 5

            I’ve been a vim user for about 10 years now, and I tried to switch over to Kakoune recently.

            Kakoune is absolutely delightful to use. It just feels so much better than vim. The commands are much more logical, and seem to be easier to recall.

            You can just install Kakoune, and launch it. You don’t need a few hundred lines of vimscript to be productive!

            Also the command completion and file completion functionality is amazing.

            I had to switch back to vim though, because I wasn’t feeling productive enough without some sort of :! support. I run my specs in vim with a mapping that runs rspec in the terminal, and that isn’t possible with Kakoune.

            I would still recommend any vim or other editor users try Kakoune out. You might be pleasantly surprised.

            1. 6

              For Kakoune and Vim, I typically run the editor in one terminal, and have a second terminal open to run tests in. Kakoune has a :terminal command that will launch a terminal running a specified program.

              However, if your test program spits out error messages like gcc (of the form file:line:column: message), you can set the makeprg option to run your test program, and then :make will run your program, pipe the output into a new buffer, and let you hit Enter on any error message to jump straight to the location described. It’s pretty sweet!

              If your test program doesn’t spit out error messages like gcc, well one of my first Kakoune plugins was a hack-and-slash conversion of the standard :make command to handle rustc’s output. It may not be the cleanest code in the world, but it’s pretty comfortable to use and (like the article says) writing a Kakoune plugin is pretty easy to do.

              1. 2

                For Kakoune and Vim, I typically run the editor in one terminal, and have a second terminal open to run tests in. Kakoune has a :terminal command that will launch a terminal running a specified program.

                Yes I’ve actually seen :make before and used it before in Kak. I’ve also used :make in vim, and I’ll never forget how painful errorformat is!

                With Kakoune I didn’t really like the fact that it’s not modal. As in it runs async and you carry on changing code while it’s happening. I like to run my tests and wait for (and see) the output. It seems a bit nit-picky now that I’m typing it out though.

                I may have to try Kakoune again, with an open mind.

                1. 5

                  When developing, I normally run Kakoune in IDE mode so the output of :make and :grep etc. appears in the right-hand terminal while I’m working on code in the left-hand terminal.

                  If you only had one Kakoune window, and you set both the toolsclient and jumpclient options to point at it, running :make and :grep would switch to the results of those commands so you could watch them run, and then you could switch back to he buffer you were editing.

                  I really like test-runs happening in a separate window, though. It’s always the case that I spot an error just after launching the test suite (like remembering you need to buy bread just after getting home from the shops), so it’s convenient to be able to fix it while the test suite is searching for other errors. :)

                  1. 2

                    This is interesting. Do you have to use tmux for this?

                    1. 2

                      tmux is certainly a robust way to do it, but Kakoune also supports Kitty, iTerm2 and basic X11 “run a terminal emulator and trust it will appear on screen somewhere”. I’ve worked quite happily in i3 or GNOME, and manually moving my terminals to where they need to be.

                    2. 1

                      Now that you mention it I too always spot a mistake while the tests are running! Ok this is it, I’m going back to kakoune.

                2. 3

                  You can just install Kakoune, and launch it. You don’t need a few hundred lines of vimscript to be productive!

                  wat? Are people really using hundreds of lines of vimscript? I think I have 8, and they’re all optional

                  1. 5
                    $ wc -l .vimrc .gvimrc 
                      374 .vimrc
                       36 .gvimrc
                      410 total
                    

                    And that’s not counting third-party Vim plugins.

                    To be fair, a lot of that is about tweaking the autoindent and commenting conventions for the dozens of different file-types and formatting conventions I’ve had to edit over the years. The number of lines that would have made a difference on a given day is much fewer.

                    (I still have some if v:version >= 600 blocks in there, just in case I ever fall through a timewarp to 2003 and I have to edit text with Vim 5.x again)

                    1. 3

                      I have 600 lines in my init.vim, almost all of which I wrote myself. Exobrains represent!

                      1. 1

                        what… do they do?

                        1. 4

                          Well I can’t show you all my tricks! 😛 Here’s a snippet I find really helpful:

                          " We need to do it as a normal mode injection
                          " Because %! uses the active buffer, not the local one
                          function! SetStatus(statusline)
                            exe "setlocal statusline=" . a:statusline
                          endfunction
                          
                          " visual_words_or_all
                          " Have to make global because statuslines are weird
                          function! g:Exo_vwal()
                            let s:worddict = wordcount()
                            if has_key(s:worddict, "visual_words")
                              return s:worddict["visual_words"]
                            else
                              return s:worddict["words"]
                            endif
                          endfunction
                          
                          augroup md
                            autocmd!
                            function! s:BufRead()
                              let s:sl='%<%n)\ %t\ %m' .
                                    \ '%=%1*%{g:Exo_vwal()}%*'
                              call SetStatus(s:sl)
                              if expand('%') =~? '\.talk'
                                setlocal statusline+=/%{g:Exo_vwal()/130}
                              endif
                            endfunction
                            au BufNewFile,BufRead *.md call s:BufRead()
                          augroup END
                          

                          When I’m in markdown files, it shows the wordcount in the status bar. If I have a visual selection, it shows the wordcount of the selection instead. And if it’s a talk I’m writing, then it also shows how long it’d take to speak out the selection (assuming 130 words a minute). I find it really helpful for revising and rehearsing conf talks.

                          Another snippet:

                          function! s:MdFootnote(note)
                            let s:footnote = "[^".a:note."]"
                            let @m = s:footnote
                            norm "mpmm
                            $put = s:footnote.':'
                            norm `m
                          endfunction
                          

                          Lets me add markdown footnotes and drop them onto the bottom of the file without having to break my flow.

                          1. 3

                            Program my text editor to my personal preferences and idiosyncracies?

                            • I have my own colorscheme, because I disagree with Vim about acceptable levels of color use.
                            • I highlight whitespace at the ends of lines.
                            • I disable Q.
                            • I map Enter in normal mode to insert a newline and go into edit mode.
                            • I use a plugin to teach Vim about camel-case words, and I have my own tweaks to this plugin.
                            • I make [[ navigate to the start of current/previous function, without requiring { to be at the start of the line. That’s 41 lines right there.
                            • I highlight timestamps everywhere.
                            • I used to use a plugin that shows me modified lines compared to version control in the left margin. Over time I stripped what I don’t need out of it and added new features. Outlay: 107 lines. This feature in particular I can’t imagine living without. All programming editors should unobtrusively indicate what I changed recently.

                            Sure, you could call all this “optional”. I often start with 6 lines on a new machine. But it’s also nice to have all the comforts of a yurt.

                            1. 1

                              I think I was reacting to the “to be productive” claim, and that kak somehow avoids this. Unless kak happens to have the colour scheme one wants out of the box, etc, I feel like it’s not going to be any different on this front…

                              1. 4

                                Totally agreed with that! But your original response sounded like minimalist status signalling.

                                1. 2

                                  Ah, apologies. While I do use vim mostly on the defaults, I’m not against people having configuration. I was more confused by the “vim needs 100s of lines of script to make it usable” attitude.

                                  1. 1

                                    Maybe I should have said “hundreds of lines to make it usable for me”

                              2. 1

                                I disable Q.

                                One mapping I have:

                                noremap Q @@
                                

                                So Q repeats the last macro I used.

                                1. 1

                                  Nice. I use ` for that :)

                          2. 1

                            See sensible.vim, a relatively popular 101-line file that collects “a universal set of defaults that (hopefully) everyone can agree on”. Some random examples of changes it makes to Vim’s defaults:

                            • set laststatus=2 – always show the status line, even when only one window is open
                            • set scrolloff=1 – when the cursor is near the edge of the screen, scroll to show one line beyond the cursor.
                              • It used to default to 0, but Vim 8’s defaults.vim defaults this to 5 for users who have no .vimrc, making this change less necessary.
                            • set formatoptions+=j – delete the comment character (e.g. #) when joining commented lines with J
                            • set history=1000 – increase the number of remembered : commands from 200 to 1000

                            For an example of multiple hundreds of lines of vimscript, see my well-commented personal vimrc, which has a 993-line configuration section followed by a 148-line todo list. I definitely wouldn’t say I need all those lines to be productive, though.

                            1. 0

                              Hah, well I’m sure that’s great for you, but isn’t really representative of vim users.

                              1. 1

                                Um… I’m not going to claim to have proof otherwise, but it’s representative of all vim users I know, and most I read online talk about using vim so that it “works everywhere, always present over ssh on every system, etc” which obviously breaks down if you add hundreds of lines of mods to the base…

                                1. 1

                                  My 6 lines are

                                  set nojoinspaces
                                  set ai
                                  set expandtab
                                  set tabstop=4
                                  set sw=4
                                  set showmode matchpairs=(:),{:},[:],<:>
                                  

                                  This is due to a lack of ambition. I’ve never bothered to learn the entire vim command set. I bet that laziness and lack of interest in learning the entirety of a very complex system is actually pretty common, rather than being “not representative of vim users”. Only way to know for sure, though, is an empirical study.

                                  Update: I did an empirical study. This DDG search: site:github.com inurl:vimrc dot files. Top 10 hits, line lengths of .vimrc files in various “dotfiles” repos on github: 108, 611, 8 403, 182, 54, 54, 1743, 422, 202.

                                  Interesting, and not what I predicted.

                              2. 2

                                Does :%sh { rspec... } not do this?

                                1. 2

                                  I think you mean :nop %sh{ rspec ... } to prevent Kakoune from trying to run the output of rspec as a command, and it probably still wouldn’t do the same thing since it eats the rspec output instead of letting you read it.

                                  1. 1

                                    I’m not sure what %sh does actually tbh.

                                  2. 1

                                    I gave it a try 4 years ago: https://lobste.rs/s/v17gol/switching_sublime_text_from_vim_2017/comments/7dbqc1#c_7dbqc1

                                    I’d love to learn if the story for any of these pain points has updates! Definitely lots I want to like about Kakoune.

                                  3. 4

                                    Another great post about kakoune. As an old punk myself, I cannot agree more. Even if the connection to Kakoune never came to my mind like this.

                                    Thanks.

                                    1. 2

                                      Most of these features remind me of emacs.