@prevent_invalid_dir
    def open(self, path=None, first_line=None, query=None): #{{{2
        """
        Creates or opens a note.
        """
        if not path:
            path = join(get_save_dir(),
                        PadInfo([first_line]).id + get_setting("default_file_extension"))
        path = path.replace(" ", "\ ")

        def split_for_pad():
            if get_setting('position["pads"]') == 'right':
                V + ("silent! rightbelow" + get_setting("window_width") + "vsplit " + path)
            else:
                V + ("silent! botright" + get_setting("window_height") + "split " + path)

        if get_setting("open_in_split", bool):
            split_for_pad()
        else:
            awa = int(vim.eval("&autowriteall"))
            if bool(int(vim.eval("&modified"))):
                reply = vim.eval('input("vim-pad: the current file has unsaved changes. " \
                        "do you want to save? [Yn] ", "y")')
                if reply == "y":
                    V + "set autowriteall"
                    V + ("silent! edit " + path)
                    if awa == 0:
                        V + "set noautowriteall"
                else:
                    V + 'echom "vim-pad: will have to open pad in a split"'
                    split_for_pad()
                V + "redraw!"
            else:
                V + ("silent! edit " + path)

        # we don't keep the buffer when we hide it
        V + "set bufhidden=wipe"

        # load notes functionality
        if ('', 'conf') in vim.eval('&filetype'):
            V + "set filetype=pad-notes"
        else:
            V + "runtime! ftplugin/pad-notes/*.vim"

        # reset set the filetype to our default if the pad-notes filetype is set
        if vim.eval('&filetype') == 'pad-notes':
            V + ("set filetype=" + get_setting("default_format"))

        # insert the text in first_line to the buffer, if provided
        if first_line:
            vim.current.buffer.append(first_line, 0)
            V + "normal! j"

        # highlight query and jump to it?
        if query not in ('', None):
            if get_setting('highlight_query') == '1':
                V + ("call matchadd('PadQuery', '\c" + query + "')")
            if get_setting('jumpto_query') == '1':
                V + ("call search('\c" + query + "')")
dataset/ETHPy150Open fmoralesc/vim-pad/pythonx/pad/plugin.py/PadPlugin.open/swapped operands of `in`