Is there a standard public-friendly keyset available for vim? - windows

I've seen several bits of documentation on how to do ad-hoc vim key bindings.
Since I'm trying to pitch vim (or, to be more accurate, the idea of free 'nix text editors in general) to a coworker, I'm hoping to make it as painless for them as possible.
In contract to that ad-hoc approach, is there a wholesale block of widely accepted text I can throw into a .vimrc file in order to make most "standard" mac or windows keyboard shortcuts behave roughly the way they would on those systems? (For example, ctrl-s for save, ctrl-f to bring up a search, ctrl-v to "put" a string, ctrl-w to close, ctrl-q to quit, or some subset/superset of those ...)
Thanks for any help. I'm happy to build these on my own if needed, but I figured that if I'm documenting it for future use, I might as well link out instead of rebuilding the wheel.
I did a bit of looking around before asking, but if this is a duplicate, feel free to merge.

mswin.vim provides many typical Windows keybindings, so that any Notepad user will feel almost comfortable with Vim. You enable that by putting
source $VIMRUNTIME/mswin.vim
into your ~/.vimrc, cp. :help mswin.vim.
:set insertmode
(or starting via evim) almost turns Vim into Notepad by defaulting to insert mode :-)
The downside is similar to training wheels for bikes: It allows for some quick successes, but overall takes longer to become proficient. (I personally started out with mswin.vim, and gradually reduced the mappings.)

There is cream. It's a vim plugin that starts in insert mode and rebinds ctrl-c to copy, ctrl-v to paste etc...
http://cream.sourceforge.net/home.html
It's intended to make things easier for people used to editing in more conventional editors. That said I never used it. I learned vim the hard way and don't regret it.

Related

Keyboard shortcut for a repetitive sentence

