简体   繁体   中英

setting custom arguments in vimrc

I've tried looking everywhere for information on this but have come up short. I want to be able to use vimrc to set my own arguments for opening vim with. The idea being that if I run "vim -#code foo.bar" then the vimrc file will set syntax highlighting and line numbers but if run "vim foo.bar" then the file will open without line numbers or syntax highlighting. This seems like an obvious thing to want to do and I'm sure I've missed a trick somewhere but I'm struggling to get vim to play nicely. It seems silly to have to set a bash alias for this when the vimrc file is designed for this kind of thing.

My vimrc currently looks like this:

if $ARGV[0] == "#code"
set nu
filetype plugin on
syntax on
endif

I have a workaround for similar situation I have special vimrc (.coding_vimrc) wich loads usual vimrc inside

source .vimrc

and contains all special settings for coding

Run vim with

vim -u .coding_vimrc foo.bar

PS: assumes full path in both cases

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM