Vim:Buffer
Buffer list
:ls또는 :ls!를 사용하여 버퍼목록 출력할 수 있다.
Indicators (chars in the same column are mutually exclusive):
| Flags | Brief | ||||
| u | an unlisted buffer (only displayed when ! is used) | ||||
| % | the buffer in the current window | ||||
| # | the alternate buffer for " | ||||
| a | an active buffer: it is loaded and visible | ||||
| h | a hidden buffer: It is loaded, but currently not displayed in a window hidden-buffer | ||||
| - | a buffer with 'modifiable' off | ||||
| = | a readonly buffer | ||||
| + | a modified buffer | ||||
| x | a buffer with read errors | ||||
Active buffer list
function TrimLeft(text)
return substitute(a:text, '^[ \t]*', '', '')
endfunction
function GetBuffersOutput()
redir => output
silent execute 'buffers'
redir END
return output
endfunction
function GetListedBuffer()
let result = []
for cursor in split(GetBuffersOutput(), '\n')
let result += [matchstr(TrimLeft(cursor), '^[0-9]*')]
endfor
" return a string list.
return result
endfunction
이후, :call GetListedBuffer()를 호출하면 된다.
Example
-
:ls: 버퍼 목록을 출력한다. -
:ls!: 버퍼 목록을 출력한다. (unlisted-buffer도 출력한다) -
:bufdo [COMMANDS]:bufdoruns command for all buffers. -
:bufdo bd: Close all buffer. -
:bd: 현재 버퍼를 닫는다. (unlisted-buffer에 남아있다) -
:bw: 현재 버퍼를 완전히 제거한다. -
:bd2: 2번 버퍼를 닫는다. -
:1,100bd: 1번 ~ 100번 버퍼를 닫는다. -
:echo bufnr('%'): 현재 버퍼의 번호를 출력한다. -
:bnext: 다음 버퍼로 이동. -
:bprevious: 이전 버퍼로 이동.