I want to be able to easily start Vim in a private mode. Let's define a private mode as one that utilizes this set of commands:
set history=0 set nobackup set nomodeline set noshelltemp set noswapfile set noundofile set nowritebackup set secure set viminfo=""
Let me know if you can think of any additional commands suitable for the private mode.
The point is I cannot think of any short and easy way to start Vim with this setup.
Here are some ideas I've come up with:
Load .vimrcprivate instead of .vimrc
You can simply put all the necessary commands into .vimrcprivate and start Vim like this:
vim -u .vimrcprivate
Define and call a
Another idea add a code like this to your .vimrc:
function Private() " set of commands here endfunction
and then you are able to start Vim in a private mode like this:
vim -c 'call Private()'
Use a variable to trigger the setting up of your commands
It is quite similar to the second solution. Just add
if exists('privatemode') " set of commands here endif
to your .vimrc and then start Vim using
vim -c 'let privatemode=1'
which is neither smart nor short.
Add an alias to your .bashrc (or to any other .*rc file your shell is using)
alias vimprivate="vim +\"set history=0\" +\"set nobackup\" +\"set nomodeline\"\ +\"set noshelltemp\" +\"set noswapfile\" +\"set noundofile\"\ +\"set nowritebackup\" +\"set secure\" +\"set viminfo=\"\"\""
which is awful. I don't like it.
Use an environmental variable
VIM_PRIVATE=1 vimand add
if $VIM_PRIVATE " set of commands here endif
to your .vimrc.
Some magic (from a comment by Carpetsmoker in this thread)
Carpetsmoker says in this comment that
I would not recommend using a separate vimrc file, for the simple reason > that it's so easy to forget. Something like this autocmd:
au BufRead * if &cryptmethod != "" | setlocal nobackup noundofile ... | endifshould do the magic for you, and it's impossible to forget.
However I've got no idea how this magic works yet.
Have you got any idea?
The perfect solution would be
vim -private or
vim +Private however:
- I am quite sure you cannot add you own custom command line options like
- when it comes to
+PrivateI was unable to find it online.