vim unmap everything (completely stripped down vim) - vim

Love vim. Tried Janus. Like the idea, but it's too slow, 100 plugins competing for keybindings. I want to actually understand what every vim configuration I make does.
Is there a way to "unmap" all vim keys or as much as possible. Remove most commands, etc. The point of this is an exercise for myself. I want a super small subset of maps, settings, bindings, so I can add things one by one as I need them.
Have you seen efforts like this?

Try to run vim with the following command :
"vim -u NONE"
from man vim
-u {vimrc} Use the commands in the file {vimrc} for initializations.
All the other initializations are skipped. Use this to
edit a special kind of files. It can also be used to skip
all initializations by giving the name "NONE". See ":help
initialization" within vim for more details.
It should start vim without any plugin or customisation.

Aside from
:mapclear
:nmapclear
:vmapclear
:xmapclear
:smapclear
:omapclear
:mapclear
:imapclear
:lmapclear
:cmapclear
starting it like
vim -U NONE -C -Z
will start
-U without startupfile
-C in compatible mode
-Z in restricted mode

I tried to do something similar and posted that on reddit post.
I try to restrict the mappings I define in my vimrc and load only some
plugins that I find essential.

Related

Separate settings for Easy Vim (with -y flag)

Is there a way to have some settings which will work only for Easy Vim (Vim with -y flag, i.e. vim.exe -y), but not for "normal" Vim?
This works for me:
_vimrc file + _gvimrc file
However, this doesn't:
_vimrc file + _evimrc file
Probably I shouldn't try to use separate file for it, but incorporate such settings into _vimrc or _gvimrc instead? How is it possible?
As far as I can see, this isn't easy, but it's doable:
From within Vimscript (= in your .vimrc), you can call ps to get the arguments vim was called with
echo split(system("ps -o command= -p " . getpid()))
This prints ['vim', '-y'] and you could then go on checking if -y is in that list (with count) and then do different things depending on that.
I see that you're using Windows though, so you have to find an alternative to the ps solution. This answer on superuser makes me believe WMIC path win32_process get Caption,Processid,Commandline might be a start..
I would guess that those "settings" that break in Easy Vim is 'insertmode', as that is the defining option of it. You can check for it in your ~/.vimrc, like this:
if ! &insertmode
" Stuff that only works in default (non-Easy) Vim.
" ...
endif

How do I use Vim with Rebar

Trying to get up and running Vim + Rebar.
Separately they work but not together. What I want to achieve is to run eunit without leaving the Vim.
I guess this is doable with following plugin https://github.com/mbbx6spp/vim-rebar . Unfortunately is very poorly documented.
How do I run my tests quickly, see the output, code and once again.
All your feedback will be appreciated.
I don't know how to integrate rebar into vim, but perhaps you could try tmux? This works for me. In one window I keep opened vim, another window i use as compilation/attach session to erlang node.
One quick way to get out of Vim is to suspend it with Ctrl+z, run your commands, and then foreground it again with fg afterwards. Works at least on bash in Os X and Ubuntu Linux.
You can also run command line commands with :! <command name> directly from Vim, e.g. :! ls.
Yet another way is to use screen, with one window running vim and another still on the command line.
The best solution I've found is to use a Makefile in my project. Since vim is capable of running shell commands, you can call make & have it use your makefile. Then map these shell commands to shortcuts of your choosing.
For example, my Makefile has the following:
test:
$(REBAR) skip_deps=true eunit
In my .vimrc:
command MakeErlangTest !make test
nmap <leader>r :MakeErlangTest<CR>

Custom autocompletion for zsh

ZSH has builtin autocompletion for scp, so a command like
scp user#host/path/
would show directory listings on the remote server.
However, this does not work when opening a remote file in vim
vim scp://user#host/path/
I have googled around for documentation on the zsh autocomplete functions but it seems very complicated. How can I enable autocomplete for vim scp?
Complete autocompletion documentation is located in man zshall (if you don't want to view all sections in one man, see index in man zsh). Completion for vim is located in /usr/share/zsh/$ZSH_VERSION/functions/Completion/Unix/_vim, I guess you need to modify _vim_files function located at the top of the file and somehow export function _remote_files located in the /usr/share/zsh/$ZSH_VERSION/functions/Completion/Unix/_ssh.

what is the load order of scripts when you start up vim?

If you start up vim with something like this:
vim -S myscript.vim file.txt
What is the load order of scripts? Does myscript.vim get loaded after or before ~/.vimrc.
If you pass in vimscript commands to vim directly on the command line, when do they get executed relative to sourced and default vimscripts?
I believe vimrc is always first. You can run :scriptnames to get a list of sourced scripts in order in which they were first sourced in your Vim instance.
The help entry is way too long to post here, but it lists the order of everything that vim does at initialization. See :help initialization.
The answer is myscript.vim gets loaded dead last.
The vim -V option is a lifesaver here. (Capital -V, because -v starts in vi mode.) Just ran across it, after searching further since although the other answers answered your question, they don't show what wasn't sourced because it wasn't found. If I could send it back in time, I'd save myself a lot of time banging my head against strace output.
This will not only show you all of the scriptnames that it did source in order, but also all of the scriptnames that it would have sourced if they existed in order. So, you can discover what files you can create to load at the appropriate time.
$ vim -V
Adding it to your vim arguments easily answers the question.
$ vim -V -S myscript.vim file.txt
It shows myscript.vim as dead last.
It prints a ton, and winds up at a "Press ENTER or type command to continue" prompt, which lets you step through Autocommands.

vim -u skips some initialization steps

vim -u vimrc_file lets me specify a particular vimrc file to use, however from what I read from :help initialization some initialization steps are skipped.
Is there a different option I can use to run vim using a particular vimrc file without skipping those initialization steps?
or Maybe how can I include those initialization steps that are skipped into the vimrc file?
thanks in advance
Is there a different option I can use to run vim using a particular vimrc file without skipping those initialization steps?
Documentation of my VIM 7.1 shows that those initialization steps are only to read from other standard rc files. What IMO is the whole point of the -u option: only the initialization commands from the user supplied script are read, thus they are guaranteed not to be overridden by standard initialization scripts.
Try the -S {file} option to see if it fits your needs better.

Resources