に行く grammar with 行く replaced by other verbs


I wonder if I can be more creative and replace 行くwith other verbs.

> トニーくんは皆さんのためにコーヒー準備しに部屋を出ました。(1)
>
> トニーくんは部屋を出て皆さんのためにコーヒー準備しました。(2)

  * Tony left the room to prepare coffee for everyone. (1)
  * Tony left the room and prepared coffee for everyone. (2)

The first sentence sounds more natural if 行くcan be replaced with 出る, since
both Japanese verbs express direction. I want to know if I am doing it the
acceptable way. Thank you.

EDIT: I meant, the meaning will change depending on the last verb used.

  * に行く: Go to do something 
  * に出る: Leave (a place) to do something

A demonstrating example with 行く even though it is irrelevant :

> 昨日 トニーくんは勉強しに図書館に行きました。(3)

  * Yesterday Tony went to the library to study.




One of the functions of the に particle is showing the purpose/goal of an
action
([動作・作用の目的を表す)](https://kotobank.jp/word/%E3%81%AB-590835#E5.A4.A7.E8.BE.9E.E6.9E.97.20.E7.AC.AC.E4.B8.89.E7.89.88),
ie "買いに行く", so you can replace 行く, but as Chocolate helpfully corrected me in
the comments, the way you express this in Japanese changes depending on
whether or not the verb expresses movement.

If it is a movement verb, such as 行く/来る/帰る, you use the 連用形{れんようけい} form/masu
stem of the action or a noun that expresses an action + に + the movement verb.

Examples:  

> 友達が遊びに来るんだ。  
>  買いに行く。  
>  映画を見に行く。  
>  買い物に行きます。

If you are using any other verb except for that, you need to add の before に.

Examples:  

> ご飯を食べるのに使うお茶碗  
>  えんぴつは字を書くのに使います。




One of the functions of the に particle is showing the purpose/goal of an
action
([動作・作用の目的を表す)](https://kotobank.jp/word/%E3%81%AB-590835#E5.A4.A7.E8.BE.9E.E6.9E.97.20.E7.AC.AC.E4.B8.89.E7.89.88),
ie "買いに行く", so you can replace 行く, but as Chocolate helpfully corrected me in
the comments, the way you express this in Japanese changes depending on
whether or not the verb expresses movement.

If it is a movement verb, such as 行く/来る/帰る, you use the 連用形{れんようけい} form/masu
stem of the action or a noun that expresses an action + に + the movement verb.

Examples:  

> 友達が遊びに来るんだ。  
>  買いに行く。  
>  映画を見に行く。  
>  買い物に行きます。

If you are using any other verb except for that, you need to add の before に.

Examples:  

> ご飯を食べるのに使うお茶碗  
>  えんぴつは字を書くのに使います。

