2

I came across some odd vimscript syntax while reading through the source of the fugitive plugin that I haven't been able to find any documentation on or figure out what it does. It's a user command followed by a space and a colon like so (third line):

function! s:Status() abort
  try
    Gpedit :
    wincmd P
    setlocal foldmethod=syntax foldlevel=1
    nnoremap <buffer> <silent> q    :<C-U>bdelete<CR>
  catch /^fugitive:/
    return 'echoerr v:errmsg'
  endtry
  return ''
endfunction

I've never seen this before! I've worked through Steve Losh's Learn Vimscript the Hardway book, read plenty of articles on vimscript, read help often and have never come across this other than here. Anyone know?

Xavier T.
  • 40,509
  • 10
  • 68
  • 97
Andrew Haust
  • 356
  • 2
  • 12
  • 1
    Well, if it's a user command it can take any argument it pleases. `$!?*=` might be an acceptable argument if the command can deal with it. – glts Nov 30 '14 at 18:59
  • Ohhh, dang. I've even seen that documentation before. I still get muddled sometimes read vimscript. I always try and remind myself to "just imagine a : at the beginning of every line" but still forget sometimes. That to me just looked like some weird line with no "call" or "exec" leading it off. Anyway, thank you!! – Andrew Haust Nov 30 '14 at 19:10
  • in prolog with ```(; :echom vim:[ $!?*= ] prolog:{"~q" – Kintalken Aug 28 '17 at 11:55

1 Answers1

3

There is nothing special about this syntax. Since :Gpedit is a user command, it can take any argument its author has provided some handling logic for.

When you look up the documentation for :Gpedit you can see that it takes a 'revision' argument.

You'll also find in the documentation that : is short for the Git index.

glts
  • 21,808
  • 12
  • 73
  • 94