Skip to content

Instantly share code, notes, and snippets.

@Houl
Created January 7, 2014 18:26
Show Gist options
  • Save Houl/8304083 to your computer and use it in GitHub Desktop.
Save Houl/8304083 to your computer and use it in GitHub Desktop.
expand("<cword>") for the word left from the cursor
func! ExpandHeadWord()
let [clnum, ccol] = searchpos('\<\k*\%(\k\@!.\)*\%#', 'bcWn')
if ccol >= 1
return matchstr(strpart(getline(clnum), ccol-1), '^\k*')
else
return ""
endif
endfunc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment