vim

vim - search. 커서가 어디에 놓일지를 정해주는 방법

루트노드 2011. 9. 9. 17:53

Vim tips: The basics of search and replace

Where you land

Searches in Vim put the cursor on the first character of the matched string by default; if you search for Debian, it would put the cursor on the D. That's usually fine, but Vim has a few options for offsetting the cursor placement from the beginning of the matched string.

To land on the last character in the matched string, rather than the beginning, add an /e to your search:

/Debian/e

That will place the cursor on the n rather than the D. Vim also allows you to specify a cursor offset by line, or from the beginning or end of the string. To have the cursor land two lines above a matched string, for example, use /string/-2. To place the cursor two lines below the string, use /string/+2.

To offset from the beginning of the string, add a /b or /s with the offset that you want. For example, to move three characters from the beginning of the search, you'd use /string/s+3 or /string/b+3 -- "s" for "start" or "b" for "begin." To count from the end of the string, use /e instead, so /string/e-3 will place the cursor on the third character from the last character of the matched string.


커서 위치에 대해 별다른 지정이 없으면, search string의 첫번째 문자에 커서가 올라온다.

/Debian/s+3 또는 /Debian/b+3 첫번째 문자에서 세문자 뒤에 커서가 올라온다.

/Debian/e+5 는 탐색 문자열에서 다섯 문자 뒤에 커서가 올라온다.