Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to insert function names in insert mode #389

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/surround.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ function name inside the parentheses.
If s is used, a leading but not trailing space is added. This is useful for
removing parentheses from a function call with csbs.

If you prefer entering function name inside the buffer (possibly with a help
from lsp completion). You can enable this behaviour with an option.
>
let g:surround_insert_func_name_interactivly = "1"
<

CUSTOMIZING *surround-customizing*

The following adds a potential replacement on "-" (ASCII 45) in PHP files.
Expand Down
18 changes: 14 additions & 4 deletions plugin/surround.vim
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,25 @@ function! s:wrap(string,char,type,removed,special)
let after = '\end'.matchstr(env,'[^}]*').'}'
endif
elseif newchar ==# 'f' || newchar ==# 'F'
let fnc = input('function: ')
if fnc != ""
let s:input = fnc."\<CR>"
let before = substitute(fnc,'($','','').'('
if !exists("g:surround_insert_func_name_interactivly")
let fnc = input('function: ')
if fnc != ""
let s:input = fnc."\<CR>"
let before = substitute(fnc,'($','','').'('
let after = ')'
if newchar ==# 'F'
let before .= ' '
let after = ' ' . after
endif
endif
else
let before = '('
let after = ')'
if newchar ==# 'F'
let before .= ' '
let after = ' ' . after
endif
startinsert
endif
elseif newchar ==# "\<C-F>"
let fnc = input('function: ')
Expand Down