Skip to content

One bug report and One confliction #43

@lanjiann

Description

@lanjiann

I. When let g:xptemplate_brace_complete=1, paste from registers * and + wrong result will show up, for example: if I copy some text like getline('.')[col('.') - 1] with line end invisible symbol, which can be selected if set list, I will get(in two lines)

getline(.'[ol(.') - 1]
')

; if I virtual select an area without line end invisible symbol, I will get getline(.'[ol(.') - 1]'). Both are wrong. BTW, you can see a highlight marker inside the pasted text, which, I think, was generated by auto applying common.bracketcmpl.xpt.vim when pasting.

II. It has been a long time for me not writing C-like code. So I write a vimscript function inside .vimrc to auto add semicolon to the end of non-blank line. My vimscript function is very simple and concentrates on adding semicolon only to the end of lines, because I know the non-line-end-semicolon, such as semicolon in structure(i = 0; i < len; i++) will be autocompleted by xptemplate. My function and map are like this:

function! AutoSemicolon() "{{{
  if getline('.') =~ '^[:space:]*$'
      execute "normal o"
      startinsert
  else
      execute "normal A;"
      execute "normal o"
      startinsert
  endif
endfunction "}}}

autocmd FileType c,cpp,java <buffer><CR> <ESC>:call AutoSemicolon()<CR>

However, I notice they conflict. Before trigger the first xptemplate snippet in a file, my code work well. After triggering a xptemplate snippet, when typing , I will get error messages:

E15: Invalid expression: ^[:call AutoSemicolon()^M
E15: Invalid expression: ^[:call AutoSemicolon()^M

Could you tell me how to solve this? And could you provide this kind of facility in the future version of xptemplate?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions