vim -u skips some initialization steps - vim

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.

Related

need to write a script to change file format from dos to unix

I have to make a script using vim which opens a file, set the fileformat=unix, and then save the file and exit. Could you please help? Thanks
First, check out whether you have a dos2unix or dos2ux command; it already does this for you.
With Vim, this should do the job:
$ vim -c "wq ++ff=unix" filename
This one in-lines the fileformat change with the :w command; of course, you can also do this separately via -c "set ff=unix".
Notes
You can also do this via a variety of tools, e.g. sed, perl, ...; Vim is a quite heavyweight alternative.
This still starts up a full, interactive Vim instance. Have a look at this answer which additional command-line arguments can turn Vim into batch mode.

Use vim as command line tool?

is there a way to use vim as a command line tool? What I mean is, use it from the console (without opening a ncurses window) to run vim commands on file and save them. I need this because I usually run through all my files and do 'gg=G' to auto indent them.
Thanks
Here are listed two different ways to do that:
by using vim -s file-containing-commands file-to-edit
by using vim file "+:firstcommand" "+:secondcommand" ...
The first solution needs a file to be written beforehands; the second solution will launch vim and execute the commands, without leaving vim; you'll have to do that yourself, for instance adding a last command '+:x'

vim unmap everything (completely stripped down 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.

How to get Command history by cursor key in Linux tclsh

Can get the command history by using cursor key (like up arrow key) in TCL shell (tclsh).
I am running tclsh on fedora with linux version 2.6.21.
You want access to the readline library, you can do that with rlwrap:
$ rlwrap tclsh
Useful options are -c for file name completion, and -f to add words from a file to the completion list:
$ rlwrap -cf my_complete_file tclsh
Since you almost always want to use rlwrap, adding a shell alias is useful:
alias tclsh='rlwrap tclsh'
I usually use tkcon which comes with ActiveTcl, or as a separate installation. tkcon has many features, but the one I use the most is the command-line editing aspect.
Another good pure-terminal option is tclsh-wrapper
Link to tclsh-wrapper on github
It provides rich command line editing, history, aliasing, and keyword completion but does not require X11. Documentation for the key mapping is also available.

How to enable tab-completion of command line switches in bash?

With bash, I can complete a command with TAB. Normally, it should also complete the command line switches: e.g. when I typed:
java -
it should show me the possibilities. It does not. How can I enable this preview?
See also Surprise! the shell suggests command line switches
Take a look at Extended Bash Completion
You need to have bash_completion installed and then just add . /etc/bash_completion to your .bashrc.
Related: Surprise! the shell suggests command line switches
In the answers to that question there were several links to documentation. You might find what you look for there.
Depending on what Linux flavor you're using, you may want to add a package. For Fedora and related distributions, you need to add the separate package bash-completion to get this to work. I wouldn't be surprised if other distributions had this packaged as an optional 2nd package that you need to add in addition to the bash package.
If you want to create your own custom completions you can look at this post:
https://stackoverflow.com/a/21476506/2649637

Resources