Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit.

  • Loading branch information...
commit 7e2ae760f768fde87ceb08105643db4fe3063c4b 0 parents
@Soares authored
Showing with 157 additions and 0 deletions.
  1. +10 −0 README.md
  2. +77 −0 doc/longline.txt
  3. +70 −0 plugin/longline.vim
10 README.md
@@ -0,0 +1,10 @@
+# LongLine
+# Avoid long lines
+
+LongLine helps you with long lines in vim.
+
+* Highlight lines that are too long.
+* Vary the definition of "too long" by file type.
+* Provide easy hooks for your `statusline` to know if long lines exist.
+
+See the help documentation for details.
77 doc/longline.txt
@@ -0,0 +1,77 @@
+*longline.txt* Avoid Long Lines.
+*longline* *LongLine*
+
+Author: Nate Soares <http://so8r.es/>
+License: Same terms as Vim itself (see |license|)
+
+=============================================================================
+CONTENTS *longline-contents*
+ 1. Intro........................................|longline-intro|
+ 2. Options......................................|longline-options|
+ 3. Commands.....................................|longline-commands|
+ 4. Functions....................................|longline-functions|
+ 6. About........................................|longline-about|
+
+=============================================================================
+INTRODUCTION *longline-intro*
+
+Vim buffer utilities. Light your buffers up.
+
+=============================================================================
+OPTIONS *longline-options*
+
+ *longline-matchgroup*
+g:longline_matchgroup The matchgroup to highlight the long parts of lines
+ with. {ErrorMsg} by default.
+
+ *longline-maxlength*
+g:longline_maxlength The length that is too long. 80 by default.
+
+ *longline-filetype_map*
+g:longline_filetype_map A dictionary of filetypes
+
+=============================================================================
+COMMANDS *longline-commands*
+
+ *longline-:LongLine*
+:LongLine Toggles the highlighting on long lines.
+
+=============================================================================
+FUNCTIONS *longline-functions*
+
+ *longline-MaxLength*
+longline#MaxLength() The maximum length of a line. Takes one optional
+ parameter specifying the line length. A negative value
+ signals that no line is too long, a positive value
+ signals that the defaults should be used. If the
+ defaults should be used or the parameter is ommitted
+ then the longline_filetype_map and longline_maxlength
+ will be used.
+
+ *longline-Show*
+longline#MaxLength() The maximum length of a line. Takes one optional
+
+longline#Show() Highlight parts of lines that are too long.
+ Long lines are not highlighted by default. To
+ highlight long lines by default you'll want a command
+ like the following >
+ augroup longlines
+ autocmd BufEnter * :LongLine
+ augroup end
+
+<
+
+ *longline-Hide*
+longline#Hide() Stop highlighting long parts of lines.
+
+ *longline-Toggle*
+longline#Toggle() Toggle highlighting on long parts of lines.
+
+=============================================================================
+ABOUT *longline-about*
+
+Grab the latest version or report a bug on GitHub:
+
+http://github.com/Soares/longline.vim
+
+ vim:tw=78:ts=8:noet:ft=help:norl:
70 plugin/longline.vim
@@ -0,0 +1,70 @@
+if !exists('g:longline_matchgroup')
+ let g:longline_matchgroup = 'ErrorMsg'
+endif
+
+if !exists('g:longline_maxlength')
+ let g:longline_maxlength = 80
+endif
+
+if !exists('g:longline_filetype_map')
+ let g:longline_filetype_map = {
+ \ 'java': 100,
+ \ 'html': -1,
+ \ 'soy': -1,
+ \ 'text': -1,
+ \ 'markdown': -1,
+ \ 'help': -1,
+ \}
+endif
+
+
+function! s:LineMatch(type, num)
+ " Highlight lines of a certain length with a certain highlight group.
+ exe "match ".a:type." '\\%>".a:num."v.\\+'"
+endfunction
+
+
+function! longline#MaxLength()
+ let num = a:0 > 0 ? a:1 : 0
+ if num == 0 | let num = get(g:longline_filetype_map, &ft) | endif
+ if num == 0 | let num = g:longline_maxlength | endif
+ if num < 1 | return -1 | endif
+ return num
+endfunction
+
+function! longline#Show()
+ " Highlight lines of or beyond a certain length.
+ call longline#Hide()
+ let num = call('longline#MaxLength', a:000)
+ if num > 0
+ call s:LineMatch(g:longline_matchgroup, num)
+ let b:longline_highlighted = num
+ endif
+endfunction
+
+function! longline#Exists()
+ " True iff. a line exists that is too long.
+ let num = call('longline#MaxLength', a:000)
+ if num < 1 | return 0 | endif
+ return search('\%>'.num.'v.', 'nw') != 0
+endfunction
+
+function! longline#Hide()
+ " Remove the highlighting on long lines.
+ if exists('b:longline_highlighted')
+ if b:longline_highlighted > 0
+ call s:LineMatch('NONE', b:longline_highlighted)
+ endif
+ unlet b:longline_highlighted
+ endif
+endfunction
+
+function! longline#Toggle()
+ " Toggle long line highlighting
+ if exists('b:longline_highlighted') && b:longline_highlighted > 0
+ call longline#Hide()
+ else
+ call call('longline#Show', a:000)
+ endif
+endfunction
+command! LongLines call longline#Toggle()
Please sign in to comment.
Something went wrong with that request. Please try again.