VIM - 通过命令行结肠传递的命令列表 [英] VIM - Passing colon-commands list via command-line
问题描述
您好,
我是我的.bashrc文件中写一个简单的脚本来容纳东西在previous的问题,我不能完全解决:
<一个href=\"http://stackoverflow.com/questions/12182024/side-by-side-view-in-vim-of-svn-diff-for-entire-directory\">Side-by-side鉴于SVN-DIFF为整个目录 Vim的
我基本上产生其中有一个修改时间SVN状态的所有文件的列表。对于每一个文件,我想创建一个并排侧视觉差异,将其转换为HTML,然后将其附加到正在运行的HTML文件。
例如:
MODIFIED_FILES =$(SVN状态| grep的^ M|切-c9-)
因为我在$ {} MODIFIED_FILES;做
#生成通过Vimdiff可以边并排差异在vim
#通过ToHTML转换
#追加HTML文件,一个名为overall_diff.html的文件
DONE
我可以通过创建该文件的全新副本,并有修改过的文件的副本完成Vimdiff可以很轻松了。
Vimdiff可以
有一些问题在第一,即:
2档,以编辑
检测到错误在处理/Users/Owner/.vimrc:
第45行:
E474:无效的参数:listchars =标签:&GT; - ,足迹:延伸:&GT;,precedes:«
preSS ENTER或键入命令继续
所以,我试图让过去,这让我没有打<大骨节病> ENTER 骨节病>在我的列表中的每个文件。
接下来,我需要有 Vimdiff可以
致电 ToHTML
命令,然后发出命令追加HTML缓冲到正在运行的文件:
:'&LT;,'&GT; W--! &GT;&GT; overall_diff.html
在短,我该怎么办:
- 让过去与
listchars
这个问题,当Vimdiff可以
被调用。当我运行不会出现此问题VIM
,所以我不知道为什么,当我运行它发生Vimdiff可以
- 传递结肠命令的列表VIM有它在
启动运行它们
,而不需要更改我的的.vimrc
文件。
在最后,我创建了被在运行时传递给 VIM
命令单独vimrc文件通过:
`VIM -d文件1 FIL2 -u my_special_vimrc_file`功能createVimDiff()
{
#创建一些缓冲
TEMP_FILE =./ tmp_file
VIM_TEMP =./ temp.html
版本=
BUFFER_FILE =./ overall_diff.html
#获取已更改的文件列表
MODIFIED_FILES =$(SVN状态| grep'可以^ M'|切-c9-)
#删除缓冲区
RM$ {} BUFFER_FILE
因为我在$ {} MODIFIED_FILES;做
#删除中间缓冲区
RM$ {} TEMP_FILE
RM$ {} VIM_TEMP
#获取当前SVN转数当前文件
版本=$(SVN信息$ {I} | grep的修订版)
#回声文件报告的名称
回声文件:$ {I}&GT;&GT; $ {} BUFFER_FILE
#等同于版本号
回声$ {}修订&GT;&GT; $ {} BUFFER_FILE
回声&LT; BR&gt;中&GT;&GT; $ {} BUFFER_FILE
#先打印未修改文件的副本在临时缓冲区
SVN猫$ {I}&GT; $ {} TEMP_FILE
#现在打印在左侧栏的未经修改的文件,以及
#改性在右列文件,因此它们出现侧由端
VIM -d$ {} TEMP_FILE$ {I}-u〜/ .vimdiff_rc
#写侧由端diff来的文件
猫$ {} VIM_TEMP&GT;&GT; $ {} BUFFER_FILE
回声&LT; BR&gt;中&GT;&GT; $ {} BUFFER_FILE
DONE
#清理临时缓冲区
RM$ {} TEMP_FILE
RM$ {} VIM_TEMP
}
和下面的投入我的vimrc文件:
转换的差异为HTML
自动命令在VimEnter *沉默TOhtml写输出到临时缓冲区
自动命令在VimEnter *宽! ./temp.html退出VIM
自动命令在VimEnter * QA!
Good day,
I am writing a simple script within my BASHRC file to accommodate something I couldn't quite resolve in a previous question:
Side-by-side view in Vim of svn-diff for entire directory
I basically generate a list of all files which have a "Modified" SVN status. For each of these files, I want to create a side-by-side visual diff, convert it to HTML, then append it to a running HTML file.
eg:
MODIFIED_FILES="$(svn status | grep "^M" | cut -c9-)"
for i in ${MODIFIED_FILES}; do
# Generate a side-by-side diff in vim via VIMDIFF
# Convert via ToHTML
# Append the HTML file to a file called "overall_diff.html"
done
I can accomplish the vimdiff easily enough by creating a clean copy of the file, and having a copy of the modified file.
vimdiff
has an issue at first, ie:
2 files to edit
Error detected while processing /Users/Owner/.vimrc:
line 45:
E474: Invalid argument: listchars=tab:>-,trail:.,extends:>,precedes:«
Press ENTER or type command to continue
So, I am trying to get past this so I don't have to hit ENTER for each file in my list.
Next, I need to have vimdiff
call the ToHTML
command, and then issue the command to append the HTML buffer to a running file:
:'<,'>w! >>overall_diff.html
In short, how do I:
- Get past this issue with
listchars
whenvimdiff
is called. This issue doesn't occur when I runvim
, so I don't know why it occurs when I runvimdiff
. - Pass a list of colon-commands to VIM to have it run them at
startup
without requiring a change to my.vimrc
file.
In the end, I created a separate VIMRC file that gets passed to the vim
command at run time, via:
`vim -d file1 fil2 -u my_special_vimrc_file`
function createVimDiff()
{
# Create some buffers
TEMP_FILE="./tmp_file"
VIM_TEMP="./temp.html"
REVISION=""
BUFFER_FILE="./overall_diff.html"
# Get a list of the files that have changed
MODIFIED_FILES="$(svn status | grep '^M' | cut -c9-)"
# Remove buffers
rm "${BUFFER_FILE}"
for i in ${MODIFIED_FILES}; do
# Remove intermediate buffers
rm "${TEMP_FILE}"
rm "${VIM_TEMP}"
# Get the current SVN rev number for the current file
REVISION="$(svn info ${i} | grep Revision)"
# Echo the name of the file to the report
echo "FILE: ${i}" >> "${BUFFER_FILE}"
# Same with the revision number
echo "${REVISION}" >> "${BUFFER_FILE}"
echo "<br>" >> "${BUFFER_FILE}"
# First print a copy of the unmodified file in a temporary buffer
svn cat "${i}" > "${TEMP_FILE}"
# Now print the unmodified file on the left column, and the
# modified file in the right column, so they appear side-by-side
vim -d "${TEMP_FILE}" "${i}" -u ~/.vimdiff_rc
# Write the side-by-side diff to a file
cat "${VIM_TEMP}" >> "${BUFFER_FILE}"
echo "<br>" >> "${BUFFER_FILE}"
done
# Cleanup temporary buffers
rm "${TEMP_FILE}"
rm "${VIM_TEMP}"
}
And the following was put into my VIMRC file:
" Convert the diff to HTML
autocmd VimEnter * silent TOhtml
" Write output to temporary buffer
autocmd VimEnter * w! ./temp.html
" Quit VIM
autocmd VimEnter * qa!
这篇关于VIM - 通过命令行结肠传递的命令列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!