# コード箇所を囲む

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/ja-jp/help/clion/llms.txt).

CLion provides standard templates for surrounding code fragments with various constructs based on the language of the source code. これには、  `if...else`  条件ステートメント、  `do...while`  および  `for`  ループ、フォールディング領域、その他の構造が含まれます。

|  前  |  後  |
| --- | --- |
|    ![「囲む」オプション](https://resources.jetbrains.com/help/img/idea/2026.3/cl_qsg_surroundwith_before.png)  |    ![while で囲った結果](https://resources.jetbrains.com/help/img/idea/2026.3/cl_qsg_surroundwith_after.png)  |

Procedure: 言語構造でコードブロックを囲む

1. コードフラグメントを選択します。

2. メインメニューから  `コード | 囲む`  を呼び出すか、 `Ctrl+Alt+T` (Windows), `⌘ ⌥ T` (macOS), `⌘ ⌥ T` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ T` (macOS System Shortcuts), `Ctrl+Alt+Shift+B` (XWin), `Ctrl+Alt+Shift+B` (GNOME), `Ctrl+Alt+Shift+B` (KDE), `Ctrl+Alt+T` (Emacs), `Ctrl+Alt+T` (Sublime Text), `⌘ ⌥ T` (Sublime Text (macOS)), `⌘ ⌥ T` (Xcode), `Ctrl+Alt+T` (Visual Studio), `Ctrl+Alt+T` (Visual Studio (macOS)), `Ctrl+Alt+T` (ReSharper), `Ctrl+Alt+T` (ReSharper (macOS)), `Ctrl+Alt+T` (QtCreator), `⌘ ⌥ T` (QtCreator (macOS)), `Ctrl+Alt+T` (NetBeans), `Alt+Shift+Z` (Eclipse), `⌘ ⌥ Z` (Eclipse (macOS)) を押してください。

3. リストから必要なサラウンドステートメントを選択します。 オプションの上にマウスを移動すると、そのステートメントを選択した場合に適用される変更のプレビューが表示されます。

> **Note:**
> ライブテンプレートに [$SELECTION$ 変数](template-variables.html#pdtv)が含まれている場合は、サラウンドステートメントとして使用できます。
>
>
>
> 独自のサラウンドステートメントを作成するには、 [ライブテンプレートを作成し](creating-and-editing-live-templates.html)、テンプレートテキストで  `$SELECTION$`  変数を使用します。

