[英]VIM - Passing colon-commands list via command-line
Good day, 美好的一天,
I am writing a simple script within my BASHRC file to accommodate something I couldn't quite resolve in a previous question: 我正在BASHRC文件中编写一个简单的脚本,以容纳我在上一个问题中无法解决的问题:
Side-by-side view in Vim of svn-diff for entire directory 在整个目录的svn-diff的Vim中并排查看
I basically generate a list of all files which have a "Modified" SVN status. 我基本上生成了一个具有“修改”SVN状态的所有文件的列表。 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.
对于这些文件中的每一个,我想创建一个并排的可视差异,将其转换为HTML,然后将其附加到正在运行的HTML文件。
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。
vimdiff
has an issue at first, ie: vimdiff
最初有一个问题,即:
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. 所以,我试图通过这个,所以我不必为列表中的每个文件按ENTER键 。
Next, I need to have vimdiff
call the ToHTML
command, and then issue the command to append the HTML buffer to a running file: 接下来,我需要让
vimdiff
调用ToHTML
命令,然后发出命令将HTML缓冲区附加到正在运行的文件:
:'<,'>w! >>overall_diff.html
In short, how do I: 简而言之,我该怎么做:
listchars
when vimdiff
is called. vimdiff
时,使用listchars
解决此问题。 This issue doesn't occur when I run vim
, so I don't know why it occurs when I run vimdiff
. vim
,这个问题不会发生,所以当我运行vimdiff
时,我不知道它为什么会出现。 startup
without requiring a change to my .vimrc
file. startup
时运行它们,而不需要更改我的.vimrc
文件。 In the end, I created a separate VIMRC file that gets passed to the vim
command at run time, via: 最后,我创建了一个单独的VIMRC文件,该文件在运行时传递给
vim
命令,通过:
`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: 以下内容已放入我的VIMRC文件中:
" Convert the diff to HTML
autocmd VimEnter * silent TOhtml
" Write output to temporary buffer
autocmd VimEnter * w! ./temp.html
" Quit VIM
autocmd VimEnter * qa!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.