zshrc.d/30-functions-vim.zrc
author Mikael Berthe <mikael@lilotux.net>
Fri, 10 Jul 2020 09:42:03 +0200
changeset 45 c8b92fa96f48
parent 28 aa674a9c97c2
child 56 d065bc0c6991
permissions -rw-r--r--
Update key bindings Fix some key bindings, remove binary escape bytes from key bindings.


# Change "viml file:n" to "vim file +n"
# Based on http://www.zsh.org/mla/users/2011/msg00333.html
#
function viml() {
    [[ "$#" != 1 || -r "$1" ]] && {
        vim "$@"
        return $?
    }

    local args
    args=(${(s.:.)1})
    [[ "$#args" -ge 2 && "$args[2]" == <-> ]] && \
        command vim "$args[1]" "+$args[2]"    || \
        command vim "$args[1]"
}