Loading ...
Sorry, an error occurred while loading the content.

Functions

Expand Messages
  • Martin Casado
    Is it possible to use the word presently under the cursor in a function? Somewhat like keywordprg, but not passed to an external script/program. Thanks in
    Message 1 of 12 , Jan 31, 2001
    • 0 Attachment
      Is it possible to use the word presently under the cursor in a
      function? Somewhat like keywordprg, but not
      passed to an external script/program.


      Thanks in Advance,

      - M
    • c928400@student.dtu.dk
      ... Something like ... or ... See :h for details and differences. Peppe -- Before you criticize someone, walk Preben Peppe Guldberg __/- __
      Message 2 of 12 , Jan 31, 2001
      • 0 Attachment
        Thus wrote Martin Casado (e001247@...) on [010131]:
        > Is it possible to use the word presently under the cursor in a
        > function? Somewhat like keywordprg, but not
        > passed to an external script/program.

        Something like

        :call MyFun(expand("<cword>"))

        or

        :call MyFun(expand("<cWORD>"))

        See ":h <cword>" for details and differences.

        Peppe
        --
        "Before you criticize someone, walk
        Preben "Peppe" Guldberg __/-\__ a mile in his shoes. That way, if
        c928400@... (o o) he gets angry, he'll be a mile away
        ----------------------oOOo (_) oOOo-- - and barefoot." --Sarah Jackson
      • Tony Berkopes
        Hello, I am new to vim and have a few questions. My .vimrc is becoming quite large. Is there a way to cut out the parts that will not change, like functions,
        Message 3 of 12 , Jan 31, 2006
        • 0 Attachment
          Hello,
          I am new to vim and have a few questions. My .vimrc is becoming
          quite large. Is there a way to cut out the parts that will not
          change, like functions, some maps, or anything that probably will not
          change into a separate file. Then source that file from .vimrc to cut
          down on the clutter?

          Does anyone have problems remembering what your maps are? I have a
          growing number of "map <leader>v do something", plus the Fx keys. How
          are these remembered?

          Thanks
          TonyB
        • John Love-Jensen
          Hi TonyB, ... HTH, --Eljay
          Message 4 of 12 , Jan 31, 2006
          • 0 Attachment
            Hi TonyB,

            :help :source

            HTH,
            --Eljay
          • Benji Fisher
            ... is the syntax to create the top-level menu MyMaps with the item Foo that inserts a new line containing the text Foo ; and the menu item shows the keyboard
            Message 5 of 12 , Jan 31, 2006
            • 0 Attachment
              On Tue, Jan 31, 2006 at 08:25:16AM -0500, Tony Berkopes wrote:
              > Hello,
              > I am new to vim and have a few questions. My .vimrc is becoming
              > quite large. Is there a way to cut out the parts that will not
              > change, like functions, some maps, or anything that probably will not
              > change into a separate file. Then source that file from .vimrc to cut
              > down on the clutter?

              :help :source

              > Does anyone have problems remembering what your maps are? I have a
              > growing number of "map <leader>v do something", plus the Fx keys. How
              > are these remembered?

              :menu MyMaps.Foo<Tab>oFoo<Esc> oFoo<Esc>

              is the syntax to create the top-level menu MyMaps with the item Foo that
              inserts a new line containing the text "Foo"; and the menu item shows
              the keyboard equivalent. It is all typed literally. We can be a little
              fancy with the <leader> (assuming you do not change the value of
              mapleader after creating the menu). For simplicity, I will assume that
              mapleader has been defined. (If it is not defined, then vim acts as if
              mapleader="\".)

              :execute 'MyMaps.do\ something<Tab>' . mapleader . 'v' mapleader . 'v'

              :help :menu
              :help mapleader
              :help :execute

              HTH --Benji Fisher
            • Steve Hall
              ... Absolutely, I ve done this for years and find it very helpful. ... I have re-worked the menu (in gvim) and added a shortcut indication beside the items so
              Message 6 of 12 , Jan 31, 2006
              • 0 Attachment
                On Tue, 2006-01-31 at 08:25 -0500, Tony Berkopes wrote:
                > Hello,
                > I am new to vim and have a few questions. My .vimrc is becoming
                > quite large. Is there a way to cut out the parts that will not
                > change, like functions, some maps, or anything that probably will
                > not change into a separate file. Then source that file from .vimrc
                > to cut down on the clutter?

                Absolutely, I've done this for years and find it very helpful.

                > Does anyone have problems remembering what your maps are? I have a
                > growing number of "map <leader>v do something", plus the Fx keys.
                > How are these remembered?

                I have re-worked the menu (in gvim) and added a shortcut indication
                beside the items so that every customized feature and map is navigable
                and documented in case I forget what they all are.


                --
                Steve Hall [ digitect mindspring com ]
                :: Cream... something good to put in your Vim!
                :: http://cream.sourceforge.net
              • A. J. Mechelynck
                ... Write out a vim script of any name (preferably ending in .vim) and source that from your vimrc. My own _vimrc is like this: set nocompatible if has( unix )
                Message 7 of 12 , Jan 31, 2006
                • 0 Attachment
                  Tony Berkopes wrote:
                  > Hello,
                  > I am new to vim and have a few questions. My .vimrc is becoming quite
                  > large. Is there a way to cut out the parts that will not change, like
                  > functions, some maps, or anything that probably will not change into a
                  > separate file. Then source that file from .vimrc to cut down on the
                  > clutter?
                  >
                  > Does anyone have problems remembering what your maps are? I have a
                  > growing number of "map <leader>v do something", plus the Fx keys. How
                  > are these remembered?
                  >
                  > Thanks
                  > TonyB


                  Write out a vim script of any name (preferably ending in .vim) and
                  source that from your vimrc. My own _vimrc is like this:

                  set nocompatible
                  if has("unix")
                  language messages C
                  else
                  language messages en
                  endif
                  runtime vimrc_example.vim
                  source ~/local_rc.vim

                  Notice the last two lines, which invoke two additional files (one
                  distributed with Vim and the other written by me). IIUC there is no
                  practical limit to how far you can "nest" sourced scripts.

                  To have Vim remember mappings, write them down into your vimrc -- or
                  into any vim script sourced by your vimrc, or, for mappings specific to
                  some file types, into filetype-plugins sourced by Vim when needed: you
                  would write the latter with "map <buffer> {lhs} {rhs}" into files named
                  somefiletype.vim (where "somefiletype" is the file type) and placed in
                  the ftplugin subdirectory of a directory (other than $VIMRUNTIME for
                  scripts you write yourself) mentioned in 'runtimepath'.

                  To remember the mappings yourself, follow the KISS rule: Keep It Simple
                  and Stupid. Use the F1-F12 keys in preference to more complicated
                  mappings, and map related functions to a single Fn key with different
                  combinations of Shift and/or Ctrl. (For instance, I use the following
                  mappings for navigating "quickfix" results:

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

                  ).


                  Best regards,
                  Tony.
                • Tim Chase
                  In addition to Eljay s suggestion of checking out the help on the source command (which would be a good way to include ... ... I find that I remember things
                  Message 8 of 12 , Jan 31, 2006
                  • 0 Attachment
                    In addition to Eljay's suggestion of checking out the help on the
                    "source" command (which would be a good way to include ...

                    > Does anyone have problems remembering what your maps are? I
                    > have a growing number of "map <leader>v do something", plus
                    > the Fx keys. How are these remembered?

                    I find that I remember things I use regularly and forget things I
                    don't. If you're not using them regularly, they're easy to
                    forget. It may be handy to have them predefined, and it's only a
                    ":map" away to see what sorts of mappings you have available. I
                    still (2 yrs after I learned about them) have a little scrap of
                    paper taped to my monitor with the help for i_ctrl-A and i_ctrl-@
                    because I never remember exactly which is which and it's faster
                    to look in the corner of my monitor than go scrounging through
                    the help, or arbitrarily use one and get an unexpected behavior.

                    Because I don't use the same mappings regularly, I rarely do any
                    persistant mappings. I may create a mapping on the fly to do
                    something in a particular document, but I generally consider it
                    disposable.

                    Most of the mappings I *do* do provide an expected behavior with
                    a particular syntax that Vim doesn't support natively. E.g. the
                    "[[" command (to go the the beginning of the enclosing function)
                    works wonderfully in C/C++/Java if you have the opening
                    curly-brace at the beginning of the line. However, for my VB
                    code at work, I have the "[[" mapped to search backwards for a
                    particular regexp that matches a VB function definition. Same
                    functionality, diff. implementation.

                    Not having piles of mappings also helps when jumping between
                    machines...I don't have to synchronize my mappings between
                    machines. The venerable Tim O'reilly wrote on why he uses vi/vim
                    rather than Emacs and states that he switched at one point when
                    his huge custom-tweaked .emacsrc got hosed and his productivity
                    was paralized. I kinda shy away from hanging my productivity on
                    a .vimrc file that can get out of sync or get hosed.

                    I guess it boils down to each person remembering things in their
                    own way...try and find what works for you, and hopefully it
                    helps. I just have a bad memory :)

                    Just my thoughts on the matter.

                    -tim
                  • Walter Cazzola
                    ... interesting, could you post your staff for the newby like me? thank you Walter -- Walter Cazzola, PhD - Assistant Professor, DICo, University of Milano
                    Message 9 of 12 , Jan 31, 2006
                    • 0 Attachment
                      On Tue, 31 Jan 2006, Steve Hall wrote:

                      >> Does anyone have problems remembering what your maps are? I have a
                      >> growing number of "map <leader>v do something", plus the Fx keys.
                      >> How are these remembered?

                      > I have re-worked the menu (in gvim) and added a shortcut indication
                      > beside the items so that every customized feature and map is navigable
                      > and documented in case I forget what they all are.

                      interesting, could you post your staff for the newby like me?
                      thank you
                      Walter

                      --
                      Walter Cazzola, PhD - Assistant Professor, DICo, University of Milano
                      E-mail cazzola@... Ph.: +39 010 353 6637 Fax: +39 010 353 6699
                      · · · --------------------------- · · · --------------------------- · · ·
                      ... recursive: adjective, see recursive ...
                      · · · --------------------------- · · · --------------------------- · · ·
                    • iler_ml@fastmail.fm
                      ... I myself have same problem, and I made up my working low-tech solution that goes like like this: map ? :echo a - do this n b - do that etc
                      Message 10 of 12 , Jan 31, 2006
                      • 0 Attachment
                        > >> Does anyone have problems remembering what your maps are? I have a
                        > >> growing number of "map <leader>v do something", plus the Fx keys.
                        > >> How are these remembered?

                        I myself have same problem, and I made up my working low-tech solution
                        that goes like like this:

                        map <leader>? :echo "\\a - do this\n\\b - do that etc etc\n"<cr>

                        So when I need to remember my maps, I press \?
                        (assuming <leader> is \) and I get list of my mappings.

                        Yakov Lerner
                        --

                        iler_ml@...

                        --
                        http://www.fastmail.fm - mmm... Fastmail...
                      • Steve Hall
                        From: Walter Cazzola, Jan 31, 2006 9:22 AM ... This is the Cream overlay (http://cream.sf.net), which might be more overhead than you want from Vim. But you
                        Message 11 of 12 , Jan 31, 2006
                        • 0 Attachment
                          From: Walter Cazzola, Jan 31, 2006 9:22 AM
                          > On Tue, 31 Jan 2006, Steve Hall wrote:
                          > > >
                          > > > Does anyone have problems remembering what your maps are? I have
                          > > > a growing number of "map <leader>v do something", plus the Fx
                          > > > keys. How are these remembered?
                          > >
                          > > I have re-worked the menu (in gvim) and added a shortcut
                          > > indication beside the items so that every customized feature and
                          > > map is navigable and documented in case I forget what they all
                          > > are.
                          >
                          > interesting, could you post your staff for the newby like me?

                          This is the Cream overlay (http://cream.sf.net), which might be more
                          overhead than you want from Vim. But you could easily use the menu
                          concept (:help sub-menu-priority is the best example).


                          --
                          Steve Hall [ digitect mindspring com ]
                        • Luc Hermitte
                          ... Sometimes (often?), plugins and ftplugins make more sense. HTH, -- Luc Hermitte http://hermitte.free.fr/vim/
                          Message 12 of 12 , Feb 1 4:49 PM
                          • 0 Attachment
                            * On Tue, Jan 31, 2006 at 07:37:39AM -0600, John Love-Jensen <eljay@...> wrote:
                            > :help :source

                            Check also:

                            :h plugin

                            Sometimes (often?), plugins and ftplugins make more sense.


                            HTH,

                            --
                            Luc Hermitte
                            http://hermitte.free.fr/vim/
                          Your message has been successfully submitted and would be delivered to recipients shortly.