Repository navigation
|
For years I have had a key binding to insert #!/usr/bin/env xxx at the top of a file, and then restore my position. FYI: hx is the binary in my PATH, for the helix editor This I have tried: [keys.normal] I get all kinds of errors. Can anyone help? Thanks. |
Replies: 1 comment 4 replies
|
Two things are going on in your attempt:
You don't need the clipboard at all. [keys.normal]
"C-S-p" = [
"save_selection",
"goto_file_start",
"extend_to_line_bounds",
":insert-output echo '#!/usr/bin/env python'",
"collapse_selection",
"jump_backward",
]Why
One caveat: whether |
Glad the approach fits! Could you paste the exact error (and
hx --version)? My guess is the shell part: on Helix older than 25.01, the old argument parser drops the quotes around'#!/usr/bin/env python', soshsees#as the start of a comment and things break.Here's a version that avoids the shell entirely. It's a macro keybinding (Helix 25.01+), which replays plain keys:
Step by step:
<C-s>saves the selection to the jumplist,gggoes to the file start,Oopens a line above, the shebang is typed in,<esc>returns to normal mode, and<C-o>jumps back to where you were.(Macro bindings can't be mixed into a
[...]com…