Share via


TextSelection.WordLeft 메서드

텍스트 선택 영역을 지정 된 단어 수를 왼쪽으로 이동.

네임스페이스:  EnvDTE
어셈블리:  EnvDTE(EnvDTE.dll)

구문

‘선언
Sub WordLeft ( _
    Extend As Boolean, _
    Count As Integer _
)
void WordLeft(
    bool Extend,
    int Count
)
void WordLeft(
    [InAttribute] bool Extend, 
    [InAttribute] int Count
)
abstract WordLeft : 
        Extend:bool * 
        Count:int -> unit
function WordLeft(
    Extend : boolean, 
    Count : int
)

매개 변수

  • Extend
    형식: Boolean

    선택적 요소. 이동된 텍스트가 축소되었는지 여부를 확인합니다. 기본값은 false입니다.

  • Count
    형식: Int32

    선택적 요소. 왼쪽으로 이동할 단어 수를 나타냅니다. 기본값은 1입니다.

설명

경우 Extend 는 True, 텍스트 선택 영역의 활성 끝 왼쪽으로 이동 Count 단어의 숫자입니다. 그렇지 않으면 선택한 텍스트 축소 고 위치 Count 활성 끝의 왼쪽 단어. 활성 끝을 Count에 지정된 단어 수만큼 이동하던 중 문서의 시작 부분을 만나면 위치는 문서의 시작 부분에 그대로 유지됩니다.

Count의 값이 음수이면 WordLeft가 WordRight 메서드처럼 수행됩니다.

텍스트 문서의 활성 언어 관리자는 "단어"의 의미를 정의합니다.

예제

Sub WordLeftExample()
    ' Before running this example, open a text document.
    Dim objSel As TextSelection = DTE.ActiveDocument.Selection
    If objSel.IsEmpty Then
        ' If there is no text selected, swap the words before and after 
        ' the insertion point. We begin by selecting the word before 
        ' the insertion point.
        objSel.WordLeft(True)
        If Not objSel.IsEmpty Then
            ' We can continue only if the selection was not already at 
            ' the beginning of the document.
            Dim strBefore As String = objSel.Text

            ' The text is saved in strBefore; now delete it and move 
            ' past the following word.
            objSel.Delete()
            objSel.WordRight(True)
            If objSel.Text.StartsWith(" ") Or objSel.Text.StartsWith(Microsoft.VisualBasic.ControlChars.Tab) Then
                ' The previous call to WordRight may have skipped some 
                ' white space instead of an actual word. In that case, 
                ' we should call it again.
                objSel.WordRight(True)
            End If

            ' Insert the new text at the end of the selection.
            objSel.Insert(strBefore, vsInsertFlags.vsInsertFlagsInsertAtEnd)
        End If
    Else
        ' If some text is selected, replace the following word with the 
        ' text selection.
        Dim strSelected As String = objSel.Text

        objSel.MoveToPoint(objSel.BottomPoint)
        objSel.WordRight(True)
        If objSel.Text.StartsWith(" ") Or objSel.Text.StartsWith(Microsoft.VisualBasic.ControlChars.Tab) Then
            ' The previous call to WordRight may have skipped some 
            ' white space instead of an actual word. In that case, we 
            ' should call it again.
            objSel.WordRight(True)
        End If

        ' Insert the text, overwriting the existing text and leaving 
        ' the selection containing the inserted text.
        objSel.Insert(strSelected, vsInsertFlags.vsInsertFlagsContainNewText)
    End If
End Sub

.NET Framework 보안

참고 항목

참조

TextSelection 인터페이스

EnvDTE 네임스페이스