diff --git a/autoload/neosnippet.vim b/autoload/neosnippet.vim index 40c510d..d3a30c5 100644 --- a/autoload/neosnippet.vim +++ b/autoload/neosnippet.vim @@ -1,7 +1,7 @@ "============================================================================= " FILE: neosnippet.vim " AUTHOR: Shougo Matsushita -" Last Modified: 29 Oct 2012. +" Last Modified: 30 Oct 2012. " License: MIT license {{{ " Permission is hereby granted, free of charge, to any person obtaining " a copy of this software and associated documentation files (the @@ -735,6 +735,10 @@ function! s:expand_placeholder(start, end, holder_cnt, line)"{{{ \ '\\d\\+', a:holder_cnt, '') let default = substitute( \ matchstr(current_line, default_pattern), '\\\ze[^\\]', '', 'g') + + let neosnippet = neosnippet#get_current_neosnippet() + let neosnippet.selected_text = default + " Substitute marker. let default = substitute(default, \ s:get_placeholder_marker_substitute_pattern(), @@ -973,6 +977,7 @@ function! neosnippet#get_selected_text(type, ...) let sel_save = &selection let &selection = 'inclusive' let reg_save = @@ + let pos = getpos('.') try " Invoked from Visual mode, use '< and '> marks. @@ -991,6 +996,7 @@ function! neosnippet#get_selected_text(type, ...) finally let &selection = sel_save let @@ = reg_save + call setpos('.', pos) endtry endfunction diff --git a/doc/neosnippet.txt b/doc/neosnippet.txt index d788725..677692e 100644 --- a/doc/neosnippet.txt +++ b/doc/neosnippet.txt @@ -361,6 +361,16 @@ Placeholder feature is available. The string after ":" is default value. ${2} endif < +Commented placeholder feature is available. If the default value starts with +"#:", neosnippet will the delete default value when jump to next placeholder. +> + snippet if + abbr if endif + options head + if ${1:#:condition} + ${2} + endif +< Note: To contain "}" character in default value, you must escape "}". > snippet test @@ -454,6 +464,9 @@ snippet *neosnippet-unite-action-snippet* ============================================================================== CHANGELOG *neosnippet-changelog* +2012-10-30 +- Implemented commented placeholder. + 2012-10-29 - Improved parse of snippets file. - Improved syntax of markers. diff --git a/plugin/neosnippet.vim b/plugin/neosnippet.vim index 75718bd..b8afbef 100644 --- a/plugin/neosnippet.vim +++ b/plugin/neosnippet.vim @@ -1,7 +1,7 @@ "============================================================================= " FILE: neosnippet.vim " AUTHOR: Shougo Matsushita -" Last Modified: 29 Oct 2012. +" Last Modified: 30 Oct 2012. " License: MIT license {{{ " Permission is hereby granted, free of charge, to any person obtaining " a copy of this software and associated documentation files (the @@ -40,22 +40,23 @@ set cpo&vim " Plugin key-mappings."{{{ inoremap (neosnippet_expand_or_jump) \ neosnippet#expand_or_jump_impl() -snoremap (neosnippet_expand_or_jump) - \ neosnippet#expand_or_jump_impl() inoremap (neosnippet_jump_or_expand) \ neosnippet#jump_or_expand_impl() -snoremap (neosnippet_jump_or_expand) - \ neosnippet#jump_or_expand_impl() inoremap (neosnippet_expand) \ neosnippet#expand_impl() -snoremap (neosnippet_expand) - \ neosnippet#expand_impl() inoremap (neosnippet_jump) \ neosnippet#jump_impl() +snoremap (neosnippet_expand_or_jump) + \ neosnippet#expand_or_jump_impl() +snoremap (neosnippet_jump_or_expand) + \ neosnippet#jump_or_expand_impl() +snoremap (neosnippet_expand) + \ neosnippet#expand_impl() snoremap (neosnippet_jump) \ neosnippet#jump_impl() -" :call neosnippet#get_selected_text(visualmode(), 1) +xnoremap (neosnippet_get_selected_text) + \ :call neosnippet#get_selected_text(visualmode(), 1) imap (neocomplcache_snippets_expand) \ (neosnippet_expand_or_jump)