Lev Lvovsky wrote:
I recently started work at a company where the predominant text editor happens to be emacs. I've been using vim for a while now, though only recently started getting into the more advanced functionality beyond simple editing (highlighting, folding, tags etc...). Watching one of my co-workers with emacs is pretty fun, as he does things fairly quickly - I asked him what his most common emacs actions were, to see how I could do them in vim:

* autocomplete - say that I've declared a constant variable in Perl named MY_CONSTANT, later, to have the editor fill it in, I type in MY_, and some other key-stroke, and "CONSTANT" gets typed in for you

You can do it if the filetype-plugin provides for it. In Vim it is called "omni-completion" (new in version 7).
See
        :help compl-omni
        :help compl-omni-filetypes


* goto when compiling - when compiling with make for example, and there is a problem in the code identified by a line, can vim somehow know to go to that line? this would be especially useful with 'make'

The Vim help dedicates one whole helpfile to that:
        :help quickfix.txt


* rectangular cut/pastes - if I have a column (multi-row) of text that I'd like to paste on several lines, can I do this without a regex?

Blockwise visual mode. Start with Ctrl-V, move the cursor, copy, paste, whatever. You can also do it linewise or characterwise. See
        :help visual.txt


* ctags variable name references - assuming I'm using ctags, how can I replace the name of a variable throughout my code base?

That depends how your "code base" is defined. For instance, to replace "foo" by "bar", but as single words only, in all .c and .h files in any subdirectory of the parent of the current dir:
(untested)
        :args ../**/*.[ch]
        :argdo 1,$s/\<foo\>/bar/g | w

Note that the ":vimgrep" command (internal grep, available starting at version 7) is very useful to search the files of a given project for a given regex. See

        :help :vimgrep


* regional undo - can I select a region, and perform an undo for all of the changes only in that region?

that isn't so obvious. Maybe undo, followed by select above and . (redo latest change), select below and . but I'm not sure.


* cvs/diff mode - what support does vim offer for these two apps, internal to the editor.

Vim source can be fetched by cvs. To get other sources by cvs and edit them in Vim, I'm not sure; probably see
        :help pi_netrw.txt

diff mode is fully supported, see
        :help -d
        :help diff.txt

The appropriate external program must of course be present. See also
        :help :!
        :help filter
        etc.

about using external commands from within Vim.


I'll be glad to RTFM for all of these things, however I don't know where to look them up - any pointers would be appreciated!

To find your lost "needle" in the vim help "haystack":

Method I. You know part of a help tag. Use helptag completion:

        :set wildmode
        :help <pattern><Tab>

where <pattern> is a Vim regex and <Tab> means "hit the Tab key". If there is only one possible completion, Vill will complete it on the command-line; if there are two or more you'll get a menu on the bottom status line. Select with <Left> and <Right>, accept with <Enter>, cancel with <Esc>

Method II. You want to search for some text in the body text of all helpfiles. Use the ":helpgrep" command (requires version 6.1.423 or higher). Its use is explained under
        :help :helpgrep

Basically, you enter
        :helpgrep <pattern>

to search the helpifles for a given regexp. Then you may use the commands
        :cn[ext]
        :cp[revious] (or cN[ext])
        :cfir[st]
        :cla[st]

to navigate the results (if any) -- just like the results of vimgrep or the errors of a compile. To do it faster, I have defined the mappings

        :map <F2> :cn<CR>
        :map <S-F2> :cN<CR>

in my ~/.vimrc


thanks,
-lev



You're welcome
Tony.

Reply via email to