I'm currently saving 200/300 PDFs a day (work related), they all have a sentence in that's the same, I'm unable to use Ctrl C/V as I have to copy other parts before saving.
Is there a way for me to have a keyboard shortcut that puts the sentence in for me when saving the file?
(Windows 7 and limited admin access)
Many Thanks,
L
You could use a Macro editor which records keystrokes and repeats them.
This one is a free portable example (doesn't require an installation).
https://portableapps.com/apps/utilities/tinytask_portable
On windows 7 you can only have one Item in the Copy&Paste Memory, so there is no other easy way than to simulate keyboard input. You can also "Drag and Drop" the sentence from somewhere else (like a website) by selecting it and then clicking on it and dragging it into the Document.
Maybe that works better for you.
I'm not sure I've understood completely your problem, but in all likelihood a clipboard manager would suit your case.
They don't (usually) allow you to have a sentence inserted automatically before saving, but they let you save many instances of "clippings" and paste them conveniently.
There are a lot of them, I personally like Clip and used also ClipX and Ditto.
Many of these clipboard managers include features to associate a specific hot key to insert a specific snippet of text.
There also programs that are focused specifically on that HotKey -> specific snippet functionality, or that include it among others.
Also, if clarified what software you're using to do these "pdf savings", it would help (it's possible that it does include facilities to include a sentence before saving).
And in any case you can almost for sure do what you want with a macro/scripting utility such as AutoHotKey (but it would usually be pretty complex if you're not already familiar with it).

Is there an Om Writer-style front end for gvim or macvim

Here's my dilemma: I love the features of vim, but I also like using Om Writer for its' approach to enhancing relaxation and creativity. For those unfamiliar, Om Writer blanks out all other programs, fills the screen with a complete blank page and has music and sounds that play. It even has the _ character as the cursor to avoid the wall style | character at the end of the line!
So I use Om Writer for some things, but I sure miss all of the neat things you can do from the keyboard in vim. Om Writer requires a lot of mousing around. So I have looked around and found nothing, but I was wondering if there might be such a thing as an Om Writer-style front end for Vim?
And if not, how difficult might such a thing be to program for MacVim on Snow Leopard? (I am at the kindergarten level as a programmer, but I would considering paying someone to do it if the job wasn't terribly involved.)
I remembered one plugin but a quick google returned two other projects. Playing music, though, is kind of the absolute opposite of Vim's philosophy but nothing stops you from launching a playlist in iTunes.
And I'll spare you my rant about those "distraction-free" editors.
I second romainl's recommendation of vimroom; I've tried it and found it quite nice. Additionally, the shell.vim plugin has a fullscreen mode that blanks out window title, taskbar, etc.

Carbon Emacs: no `focus' in minibuffer on incremental search

Good day all,
my trusty old Carbon Emacs has developed a frustrating habit: when I use C-s, the minibuffer prompts for a search string, but it is not focussed. Obviously, typing in a string doesn’t do anything. I have no clue which buffer has the focus at that time.
When I press C-g, the search is cancelled as usual. When I press Return, the I-search prompt turns into a Search prompt, and the minibuffer regains focus. Update --- When I type C-w, the current word is set as search string, as usual, and subsequent C-s advance the search as expected.
AFAIK, I have not changed anything in the .emacs file, not customized anything. The version of emacs is the same, and the OS as well. This behavior also survives a restart of emacs. Even emacs -q doesn’t solve it.
Update -- turns out that `focus' is not the right word; with i-search, the focus stays on the buffer you're searching in, but the mini-buffer echos the search term. Well, it should, but it doesn't. So, the following snippet is looking in the wrong direction.
I’ve tried this snippet to regain focus on the minibuffer:
(defun minibuffer-refocus ()
"Refocus the minibuffer if it is waiting for input."
(interactive)
(when (active-minibuffer-window)
(message "")
(select-window (minibuffer-window))))
(global-set-key (kbd "C-M-g") 'minibuffer-refocus)
But to no avail. It works like a charm in other cases, but not for the incremental search... Update -- That was to be expected.
Is there anyone that has any idea what’s going on, or has tips to hunt it down? This is really annoying...
Details
GNU Emacs 22.3.1 (i386-apple-darwin9.5.0, Carbon Version 1.6.0) of 2008-11-01 on leopard.local
OSX 10.6.7
C-s runs the command isearch-forward
Update
the good news is that is is solved. The bad news is that I don't know how :-(
Update
The bad news is that it is back again. I also realize that the above snippet does really help because the mini-buffer doesn't really get focus.
Note that when you ran C-s, M-e provides a means to edit the searched pattern, but it is much less efficient than having C-s work as expected...
I face the exact same issue (on two different Lion machines), and I do not understand what is going wrong, yet I can tell you that:
I use several "Input methods", i.e., several keyboard mappings: French and US Extended. I have selected the OS X option that allows to have keyboard mappings that depend upon the current application (I typically use US for Emacs, and French for mails for instance).
The French mapping works properly,
The US extended mapping fails as you described it,
In the same Emacs session, going from on to the other preserves that invariant: French works, US Extended is broken,
The good news is: US not-extended seems to work properly! Maybe (maybe) C-s is some prefix on OS X in the US extended mapping for some multi-key character, and some very bad interaction are started between OS X, maybe expecting for the next character part of the multi-key sequence, and Emacs which steals them from it. Wild guess.
The good news is that it works again as expected. The bad news is that I don't know what fixed it.
I do think that #vpit3833 was pointing in the right direction with the recursive edit suggestion; I was answering another question about the Alt and Esc keys and after trying out some things, like doing ESC-x and similar combo's, the incremental search started working again.
Sorry I have no real answer, but at least I can close this topic.
This is solution that work for me. I post it because I search for solution and couldn't find it.
(defun isearch (arg)
(interactive "MI-search: ")
(select-window (minibuffer-window))
(isearch-forward))
(global-set-key "\C-s" 'isearch)
I'm using GNU Emacs on Ubuntu.
EDIT: but if you use it you will not be able to search minibufer. Because of this feature you have no focus in minibufer when you search. For example you can do something like M-x C-s to search for functions names. And if you have focus in minibufer you can't do that.
I hit exactly the same problem, quite out of the blue, and discovered (as someone already pointed out) that it is something to do with OS X's own keyboard/input methods. I had been using the regular US keyboard, but then changed to the Unicode keyboard, which is when the problem arose. Once I went back to the regular US keyboard, i-search worked as expected. I got the same anomalous behavior with the US-extended keyboard.

Windows text editor that shows/hides lines based on RegEx or Grep syntax?

One of my application components produces some extremely hairy log files. They require a lot of poking and prodding before they produce useful information. I'm on the hunt for a text editor for windows that will let me enter text in either RegEx or Grep-style syntax, and automatically show/hide the relevant lines.
Does anyone know of a text editor that has this feature?
Thanks!
IVR Avenger
I know it's answered already, but http://glogg.bonnefon.org/ is the perfect answer for this. Couldn't live w/o it.
I would recommend Notepad++ as far as a good all-around Windows text editor is concerned - it is very extensible and includes just about every power feature you need to wade through data logs. If your log files are in a well-defined format, you can even use the built-in language editor to define a custom visual scheme for your logs - easier on the eyes.
-matt
GVim with for example, :g command. There are also plugins that allow entering search criteria, and they show relevant lines, and fold everything else.
Emacs, of course (occur), but I think pretty much every editor will do this.
Another option is SlickEdit using it's "Selective Display..." option
Although it wont show/hide based on a regex, Textpad will allow you to search and produce a hyperlinked result file with the lines that will allow you to click into the actual log. Consider the benefit: You can keep the filtered results up on your left monitor, and you can click into the full files and show them on your right monitor to see the context.
SPFLite is free and does just what you want. At least the IBM SPF and ISFP (used on IBM mainframes as part of the MVS operating system) that it emulates is just what you want.
From what I have tried, SPFLite will probably do the job. It can X (exclude) all lines from view, or eXclude lines with a given character or phrase (optionally starting in a certain column) from view. Or after eXcluding all lines, you can display, by Finding, characters or strings (optionally starting in a certain column). I think it also has a macro capability. The original does, and I think this Lite does as well. How robust I do not know. The original could create interactive screens and programs using the MVS TSO Command Language.
I found SPFLite at http://www.spflite.com/
I found that this interface is not so easy to use, but one gets used to about anything if necessary.

What's the point of viEmu plugin for Visual Studio?

This may sound a bit provocative but it actually is a real question. Feel free to edit if you don't like the tone.
Now, as much as I understand vi from my short experience with it like 10 years ago, it's a primitive text editor with one editable line at the bottom of the screen created before the scrollbars were invented, with some crazy shortcuts to overcome this limitation.
Can somebody explain me how one can be more productive with it than with, say normal VS.NET editor? Moreover, why would anybody want to use viEmu which supposedly turns your VS.NET into an ancient vi?
I'm willing to give it a try but I need some motivation to overcome the learning curve.
It honestly sounds like you have never seen someone use Vi who is truly proficient in it. When you normally use Visual Studio you frequently will move your hand over to your mouse, click through options, dialogs, classes, etc.
With ViEmu your hand never leaves the keyboard. You are compiling, switching files, highlighting groups of text, fixing indentation, performing complex motions on your code and running regular expression searches in seconds. For people who are fast typists it allows you to achieve a speed for tasks you would not be able to otherwise.
Many people will counter this by saying things like, "Most of my development time is spent thinking. The extra speed I gain from using tools like these is negligible.".
That is a non-argument in my opinion. It is true, for most large programming tasks you spend far more time planning and thinking then you do actually slinging code. But that doesn't mean that being able to express yourself through your IDE 2x faster doesn't have an impact on your productivity as a programmer.
The viEmu page itself has a pretty good article that might help to answer your question: Why, oh WHY, do those #?#! nutheads use vi?
I've spent the last couple months trying to teach myself to use vim "properly" and now I can hardly stand using other editors because they seem underpowered and clunky. For a random example, imagine you have a line of code that looks like this:
$welcomeMessage = "Welcome to SiteName!"; // shows at the top of homepage
In a normal editor, how would you change the string? You'd probably have to reach over and grab your mouse and carefully select it, or you'd move your cursor inside the first quotation mark, and hold down Shift and the right-arrow until you got to the closing quotation mark.
In vim, with my cursor anywhere in-between the quotes, I type ci" and it erases everything inside the quotation marks and puts me into insert-mode so I can type the new value I want. My hands didn't even have to move from my normal typing position.
There are so many things like this, I think you really have to spend a while using the editor to understand how powerful it is. It's very slow and hard to use at first, that's why a lot of people try it for a short time and think "this is dumb, everything is way harder", but after a while you start thinking in terms of the motions, it all starts to become automatic and it's much, much faster than using a "normal" editor. As I said, I can't go back now.
I've also had trouble understanding why people choose vim as their editor, even though I was using it from time to time, until I've finally "got it". I think most explanations of "why?" fails, because they fail to show couple crucial points. To explain those points, first you need to understand that in vim you are manipulating text primarily being in command mode. Ie by default your key presses are commands, and do not usually insert any text, unless those commands (like append, insert, change) switch to insert mode. This lets you navigate and edit your text easily without ever touching your mouse or moving your hands away from "editing pose".
Now the crucial points are:
Vim commands are divided into nouns, verbs and modifiers.
Editing is performed by combining them.
And this is what gives vim the power. To ilustrate the point, here are some most used commands:
Nouns: word, sentence, block, quotes and braces.
Verbs: cchange, insert, visual, delete
Modifiers: inside, around, till
And to ilustrate how you can mix them:
Want to change a word? cw
Same, but cursor in the middle of the word? caw
Change text inside quotes? ci", also change quotes? ca"
Delete function body? di{
Delete up till first comma? dt,
Delete up till second comma? d2t,
Jump to first comma? t,
Select word? viw
Also notice how all commands nicely translate into natural language:
delete word
change inside {
In vim if you learn a new verb, noun or modifier, you can easily mix and match with what you already know. So basically learning just one thing, you learn how to do a lot of different things.
Another great thing is that vim remembers what commands you have used, and you can repeat the sequence just by pressing .. For this post I've had to surround a lot of letters with <kbd> tag. But I've did that only once, and then just went over each letter and pressed ..
And that's basically the thing you "need to get" to understand the power of vim and become advanced user overnight.
P.S. if you don't like vim because it's console based and want a modern text editor, then I suggest looking into Sublime Text editor, which is a great editor and also supports vim mode.
P.S.2. I also recommend to map Esc key to jj and kk, which makes things a lot easier.
You are wrong about "one editable line at the bottom of the screen." All the text in the window is editable. And it does scroll (all versions) and in the case of gvim, has scrollbars.
Maybe you inadvertently put it in "ex mode". This is easily done and can be confusing.
Another answer got me thinking that watching some skilled editing using vim would be pretty revealing so I dug up this video showing basic and more advance motions while coding. This person could get even a bit efficient using some marks, etc but it gives an idea.
http://www.youtube.com/watch?v=FcpQ7koECgk&feature=related
If you need inspiration or want to see someone who really knows what they are doing with Vim, check out Gary Bernhardt's String Calculator Kata In Python, look at him go! http://vimeo.com/8569257
I think they have a long and acceptable answer for your question on the viEmu hompage:
One other even more powerful example: let's take the 'ce' command, which is composed of 'c' and 'e'. The 'c'hange command deletes the range specified by the next motion command, and also enters insert mode. It's the same as 'd', but with the distinction that it enters insert mode, instead of staying in normal mode. The boon is that the text you type in the next (short) input session is also part of the command. So if you do 'ceHello>', what you do is replace from the cursor to the end of the word by 'Hello', and the '.' command afterwards will work exactly like that: replace up to the end of the word with 'Hello'.
From:
http://www.viemu.com/a-why-vi-vim.html
I have viEmu installed ~half year ago. But I have to say (maybe without strong linux experiences) I've never used it. Too alien, too far, too complex.
So IMHO viEmu it's a great technical&historical challenge but no more for the 95% of the developers.
Basically with Vi (or ViM) you get faster because you don't need to touch the mouse and the key-map is improved (this represent learning curve cost but worth the effort) for do any text manipulation in a very easy way once that the fundamentals are learned.
Top 10 things Vi user need to know about Vim
I have not experience with VS.Net but I guess it has the same features that any other IDE has.
I have found that learning the all the key commands of the editor in my IDE was a sufficient replacement for Vi. Things like renaming, indenting, formatting, moving lines and that kind of stuff.
So I guess the major win would be for someone who already know Vi to be productive without having to learn VS.Net.
But then again, Vi has some truly esoteric but powerful features that probably can't be matched by you standard IDE editor.
I think you really should give Vim a try.
If you quickly tried Vi ten years ago, I may understand you didn't appreciate it. It's not really user-friendly at first sight. Actually its real power is revealed when you start feeling comfortable with the movements and start making it your own with customisation.
Once Vim is familiar to you you may understand why it deserves to be learnt.
I actually use VS only for debugging these days. Coding with vim (real vim, not viemu) is just a better experience.
Now, I am not going to claim that using one over another makes any difference in productivity - after all I spend most of my time trying to figure out how to solve a problem - entering the code is the easy part.

Resources