Just reimplementing part of code for working with VIM