<commit_before># Vim aliases

_vim() {
    # FIXME: Only proceed to open files that exist or were created. (e.g. $ v foo File "foo.txt" doesn't exist. Create
    # file? n The file /path/to/foo.txt does not exist.)
    for filename in "${@}"; do
        # Not (exists and is a directory).
        if [[ ! -d "${filename}" ]]; then
            # Not (file exists).
            if [[ ! -e "${filename}" ]]; then
                read -p "File \"${filename}\" doesn't exist. Create file? " -n 1 -r
                echo
                if [[ $REPLY =~ ^[Yy]$ ]]; then
                    touch "${filename}"
                fi
            fi
        fi
    done

    if is_ssh; then
        \vim -p "$@"
    elif which "mvim" &> /dev/null; then
        if [[ $# -eq 0 ]]; then
            mvim
        else
            mvim --remote-tab-silent "$@"
        fi
    elif which "gvim" &> /dev/null; then
        xdotool=$(which xdotool)
        if [ -z "${xdotool}" ]; then
            echo -e '\x1b[0;93mWARNING\x1b[0m: xdotool does not seem to be installed.'
        else
          window_id=$(xdotool search --name ") - GVIM")
          if [ ! -z "${window_id}" ]; then
            xdotool windowactivate "${window_id}"
          fi
        fi

        (gvim -f -p --remote-tab-silent "$@" &> /dev/null &)
    else
        \vim -p "$@"
    fi
}

alias v="_vim"
alias vi="_vim"
alias vim="_vim"

alias vimrc="_vim ~/.vimrc"

# Use vi-style command line editing.
set -o vi
<commit_msg>Fix path quoting by using separate variable for list of files<commit_after># Vim aliases

_vim() {
    # FIXME: Only proceed to open files that exist or were created. (e.g. $ v foo File "foo.txt" doesn't exist. Create
    # file? n The file /path/to/foo.txt does not exist.)
    files="${@}"
    for filename in "${files}"; do
        # Not (exists and is a directory).
        if [[ ! -d "${filename}" ]]; then
            # Not (file exists).
            if [[ ! -e "${filename}" ]]; then
                read -p "File \"${filename}\" doesn't exist. Create file? " -n 1 -r
                echo
                if [[ $REPLY =~ ^[Yy]$ ]]; then
                    touch "${filename}"
                fi
            fi
        fi
    done

    if is_ssh; then
        \vim -p "${files}"
    elif which "mvim" &> /dev/null; then
        if [[ $# -eq 0 ]]; then
            mvim
        else
            mvim --remote-tab-silent "${files}"
        fi
    elif which "gvim" &> /dev/null; then
        xdotool=$(which xdotool)
        if [ -z "${xdotool}" ]; then
            echo -e '\x1b[0;93mWARNING\x1b[0m: xdotool does not seem to be installed.'
        else
          window_id=$(xdotool search --name ") - GVIM")
          if [ ! -z "${window_id}" ]; then
            xdotool windowactivate "${window_id}"
          fi
        fi

        (gvim -f -p --remote-tab-silent "${files}" &> /dev/null &)
    else
        \vim -p "${files}"
    fi
}

alias v="_vim"
alias vi="_vim"
alias vim="_vim"

alias vimrc="_vim ~/.vimrc"

# Use vi-style command line editing.
set -o vi

{'fraction_non_alphanumeric': 0.15152509019350607, 'fraction_numerical': 0.005247622171203673, 'mean_word_length': 1.5501672240802675, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4844495', 'n_tokens_mistral': 1030, 'n_tokens_neox': 976, 'n_words': 324}