在正文中,我想在<代码>[工作目录]/spec/models/内建立一个称为“条码”的新档案,但名录还没有。
建立目录和开始编辑档案的最快途径是什么? 任何一分子?
在正文中,我想在<代码>[工作目录]/spec/models/内建立一个称为“条码”的新档案,但名录还没有。
建立目录和开始编辑档案的最快途径是什么? 任何一分子?
指挥:
function s:MKDir(...)
if !a:0
|| stridx( `+ , a:1[0])!=-1
|| a:1=~# v\@<![ *?[%#]
|| isdirectory(a:1)
|| filereadable(a:1)
|| isdirectory(fnamemodify(a:1, :p:h ))
return
endif
return mkdir(fnamemodify(a:1, :p:h ), p )
endfunction
command -bang -bar -nargs=? -complete=file E :call s:MKDir(<f-args>) | e<bang> <args>
该指令意在取代在<条码>上的代号:e。
哺乳动物不使用的条件(按顺序排列):
`generate filename`
or `=generate_filename()`
backticks filename generators or with +command
/++opt
switches.在最近3起案件中,没有做任何事,第二和第三起案件不可能处理,更复杂。
The above is ready for adding a cnoreabbrev
:
cnoreabbrev <expr> e ((getcmdtype() is# : && getcmdline() is# e )? E : e )
-complete=file
spoils things: it add not only completion, but also arguments processing (thus checking for `
expansion and special characters presence does not make sense) and forbids having multiple “filenames” (thus no ++opt).
<代码>-bar使您无法使用'=“String”
,因为现在就开始发表评论。 没有<条码>-条码>。 这不是一个<条码>:e条码>,因为你不能填写<条码>。 E. 档案
另一种版本:
function s:MKDir(...)
if !a:0
|| isdirectory(a:1)
|| filereadable(a:1)
|| isdirectory(fnamemodify(a:1, :p:h ))
return
endif
return mkdir(fnamemodify(a:1, :p:h ), p )
endfunction
command -bang -bar -nargs=? -complete=file E :call s:MKDir(<f-args>) | e<bang> <args>
:!mkdir -p spec/models
:w spec/models/blog_spec.rb
如果你经常遇到这种情况,可能值得为此增加指挥。
command -nargs=1 E execute( silent! !mkdir -p "$(dirname "<args>")" ) <Bar> e <args>
如果在您的档案中添加这一条,你可以简单地照此使用:
:E spec/models/blog_spec.rb
Edit 这一工作将仅涉及Libert/Mac,而不是Windows。
我一般认为,只有
该代码将促使你以<代码>创建名录:w,或仅以<代码>制作:w!:
augroup vimrc-auto-mkdir
autocmd!
autocmd BufWritePre * call s:auto_mkdir(expand( <afile>:p:h ), v:cmdbang)
function! s:auto_mkdir(dir, force)
if !isdirectory(a:dir)
&& (a:force
|| input(" " . a:dir . " does not exist. Create? [y/N]") =~? ^y\%[es]$ )
call mkdir(iconv(a:dir, &encoding, &termencoding), p )
endif
endfunction
augroup END
Is it possible to update vim plugins automatically?
How can I configure vim to autowrite buffers after switching with alt-tab to another application?
I m writing a lot of python code recently, and i used the tab-to-space mode in vim. I was just wondering how would i unindent in vim without leaving edit mode for example after i finished if...: block....
I ve been googling around trying to figure out if it s possible to use my mouse wheel to scroll while inside Vim in Mac s Terminal, with no luck. It seems as if only X11 or iTerm support this. Before ...
How do I delete comments in XML? If the opening and the closing comment tags are on the same line, I use :g/^<!--.*-->$/d to delete the comment. How to delete the comments that are spread ...
I have the following in my .vimrc to highlight lines longer than 80 chars: highlight OverLength ctermbg=red ctermfg=white guibg=#592929 match OverLength /\%81v.*/ This works quite well. However, the ...
Whenever I start a shell in vim using :sh, it doesn t source my ~/.bashrc file. How can I get it to do this automatically?
I’ve got a lot of plugins enabled when using Vim – I have collected plugins over the years. I’m a bit fed up with how long Vim takes to start now, so I’d like to profile its startup and see which of ...