Vim
wondering how to do a certain conditional statement in bash using vim ex if the argument is a 1, the script will echo january.
|
vim and ex are interactive editors. They can't be used to execute statements conditionally or print strings.
To output something conditionally, you can use the if clause: Code:
if ((arg==1)) Code:
((arg==1)) && echo january |
Well, actually Vim can execute scripts with vim -s scriptname.vim. Those scripts have nothing to do with bash though. They are written in Vimscript. It's a full-blown scripting language with conditionals and printing commands among others. For an example of such a script, see your /etc/vimrc or /etc/vim/vimrc (different distros have different conventions as to where they put system-wide Vim configuration).
Or just start Vim like this: Code:
vim -c 'let arg=1|if arg==1|echo "january"|endif' |
All times are GMT -5. The time now is 03:21 PM. |