if ["$1" = "g"]; then
You need spaces inside
], as they are parsed like ordinary commands. Indeed,
[ is an ordinary command (which is a builtin in most shells).
Why are you exiting with an error status after running the editor? A return status of 0 means success, anything else means failure. You should make your script return the same status as the editor. As written, you can leave off
exit altogether: when the shell reaches the end of the script, it terminates the execution of the script and returns the status of the last command that was executed.
As a refinement, you can use the
exec builtin so that instead of running the editor as a subprocess, your script will terminate and be replaced by the editor. (The same process keeps running, but its code switches to that of the other program.) But don't do that if you make this a function and not a script!
case construct would be clearer to express that you're basing your conditional on the value of a particular variable.
case "$editor" in
g) exec geany "$file".tex;;
linha=$(wc -l < "$file".tex)
exec texstudio --line "$linha" "$file.tex";;