vim usage
4486 단어 vim
:g/^Error/.w! >> errors.txt
===========================================================================
" global command display
:g/gladiolli/# : display with line numbers (YOU WANT THIS!)
:g/fred.*joe.*dick/ : display all lines fred,joe & dick
:g/\<fred\>/ : display all lines fred but not freddy
:g/^\s*$/d : delete all blank lines
:g!/^dd/d : delete lines not containing string
:v/^dd/d : delete lines not containing string
:g/joe/,/fred/d : not line based (very powerfull)
:g/fred/,/joe/j : Join Lines *N*
:g/-------/.-10,.d : Delete string & 10 previous lines
:g/{/ ,/}/- s/
\+/\r/g : Delete empty lines but only between {...}
:v/\S/d : Delete empty lines (and blank lines ie whitespace)
:v/./,/./-j : compress empty lines
:g/^$/,/./-j : compress empty lines
:g/<input\|<form/p : ORing
:g/^/put_ : double space file (pu = put)
:g/^/m0 : Reverse file (m = move)
:g/^/m$ : No effect! *N*
:'a,'bg/^/m'b : Reverse a section a to b
:g/^/t. : duplicate every line
:g/fred/t$ : copy(transfer) lines matching fred to EOF
:g/stage/t'a : copy (transfer) lines matching stage to marker a (cannot use .) *C*
:g/^Chapter/t.|s/./-/g : Automatically underline selecting headings *N*
:g/\(^I[^^I]*\)\{80}/d : delete all lines containing at least 80 tabs
" perform a substitute on every other line
:g/^/ if line('.')%2|s/^/zz /
" match all lines containing "somestr" between markers a & b
" copy after line containing "otherstr"
:'a,'bg/somestr/co/otherstr/ : co(py) or mo(ve)
" as above but also do a substitution
:'a,'bg/str1/s/str1/&&&/|mo/str2/
:%norm jdd : delete every other line
" incrementing numbers (type <c-a> as 5 characters)
:.,$g/^\d/exe "norm! \<c-a>": increment numbers
:'a,'bg/\d\+/norm! ^A : increment numbers
" storing glob results (note must use APPEND) you need to empty reg a first with qaq.
"save results to a register/paste buffer
:g/fred/y A : append all lines fred to register a
:g/fred/y A | :let @*=@a : put into paste buffer
:let @a=''|g/Barratt/y A |:let @*=@a
" filter lines to a file (file must already exist)
:'a,'bg/^Error/ . w >> errors.txt
" duplicate every line in a file wrap a print '' around each duplicate
:g/./yank|put|-1s/'/"/g|s/.*/Print '&'/
" replace string with contents of a file, -d deletes the "mark"
:g/^MARK$/r tmp.txt | -d
" display prettily
:g/<pattern>/z#.5 : display with context
:g/<pattern>/z#.5|echo "==========" : display beautifully
" Combining g// with normal mode commands
:g/|/norm 2f|r* : replace 2nd | with a star
"send output of previous global command to a new window
:nmap <F3> :redir @a<CR>:g//<CR>:redir END<CR>:new<CR>:put! a<CR><CR>
"----------------------------------------
" Global combined with substitute (power editing)
:'a,'bg/fred/s/joe/susan/gic : can use memory to extend matching
:/fred/,/joe/s/fred/joe/gic : non-line based (ultra)
:/biz/,/any/g/article/s/wheel/bucket/gic: non-line based *N*
----------------------------------------
" Find fred before beginning search for joe
:/fred/;/joe/-2,/sid/+3s/sally/alley/gIC
"----------------------------------------
" create a new file for each line of file eg 1.txt,2.txt,3,txt etc
:g/^/exe ".w ".line(".").".txt"
"----------------------------------------
" chain an external command
:.g/^/ exe ".!sed 's/N/X/'" | s/I/Q/ *N*
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Lua에서 neovim 플러그인용 UI를 만드는 방법마지막 에서는 부동 창을 사용하여 Lua에서 플러그인을 만드는 기본 사항을 살펴보았습니다. 편리한 측면 탐색에서 마지막으로 연 파일을 표시하는 간단한 플러그인을 만들어 봅시다. 인터페이스 학습에 집중하면서 이러한 목...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.