Giter Club home page Giter Club logo

preservenoeol's Introduction

This is a mirror of http://www.vim.org/scripts/script.php?script_id=4550

DESCRIPTION
This plugin causes Vim to omit the final newline (<EOL>) at the end of a
text file when you save it, if it was missing when the file was read. If the
file was read with <EOL> at the end, it will be saved with one. If it was read
without one, it will be saved without one.

Some (arguably broken) Windows applications (also several text editors) create
files without a final <EOL>, so if you have to interoperate with those, or
want to keep your commits to revision control clean of those changes, this
plugin is for you.

This works for all three line ending styles which Vim recognizes: DOS
(Windows), Unix, and traditional Mac. Multiple strategies are implemented to
handle these cases, so you can choose the one that fits you best.

HOW IT WORKS
Except for the internal Vimscript implementation, all other strategies first
let Vim save the file as usual (with a final <EOL>), and then post-process (on
BufWritePost) the file contents, using file-system API functions to truncate
the final <EOL>.

RELATED WORKS
The pure Vimscript implementation is based on the following VimTip:
    http://vim.wikia.com/wiki/Preserve_missing_end-of-line_at_end_of_text_files

USAGE
If you always want to preserve a misssing <EOL> in text files, just put
    :let g:PreserveNoEOL = 1
into your vimrc and you're done. If you need more fine-grained control or
want to just turn this on in particular situations, you can use the following
commands or the buffer-local flag b:PreserveNoEOL.

:PreserveNoEOL          For the current buffer, the 'noeol' setting will be
                        preserved on writes. (Normally, Vim only does this for
                        'binary' files.) This has the same effect as setting
                        the marker buffer variable:
                            let b:PreserveNoEOL = 1

:SetNoEOL               When writing the current buffer, do not append an
                        <EOL> at the end of the last line, even when there
                        used to be one. Same as
                            setlocal noeol | let b:PreserveNoEOL = 1

preservenoeol's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.