How to edit with kakoune without buffer tab and windows?

i know some plugin and buffer-next,-previous,But how do you edit in a situation where you can only open one buffer? Please let me know your usecase!

open a new client in a terminal. from kakoune you can type
:new
and it will automatically open a new client connected to your session. Then you can switch buffers etc
you can also do this manually: kak -c the-id-of-your-session which you can see in your kakoune window bottom left, it looks like client0@[437476] and that number is your session

I think kak defaults to xterm, so you may need to set your termcmd variable

1 Like

Yeah, I’m not sure exactly what you’re asking.

If I just have one terminal window, I start Kakoune with one file I want to edit, and if I want to edit a different file I just open it with :edit which supports tab-completion, so it’s pretty easy to swap among files.

If I really need to see files open side-by-side, the :new command will open a new terminal running Kakoune, connected to the same session so they share the same set of open files, the same configuration values, etc.

I was wondering how you are editing.
For example: example.cpp,example.h, etc… in project directories
kakoune can only open one buffer,
hyper+enter(new terminal window) with i3/sway
then cd projectkak example.cpp
hyper+enter(new terminal window) with i3/sway
then cd projectkak example.h
It is stupid to open a directory in tmux or i3/sway and type kak anything every time you want to edit multiple files like this!
The question is how edit with kakoune without file explorer or split window and tab functionality

You can also run kak example.cpp example.h to open multiple files at once.

Once Kakoune is running, you can open even more files by typing :edit path/to/file (and it has tab completion, too).

When Kakoune has multiple files open, you can switch between them with:

  • :buffer-next and :buffer-previous commands (or :bn and :bp for short)
  • :buffer and then typing the name of the buffer you want to switch to (again with tab completion, so it’s faster than cycling through open buffers with :bn)
  • :edit and then typing the filename you want to edit - if it’s already open Kakoune will switch to it, otherwise Kakoune will open it in a new buffer. This way you don’t have to care whether the file is already open or not.

As mentioned previously, :new will give you a split window - not a split inside the existing Kakoune window, but a separate window that you can make i3/sway arrange beside the original. If you switch your i3 frame to “tab” mode, now you have tabs.

thx but i have 1 more question
why cant kak directory?

Kakoune is a text editor, not a directory editor.

Some text editors (hello, Vim!) notice when you try to edit a directory and instead open a buffer that lists all the files in that directory and provides some editor-like UI for manipulating them. That’s nice, but it sort of blurs the distinction between the buffer being the thing you edit, and the user-interface you use for editing.

Kakoune prefers to keep the buffer and the user-interface separate. So, the buffer is always text you can edit, and the user-interface is available with :-commands and completion menus. The completion menu that appears when you type :edit isn’t exactly like a file browser, but it performs a lot of the same functions and it fits much better with the rest of Kakoune.

Does this mean that I need to do :cd project then :e README.md and :e example.cpp ?

Yes, that works!

If you want something a little more telescope-esque, I have this mapping in my configuration file for fuzzy file finding:
map global goto f '<esc>:prompt -shell-script-candidates %{ fd --type f --hidden } file: %{ edit %val{text} }<ret>' -docstring "file"
And I have this for navigating between open buffers:
map global goto "b" '<esc>:prompt -buffer-completion buffer: %{ buffer %val{text} }<ret>' -docstring "buffer"

I have another snippet that creates a pop-up terminal with nnn for my file browsing needs, but it’s a bit more complex to set up.

1 Like