Does anyone know how to change vim's default mode? Its default mode is command mode, but could I change it to insert mode?
Just add the following line to your vimrc:
start
Vim's default mode will be changed to Insert mode. Just press Esc to enter Command mode.
You can try the 'insertmode' option (add set insertmode to your .vimrc file), although I recommend that you learn the standard vi operation, because not all vi-like editors support this mode of work.
cheers,
mitch
If you really want an editor that starts out in insert mode, perhaps vim is not the editor for you.
Most editors that aren't based on vi behave the way you want. Emacs is very powerful, but it may be too complicated for your needs. Nano (man nano for info nano for more information) might be a good choice. There are other possibilities.
vim really isn't designed to be used that way. As others have said, there are ways to force it to start up in insert mode. (I've been using vi-style editors for decades, and I didn't even know about :set insertmode until now.) But it's awkward to use.
My advice: either (1) use an editor that behaves the way you want, or (2) spend some time learning to use vim in its default configuration, and see if you can get used to it.
One big advantage of vim's separation of insert and command modes is that the command mode can use letters as commands; modeless editors generally have to use control keys or function keys to execute commands.
Update (a decade later): vim has an option -y that starts it with insertmode enabled. evim is equivalent to vim -y, and eview to view -y. From the man page (emphasis added):
eVim starts Vim and sets options to make it behave like a modeless editor. This is still Vim but used as a point-and-click editor. This feels a lot like using Notepad on MS-Windows. eVim will always run in the GUI, to enable the use of menus and toolbar.
Only to be used for people who really can't work with Vim in the normal way. Editing will be much less efficient.
The 'insertmode' option is set to be able to type text directly.
Mappings are setup to make Copy and Paste work with the MS-Windows keys. CTRL-X cuts text, CTRL-C copies text and CTRL-V pastes text. Use CTRL-Q to obtain the original meaning of CTRL-V.
You can use
vi -cstartinsert
or
vi -cstart
That launch vi and put it insert mode. You can do an alias to that if it's really usefull (I still understand why you want that anyway). You can also look at this tip.
"Cream" is a project that aims to make Vim easier to use. By default everything you do in Cream is in insert mode, I believe:
http://en.wikipedia.org/wiki/Cream_%28software%29
Related
Using all of Vim, Xvim(for Xcode) and Ideavim(for IntelliJ), I'd like to be able to use the default keybindings while in insert mode rather than Vims. I've been using Xcode for quite some time now and have gotten quite good at typing with the standard Xcode bindings but Vim bindings are so much better while not in insert mode.
I know you can do .vimrc settings such as
:im <C-D> <esc>xa
to emulate these functions, but this still leaves problems with slightly different behaviors as well as losing functionality where these commands have multiple uses. IE ctrl+n is both down while typing and next while scrolling through autocompletions. Custom bindings in .vimrc removes the ability to scroll through autocompletions.
Using
:im <C-N> <NOP>
enables scrolling through autocompletions but still doesn't let it function as down.
Anybody know how to solve this?
If you really want to, you can put
nnoremap i :action VimPluginToggle<CR>
into your ~/.ideavimrc, then in Preferences => Keymap, find the Vim Emulator item and assign the shortcut ESC to it. This when instead of entering insert mode, you'll be disabling IdeaVim, and hitting ESC will re-enable it.
I tested this briefly and it does seem to work at least at a superficial level, although you lose the changing caret style as an indicator of which mode you're in. I'm not sure that's a good idea, however. Probably better to work within the system as designed and set up the bindings you want.
While vim's way of doing things is generally good, I feel like there are aspects that really get in the way as somebody who is not completely committed to vim for text-editing.
This means that I am hitting Esc+/ and typing slashes into files in Sublime Text, and hitting Ctrl+F in vim, scrolling down a page.
Similar things happen with Ctrl+S and :w and custom mapping ; to : still doesn't make it as convenient and fail-safe as Ctrl+S. Not to mention in PuTTY, Ctrl+S does something rather upsetting (it suspends output from the terminal till Ctrl+Q is pressed). Basically, IMHO some things (like switching to a "find mode" and saving the file) are good to attach to a global left-hand home-row shortcut chord rather than requiring the user to mess about in a modal command line. It simply is too often used to subject the user to these mode changes. I suppose this isnt a legitimate complaint because the entirety of vim is constructed around the modal concept, and these functionalities are a result of that.
In any case I'd like to make it a bit easier on my brain because I've tried for a while now to keep it all intact and it's simply too much (I have more or less internalized the switching between Ctrl on a windows machine on a desktop keyboard and the use of the thumb for the Cmd on my Macbook, but this modal text editor business seems to be too much). It did not take too much deliberation for me to decide that global homerow key chords are simply more intuitive.
Mapping Ctrl+S to :w is trivial, so the question here is about the find mode. I want to bind Ctrl+F to put me in find mode, but repeating it should not type slashes into the find command. Can this be done? Is there perhaps a colon-command that when executed simply drops me into the current find-command-buffer-thing?
In your .vimrc add:
inoremap <C-f> <Esc>/
noremap <C-f> <Esc>/
In whatever mode you are in, this will put you in "find" mode (it actually just types a slash in the command line which you can use to search). With these bindings it will work for all modes, even if you are in insert mode.
do you want this?
nnoremap <c-f> /
if you like you can also try
nnoremap <c-f> q/
the 2nd mapping brings you to a search history window. you could choose previous search keywords/patterns. also available to type new pattern (by pressing i)
btw, there is no find mode
Mappings can be defined separately for the different modes in Vim, see :help map-modes. This automatically takes care of your proposed <C-f> mapping: Initially, you're in normal mode, then the search pattern is entered in command-line mode.
If you so far only occasionally use Vim, and find it too "different", several things may make the switch easier:
easy Vim (evim or vim -y) defaults to insert mode
on Windows, :behave mswin and the $VIMRUNTIME/mswin.vim script create some common Windows shortcuts
graphical GVIM has menu items like Edit > Find... and toolbars.
Some things like the flow-control freeze on <C-s> in terminals are unfortunate, mostly historical accidents; you can't blame Vim for those.
You don't need to map anything. / is expressive enough and is definitely not slower than <C-f>. Same for <C-s> which, despite a certain familiarity, is not much better than :w<CR>. You are learning a new tool, remember?
What you should focus your efforts on is getting confortable with Vim's modality. The simple fact that, for you, doing a search involves hitting <Esc> is a sign that you didn't get that part. Your other comments on using Vim shortcuts in ST and ST shortcut in Vim are not good signs either and the part where you complain about having to adjust to your Mac's Cmd is the icing on the cake, IMO.
It may sound brutal but, from your question, it seems like you are doing too much at the same time, without organization and for, probably, no good reasons.
Switching from Windows to Mac OS X and switching from ST2 to Vim at the same time is sure to be confusing and I suggest you slow down a little and make a choice before you loose your mind and waste more of your time.
Which leads me to this: Why do you use a Mac and why are you using Vim?
Windows is a fine OS. Sublime is a fine editor. Even if you switch to the Mac, Sublime works very well there. So Why Vim?
If you are tired by some Sublime limitations and want the awesome power of Vim, fine. But you must wrap your head around its modality and awkwardness and accept to change your habit.
If you don't approach Vim with more flexibility, you'll never get full benefits.
If you decided to use Vim because it is trendy, I'll respectfully suggest you to stop there and go back to Sublime. Vim is weird, Vim is different, Vim is huge, Vim is a rabbit hole… if you are not ready to work with it and insist on not accepting its core design, you won't get far so why bother? You can pretty much live all your professional carreer without ever touching Vim. There's no shame in that.
Remapping / to <C-f>, on the other hand…
The question is self explanatory, but I haven't found a single resource that explains what the difference is after an hour of searching. After poking around a little bit in both, it appears that gVim and gVim easy are identical.
Gvim easy is started and locked in insert-mode (every character you type is printed like a simple notepad).
Standard gvim starts in normal mode and you have to toggle between normal/insert like all other vim.
From help:
Easy mode. Implied for |evim| and |eview|. Starts with
'insertmode' set and behaves like a click-and-type editor.
This sources the script $VIMRUNTIME/evim.vim. Mappings are
set up to work like most click-and-type editors, see
|evim-keys|. The GUI is started when available.
{not in Vi}
gVim-Easy, which is installed with gVim, has all the functionality of
normal gVim but lacks modes. This is especially useful for begginers
and people who do not want to, or do not have the time to, learn how
to use gVim. Users can benefit from gVim's superior syntax
highlighting and auto-indentation while not having to have to learn
the, often deemed complex, command set of gVim in order to edit a
simple document. It is recommended that readers of this tutorial at
least try to learn how to use gVim in normal mode, the learning curve
is steep, but, the benefits in speed and usability this confers is
worth the investment.
Read here
gVim Easy: gvim.exe -y (pass a parameter y)
gVim: gvim.exe
It seems that Insert and Replace are available modes, and command mode is missing. And at first glance it appears to have lost the ability to save a document using keystrokes - the File menu shows only ":w" for Save and without command mode, the command simply isn't there. What isn't shown however is Alt-F followed by S - this works, although also missing is the status line confirmation of the file being written.
I am giving Vim a serious try for coding my Python apps.
However, Vim is proving to be so flexible, I was thinking to use it as my main editor at work for writing lawyer/legal documents. The problem is that my mother tongue is not English but Greek. So, I have mapped Alt+Shift to change between English and Greek keyboard layouts.
The issue I am experiencing is that I have to press Alt+Shift each time I want to enter a Vim command (to return back to English). So it is Alt+Shift when I type my document, then Alt+Shift again to enter Vim commands. This defeats the purpose of using Vim, at least in terms of speed of use.
So my question is simple: Is there any way to avoid those frequent Alt+Shift keyboard layout changes just for entering Vim commands when writing in a non-Latin language (e.g., Greek)?
This problem can be solved with the help of the keymap option.
It allows to define an alternate keyboard mapping to use in modes
requiring text input.
To switch between the default and alternate keymaps while in Insert,
Replace, or Command-line mode (but not Normal mode), use
Ctrl+^ (Ctrl+6).
Changing the keymap affects text input only; keyboard behavior in
Normal mode stays the same regardless of the current keymap setting.
One can leave Insert mode writing in Greek and immediately use
Normal-mode keybindings without switching to a different keyboard
layout. If one then returns to Insert mode or, for example, starts
a search by typing /, Vim switches the keymap back to Greek
automatically.
The current keymap used in those text-entering modes is remembered
between switchings to other modes. The only exception from this
behaviour is made for Command-line mode which always starts with the
default keymap, since most of the time it is required to type an Ex
command (in ASCII). With the keymap option set, user is supposed
to work in Vim keeping system keyboard layout set to English while
switching Vim keymap with Ctrl+^ (instead of
the system-wide layout switch).
To enable, say, the UTF-8 Greek keymap permanently, add the following
line to your .vimrc file.
:set keymap=greek_utf-8
There are many predefined keymaps for a large set of languages, you
can browse them all in Vim itself using :e $VIMRUNTIME/keymap. Note
that usually there are several keymaps provided for one language which
differ only by character encoding, so that anybody could choose one
that suits their configuration.
I also recommend setting the options below to specify whether the
keymap should be enabled by default in Insert mode and when entering
a search pattern:
:set iminsert=0 imsearch=-1
See :help iminsert and :help imsearch for the detailed explanation.
There is also a special language mode that, if I am not mistaken,
was introduced in Vim earlier than keymap. It allows to achieve
the behaviour similar to the one provided by keymap through manually
specifying letter pairs that correspond to the keys on keyboard in
a long string to be saved in the langmap option. Personally—my
native language is not English, too—I prefer (and recommend) using
the keymap way instead.
In conclusion, I should emphasize that all of the above is equally
applicable to any other language Vim has (or can be configured to
have) a keymap for.
See also my answer to a similar question ‘Vim “annoyance”
with keyboard layouts’ that has been asked since I originally
gave this answer.
There are important features of Emacs which are missing in Vim, such as the comint mode, and there are no scripts/plugins which can replace them.
There are also benefits of Vim over Emacs, such as modal editing and generally better default shortcuts. However, Viper mode gets me both. Vimpulse also enables visual mode.
Unfortunately, no mode can make Emacs work as fast as Vim.
So I mostly learned Vim-in-Emacs. What Vim features am I missing?
I'm a regular vim user but not an emacs user and haven't used vimpulse to confirm this.
But browsing the vimpulse code below I see no mention of text objects.
http://www.emacswiki.org/cgi-bin/wiki/vimpulse.el
Vim introduced some very useful idioms for selection and movement that aren't in regular vi
cat 'cut around tag' for xml/html tags
diw 'delete in word'
di( di" delete text within a "" () etc.
in the vim help see :he text-objects for more.
Unfortunately, no mode can make Emacs work as fast as Vim.
If you mean that the emacs startup time is poor, you can cut it down dramatically by having an emacs session permanently open, and use gnuclient/emacsclient whenever you need to edit a file.
http://www.emacswiki.org/emacs/GnuClient
One vi feature that I miss in emacs is the . (dot) command that repeats the last edit. There is dot-mode.el which implements C-. to simulate this but it didn't always work for me (I am not proficient in elisp to figure out why).
Even viper doesn't implement this command exactly like vi does (last time I checked), and even if it does, I don't think that is enough for me to start using viper.
To get a complete list of what vimpulse may be missing type
:helpgrep not in Vi
Every feature in the help that is not vi compatible will be listed.
Theres about 700 matches.
Of course there will be a lot of duplicated functionality
Vi motion everywhere - in Vi you can always navigate using the same shortcuts, whether you are inside a directory listing, a help file, a write only file or something you're allowed to edit.
Correct visual and delete behaviour - very similar to emacs marking but idiomatically different, so difficult for a Vi user to retrain. If you're already used to the emacs marking you're not really missing anything.
Correct escape behaviour - should cancel all other modal activity and return you to command mode. Again, if you're comfortable in emacs you're probably used to having modal inputs and such anyway.
The obvious chestnuts about Vi being deployed on every nix system in the world (Gentoo purists correct me?) - not a very strong argument in my eyes anyway.
Those are the ones that sprang out during my use of emacs+viper.
Vim macros don't seem to work with viper/vimpulse:
Vim macros don't work when using viper + vimpulse in Emacs
(Btw, the killer emacs feature that makes me care about vim/vimpulse is that different frames can edit the same file. It's like having a split where the two pieces can be in different windows. If anyone knows how to accomplish that in vim, you'd be my hero.)
Incremental search using / and ? is missing.
Being a lover of emacs as an OS and vi as an input model, naturally I wanted to love viper. However within two seconds of using it I had to give it up: viper does not support C-[ as a substitute for the escape key–which is an essential shortcut for the most frequently used command in vi.