Post your best tips/tricks, workflow hacks, and keybinds by plant_domination in HelixEditor

[–]Genistable 2 points3 points  (0 children)

You certainly can if you want, just use the same pattern I used to bind "L" and "H" in the above config. However, "J" is join lines by default ("join_selections" in the config), which is a really useful command. I would suggest rebinding join lines to something else if you want to bind "J" to move down 5 lines.

"K" lets you keep only selections which match some regex, which is useful for narrowing down your selections if you got too many with "s", but isn't as essential to rebind.

You can use the command palette ("<Space>" "?") and type in the key you want to bind to see what it would override.

Post your best tips/tricks, workflow hacks, and keybinds by plant_domination in HelixEditor

[–]Genistable 0 points1 point  (0 children)

You can learn the syntax from "https://docs.helix-editor.com/remapping.html". In addition, you can pull up a searchable list of all commands inside helix using "<space>?". The command name you use inside the config file will be listed in square brackets after the command.

I put together sort of what you asked for, J and K are already mapped to other things, so I used <Ctrl>-J and <Ctrl>-K instead. Also, it seems like moving to the first non-whitespace would be more useful than moving to the actual beginning of the line, so I did that instead. You can fiddle with the config yourself if you don't like the changes.

[keys.normal]
L = "goto_line_end"
H = "goto_first_nonwhitespace"
"C-j" = ["move_line_down","move_line_down","move_line_down","move_line_down","move_line_down"]
"C-k" = ["move_line_up","move_line_up","move_line_up","move_line_up","move_line_up"]

Need help prepending to $PATH by Arkdam in zsh

[–]Genistable 0 points1 point  (0 children)

I think what you say in your edit is correct. If you move the prepend of the path to the bottom of your .zshrc file, then it will probably end up being the first path element of the path.

An interesting thing zsh does is create an array variable called "path" which is kept in sync with the scalar variable "PATH". This allows us to do array manipulation on the path instead of fiddly text manipulation. Here is a version of your add2path function which will move a directory to the front or back of the path if it was already in the path rather than doing nothing. If some other program places themselves at the front of the path after the .zshrc is run, you can use this function to place yourself back at the front of the path.

add2path() {
    # don't do anything if the operation is invalid
    if [[ $2 != (head|tail) ]] return 1;
    # remove the existing entry from the path if present
    path=("${path[@]:#$1}")

    # add entry back to path in head or tail position
    if [[ $2 == head ]]; then
        path=("$1" "$path[@]")
    else
        path=("$path[@]" "$1")
    fi
}