Oh, and change .* to .+ to exclude the current word, i.e.: completionCommand = 'perl -pe "s/^\t{4}($TM_CURRENT_WORD.+)\$|.* \n?/\$1/" <"$TM_FILEPATH"|sort|uniq';