sponsor Vim development Vim logo Vim Book Ad

endline : Easily add filetype-specific line-endings.

 script karma  Rating 8/2, Downloaded by 1515  Comments, bugs, improvements  Vim wiki

created by
Thomas Allen
 
script type
utility
 
description
This plugin maps (by default) <S-CR> to add a filetype's provided "line ending"
to the end of the current line if it is not already present. For instance, a ';'
would be added to the end of a line of JavaScript source.

This is similar to a feature provided by TextMate, mapped to
Command-Option-Return in that application.

Usage:

Somewhere in your .vimrc (or equivalent), provide a global dict mapping filetype
names to line endings, like so:

let g:Endlines = {
  'erlang': '.',
  'java': ';',
  'javascript': ';',
  'ocaml': ';;',
  'perl': ';',
  'php': ';',
  'python': ':',
  'sml': ';'
\}

Mappings can also be a list of patterns that will be tried in order. In the
following example, a " ->" is appended if the line starts with no whitespace
and ends with a ")", and a "," is appended if the line ends with
non-whitespace.

let g:Endlines = {
      'erlang':     [
        \['^\S.*)$', ' ->'],
        \['\S$', ',']]
      \}

By default, <S-CR> is mapped in both insert and normal mode. In insert mode, a
new line is added as well.

Global Options:

g:EndlineMapping ('<S-CR>'): The default endline mapping.
g:EndlineInsertMapping (g:EndlineMapping): The insert mode mapping.
g:EndlineNormalMapping (g:EndlineMapping): The normal mode mapping.
g:EndlineInsert (1): 0 to disable the insert mode mapping.
g:EndlineNormal (1): 0 to disable the normal mode mapping.
g:Endlines ({}): See "Usage"
 
install details
1. Extract the downloaded endline.zip file
2. Copy endline/doc/endline.txt to .vim/doc/endline.txt
3. Copy endline/plugin/endline.vim to .vim/plugin/endline.vim
4. Run :helptags ~/.vim/doc to load the documentation
5. Map your filetype line-endings (see "Usage" above, or :h Endline-usage)
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
endline.zip 0.2.0 2015-06-16 7.0 Thomas Allen Added support for pattern-specific line endings.
endline.zip 0.1.1 2015-06-16 7.0 Thomas Allen Fix bad global function definition.
endline.tgz 0.1 2010-07-22 7.0 Thomas Allen Initial upload
ip used for rating: 216.73.216.130

Questions about Vim should go to the maillist. Help Uganda.     Vim at Github