http://qs321.pair.com?node_id=592477


in reply to Learn vi/vim in 50 lines and 15 minutes

I made the switch to vim in 2003, maybe 2004 for its syntax highlighting. The last step was figuring out how to do cut and paste longer than a single line at a time (dd, p).

During the transition, I would close the file in vim, open it in nano for block moves, then return to vim. I called a friend who introduced me to my first shell and he helped me break my nano habit (except for a rare machine I've encountered where the J command did not work to kill the \n at the end of a line). He introduced me to markers. The m key will set a marker, named after the next letter you feed it. Go to the start of your block you want to move, type `ma`. Then move to the end of your block and use `d'a` and it will delete from the current position back to the marker you set. Move the cursor again and use the `p` key to paste your block where you want it.

I found this far less annoying than using `dd` and `p` to move one line at a time.

From a combination of nodes here, the vim website and elsewhere, I have now accumulated the following .vimrc file which creates a useful development environment for me. The first thing I do after being given shell access to a new server, right after changing my password, is to scp my .vimrc from my usual servers to the new environment.

My .vimrc follows:

set wrapmargin=1 "source /usr/share/vim/current/syntax/html.vim" syntax on set vb set sw=2 set autoindent set number set tw=71 set mouse=a map # :%s/./>&/ map @ 1G!Gcloak^M3Gdj map J {!}fmt -65^M}j set noautoindent set undolevels=1 set noerrorbells set bg=light " set bg=dark set wildchar=<tab></tab> let perl_include_pod = 1 let perl_extended_vars = 1 " check perl code with :make autocmd FileType perl set makeprg=perl\ -c\ %\ $* autocmd FileType perl set errorformat=%f:%l:%m autocmd FileType perl set autowrite au BufRead,BufNewFile *.t set filetype=perl | compiler perlprove " This is for taglist " let Tlist_Inc_Winwidth = 0 " map <F3> :Tlist<CR>
I write nearly everything in vim these days, love letters, code, memos, reports. Between vim and mailx (catdoc, antiword, xpdf's pdftotext and munpack) I rarely need to leave a console. Perhaps a couple of times a month I'll open Abiword or OpenOffice to "pretty up" a document for printing. But I also once wrote a perl script to massage a plain text press release thorugh LaTeX into a pdf file, so I didn't have to open a gui editor just to distribute a press release (something I had to do several times a week in a previous job).

When I introduce new folks to a linux environment, as I'm telling them not to fear the shell prompt, I urge them to learn a text editor. I tell them that nano may be more intuitive and easier to learn (with its on screen menu), but that vim is far more powerful, that if they spend any time writing (as I do) that they will appreciate having mounted the learning curve.

By now I am so attuned to working in vim, that I sometimes find spurious :wq or i's in my documents composed in other editors or on webforms like this one.

-- Hugh

:wq

if( $lal && $lol ) { $life++; }