Wednesday, September 26, 2012

Re: why is it so difficult to start using vim (may be just for me).

First try

vimtutor

(run it within your shell)

Its a command opening a special file containing some initial training
such as how to delete, insert, edit text and the like

Then next have a look at additional minimal information. The one I
consider most important is here:
https://github.com/MarcWeber/vim-addon-manager/blob/master/autoload/sample_vimrc_for_new_users.vim

And that gives some hints about how the help can be used (line 46ff)

:h *bom*<c-d>

will list all bom related options and help keywords. use <tab>
<shift-tab> to cycle, then jump to one by enter/return (which the help calls <cr>)
Note that options within '..' are buffer options - thus they are what
you're looking for.

If you can't find the information you're looking for you can still try

:helpgrep bom

to find all occurences of bom in Vim help.

> "vim [commands] file ..
> now in commands I am confused, what if I want to merge two commands
> together.

first way
vim -c 'e foo.txt' -c 'e bar.txt'
second way
vim -c 'e foo.txt | e bar.txt'

but the | command separator does not always work, so use the first one.
Mind that there is -cmd and -c
Those commands (and what you type in the command line after typing :)
is called "viml" language. You can put this into your .vimrc, too.

Multiple commands can be grouped into functions etc.
:h eval.txt will tell you all about it.

However it would be interesting to understand what you're looking for
exactly. Very ofter writing a temporary .vim file and sourcing that (so
that commands get executed) is fastest for me. Plugins like
vim-addon-local-vimrc allow you to run such code in project directories
on each startup automatically.

Now how to remove all boms?
open all .txt files (may require set hidden)
:n **/*.txt
for all buffers tell vim to not use boms:
:bufdo setlocal nobom
write all files and quit
:wa | q

How to make vim to not use boms for some files only?

augroup DONT_USE_BOMS_AND_AUTOWRITE
autocmd BufRead,BufNewFile *.* setlocal nobom
augroup end
Note that you can also use glob patterns like /home/you/project/**/*.txt or such.

How to start vim?
vim --help will show all options

> thought it must be simple to use with such a famous/powerful editor but I
> am lost in the complexity of its features
You're doing the right thing: Asking about where to find help :)
So you're doing everything right.

> I am not used to editing texts from command line, but now is needed so
> wanted to learn.
Well - it depends on what you have to edit. Even I sometimes use nano if
I have to add a single line only.
But Vim provides much more such as snippet engines which allow you to
insert the same lines of code easily again and again etc.

> with some examples ... and in detail ... from starting it to saving it, and
> exit (of course)

How to quit?
:q -> quit
:qa! -> quit and discard changes
ZZ -> write and quit current buffer (and vim if you opened one only)
ZQ -> discard changes and quit current buffer

After typing : you'll get to a command prompt (at the bottom)
ZQ and ZZ are "normal commands".

Again try to use the help - and see how easy it is:

:h quit -> will show the q[uit] command and below the q[uit]!
alternative. The ! usually means "force it" - and data may be lost.

Also try
:h ZZ

and so one.

There is much to learn so follow Brams advice: Watch yourself and try
optimizing what takes most of your time - and if its opening files than
consider learning about :oldfiles or install "open most recently used"
plugins etc.

Marc Weber

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment