Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Automatically remove empty list items on Enter

  • Loading branch information...
commit b5f4f6e0f9f691050471b7ec378a511894eed6b8 1 parent 1b928a1
@xolox authored
View
10 autoload/xolox/notes.vim
@@ -717,6 +717,16 @@ function! xolox#notes#indent_list(command, line1, line2) " {{{3
normal $
endfunction
+function! xolox#notes#cleanup_list() " {{{3
+ " Automatically remove empty list items on Enter.
+ setlocal nostartofline " <- so that <C-u> clears the complete line
+ if getline('.') =~ '^\s*\' . s:get_bullet('*') . '\s*$'
+ return "\<C-o>0\<C-o>d$\<C-o>o"
+ else
+ return "\<C-o>o"
+ endif
+endfunction
+
function! xolox#notes#highlight_names(force) " {{{3
" Highlight the names of all notes as "notesName" (linked to "Underlined").
if a:force || !(exists('b:notes_names_last_highlighted') && b:notes_names_last_highlighted > s:cache_mtime)
View
14 ftplugin/notes.vim
@@ -1,6 +1,6 @@
" Vim file type plug-in
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: July 9, 2011
+" Last Change: July 22, 2011
" URL: http://peterodding.com/code/vim/notes/
if exists('b:did_ftplugin')
@@ -22,14 +22,9 @@ setlocal tabstop=3 shiftwidth=3 expandtab
let b:undo_ftplugin .= ' tabstop< shiftwidth< expandtab<'
" Automatic formatting for bulleted lists. {{{1
-if xolox#notes#unicode_enabled()
- let &l:comments = ': • ,: * ,:> '
-else
- let &l:comments = ': * ,:> '
-endif
-let &l:commentstring = '> %s'
+let &l:comments = xolox#notes#unicode_enabled() ? ': • ,: * ,:> ' : ': * ,:> '
setlocal formatoptions=tcron
-let b:undo_ftplugin .= ' commentstring< comments< formatoptions<'
+let b:undo_ftplugin .= ' comments< formatoptions<'
" Automatic text folding based on headings. {{{1
setlocal foldmethod=expr
@@ -97,4 +92,7 @@ smap <buffer> <silent> <S-Tab> <C-o>:<C-u>call xolox#notes#indent_list('<<', lin
let b:undo_ftplugin .= ' | execute "iunmap <buffer> <S-Tab>"'
let b:undo_ftplugin .= ' | execute "sunmap <buffer> <S-Tab>"'
+" Automatically remove empty list items on Enter. {{{1
+inoremap <buffer> <silent> <expr> <CR> xolox#notes#cleanup_list()
+
" vim: ts=2 sw=2 et
View
2  plugin/notes.vim
@@ -11,7 +11,7 @@ if &cp || exists('g:loaded_notes')
finish
endif
-let g:notes_version = '0.10.1'
+let g:notes_version = '0.10.2'
" Make sure the default paths below are compatible with Pathogen.
let s:plugindir = expand('<sfile>:p:h') . '/../misc/notes'
Please sign in to comment.
Something went wrong with that request. Please try again.