If you want to set the editor only for Git
Set core.editor in git config: git config --global core.editor "vim"
Set the git-editor environment variable to export GIT_EDITOR=vim
If you need to set editor not only for git but also for other programs use following standardized visual and editor environmental variables
export VISUAL=vim
export EDITOR="$VISUAL"
For sublime text: add the following to git.config file
[core]
editor = 'subl' --wait
--wait is compulsory which allows you to type and will wait to save/close the event.
For more information please go through the following tutorial to get more info about git: