Vim: определение источника на основе строки

Вы можете попробовать:

self.navigationItem.leftBarButtonItem = newBackButton
17
задан Magnus 8 May 2009 в 17:17
поделиться

2 ответа

You can build up a string and then use the execute command:

exec "source " . $HOME . "/.vim/myscript_" . l:foo . ".vim"

(The l:foo here is an example of using a local variable from within a function.)


Edit:

But in fact exec is overkill in this specific case. As rampion shows here, the OPs task can be done directly with:

source $HOME/.vim/myscript_$FOO.vim

Although vim does not let us wrap the variable names neatly in ${...} like we could in the shell, in this case we are lucky that HOME is terminated by the / and FOO by the .

In general, exec would be needed if you wanted to follow one of the variables by a non-terminating character. For example:

exec "source " . $BAR . "_script.vim"

would insert the BAR variable, while the following would try to find a variable called BAR_script:

source $BAR_script.vim       " Possibly not what you wanted!
37
ответ дан 30 November 2019 в 11:22
поделиться

Просто : исходный код работает для меня:

% export MYPATH='a/b/c'
% mkdir -p $MYPATH
% export MYFILE='temp.vim'
% cat > $MYPATH/$MYFILE
echo 'hello world'
^D
% vim
:source $MYPATH/$MYFILE
hello world

Если вы хотите, чтобы некоторые сценарии vim автоматически загружались, просто вставьте их в свой ~ /.

4
ответ дан 30 November 2019 в 11:22
поделиться
Другие вопросы по тегам:

Похожие вопросы: