yi-core-0.19.2: Yi editor core library

Yi.File

Description

Synopsis

# File-based actions

If file exists, read contents of file into a new buffer, otherwise creating a new empty buffer. Replace the current window with a new window onto the new buffer.

If the file is already open, just switch to the corresponding buffer.

Need to clean up semantics for when buffers exist, and how to attach windows to buffers.

Yi.File module re-exports this, you probably want to import that instead.

In case of a decoding failure, failure message is returned instead of the BufferRef.

openingNewFile :: FilePath -> BufferM a -> YiM () Source #

Tries to open a new buffer with editFile and runs the given action on the buffer handle if it succeeds.

If the editFile fails, just the failure message is printed.

Same as openingNewFile with no action to run after.

Try to write a file in the manner of vi/vim Need to catch any exception to avoid losing bindings

viWriteTo :: Text -> YiM () Source #

Try to write to a named file in the manner of vi/vim

Try to write to a named file if it doesn't exist. Error out if it does.

Write current buffer to disk, if this buffer is associated with a file

Write a given buffer to disk if it is associated with a file.

Write all open buffers

Write current buffer to disk as f. The file is also set to f.

Make a backup copy of file

Revert to the contents of the file on disk

# Helper functions

Associate buffer with file; canonicalize the given path name.

Checks if the given buffer deserves a save: whether it's a file buffer and whether it's pointing at a file rather than a directory.