A classic question I think

Hello, i have a question about Texmacs using
I am on Windows 10, and the shortcut to delete a whole word CTRL + BACKSPACE isn’t working on the app
And I don’t know what to do, I searched a lot and didn’t find, I changed the shortcut, tried to see what Emacs is … and I didn’t find anything

Thank you for every answer

Hello there, I saw that the ctrl+backspace does work but only to delete a section’s template, and that’s not what I need

EDIT : I also want to know if there is a way to change all shortcuts, to make them like usual wysiwygs
Sorry for spamming

I will leave the answer to CTRL + BACKSPACE to someone else, but I can offer a first answer on how to change all of the shortcuts: on which “look and feel” are you?
You can check it with Edit->Preferences->Look and feel (in the Edit->Preferences menu it is on top of the General submenu). Perhaps the Look and feel you want is the “Windows” Look and feel.

There is also a more “finely-grained” way to change shortcuts (using Scheme commands) but perhaps the setting of the Look and feel will already give you what you want.

There is a mention of this conflict in Help->Configuration->Keyboard Configuration. TeXmacs reserves Ctrl for its function. I think is unwise to want to change all the shortcuts to conform to other editor setting. You might want to consider that TeXmacs behaves differently from other editors, in particular is not a character editor but a structured editor, that is editing operations sometimes works at the level of the structure of the document (which is a tree and not a linear sequence of characters). That is why shortcuts are configured differently in a somewhat ad-hoc manner. To obtain the same effect you could for example do [Option+Shift+Right arrow on Mac] to select the last word and then back space to cancel it. I’m not sure if there is a faster way (short of defining a shortcut). I do not use this much myself.

That said: if you are really sure to go in this direction, you can redefine all the keybindings as you please. Check the manual Help->Manual->Customizing TeXmacs and feel free to ask for further help.

See also
https://savannah.gnu.org/bugs/?func=detailitem&item_id=59794
The suggestion there is to use Ctrl-Shift-Left to select the word and delete it.

If there is a Scheme function behind Ctrl-Shift-Left then the behaviour of other editors can easily be emulated. I don’t know if this is the case.

Hi, thank you all for your answers
And so, first of all, I changed the Look and Feel of the program, and nothing has changed because indeed it is one of the keyboard shortcuts that conflict with the shortcuts of the app.
And to change only one shortcut, I tried but I can’t do it
I tried to add a keyboard shortcut myself, but I don’t know what to change, does it have anything to do with macros?
In fact, what is the command I should put here :
image
I tried to put kill-backward-word as found on the internet, but it doesn’t work
Thanks in advance for your answers and sorry for wasting your time for stupid things

I’ve checked and there is no such command kill-backward-word in TeXmacs (I’m not sure where you found it). I’ve also looked around in the TeXmacs/progs subdirectory and there seem to me no ready-made command to remove the last word (assuming you are in text or prog mode, because if you are in math mode is not clear what this means). One would need some time to understand how to do it properly. If you want just to look how to define new keybindings, again the help is your friend, see Help->Manual->Customizing TeXmacs. Also in this forum there have been various threads about keybindings (search for example for vi mode). The dialog you tried to use is ok, but since there is no ready-made command for what you want to accomplish, then one would have to go anyway at the Scheme level to code it.

@jeroen indeed there is a scheme function in progs/generic/generic-kbd.scm but it is tricky to readapt. I’ve made a short attempt but didn’t managed. It requires more time to understand what is going on. For people interested the relevant portion of code in that file is

    ("S-left" (kbd-select kbd-left))

which selects the last word (but does not work if Shift is not pressed). Maybe there are other scheme commands for selecting?

In fact looking in the code of the vi mode I found out go-to-previous-word, so that this code works (@Afredey: you have to put it in your my-init-texmacs.scm —an easy way to find out where that file goes is by activating Tools->Developer tool and then opening my-init-texmacs.scm from the Developer menu that appears)

(kbd-map ("C-S-left" (begin (kbd-select go-to-previous-word) (clipboard-cut "primary"))))

This assigns the sequence of actions “select the previous word” and “cut” to the key combination Ctrl-Shift-Left arrow. It worked in my tests, although I did not investigate what go-to-previous-word does n all circumstances (e.g. if the cursor is next to the end of an environment).
I also tested assigning the same commands to "C-S-b" (Ctrl-Shift-b`), but it did not work in this case, and I do not know why.

I hope this helps.

2 Likes

By the way this is not at all a time-waste, in two senses.

One is that responding is a choice, not an obligation, so whoever answers is choosing how to use their own time.
The second is that TeXmacs’ documentation can be overwhelming, so it is quite likely that people don’t find easily the way to do what they want: it takes time to learn how to control the program.

So please ask :slight_smile:

1 Like

I use the following code in my configuration file:

(kbd-map
(:mode in-text?)
; Delete by words in text
(“C-backspace” (begin (kbd-select traverse-left) (kbd-delete))))

This code does not copy to the clipboard the word you just deleted. There exists the “Ctrl-Delete” keyboard shortcut for removing the innermost tag (I use it a lot, it’s quite handy). Hence, I think you lose almost nothing by redefining this standard “Ctrl-Backspace” shortcut.

By the way, I see that on Windows many very handy structure editing shortcuts from:

http://www.texmacs.org/tmdoc/main/editing/man-structured-editing.en.html

are defined using “Meta” modifier instead of “Alt”. This is really inconvenient, especially for matrix/table editing. I’m not aware of any special meaning of these keyboard shortcuts in Windows and do not understand what was the particular reason for this decision. I also redefined them in my initialization file:

(kbd-map
(“A-left” (structured-insert-left))
(“A-right” (structured-insert-right))
(“A-up” (structured-insert-up))
(“A-down” (structured-insert-down))
)

and they work as they should. I hope this will help you to be more productive with TeXmacs on Windows.

1 Like

Thanks, @panpav, nice Scheme snippets!

On my system I had to put the kbd-map into a delayed to get it to work. I also used Ctrl+Shift+backspace, so as not to clash with the default shortcut.

(delayed (lazy-keyboard-force)
(kbd-map
(:mode in-text?)
; Delete by words in text
("C-S-backspace" (begin (kbd-select traverse-left) (kbd-delete)))))

Yes, I forgot to mention that I have (lazy-keyboard (my-keyboard) always?) command in the beginning of my-init-texmacs.scm file; all the code related to the keyboard shortcuts is placed in a different file my-keyboard.scm in the same directory as my-init-texmacs.scm.