What is your most productive shortcut with Vim?
stackoverflow.com
stackoverflow.com
" make space execute the 'q' macro (press qq to start recording, q to stop,
" then [space] to execute. super convenient)
noremap <Space> @q
This streamlines making and executing macros to such a degree that I'll often do that instead of merely making 3 or 4 complex series of edits manually. You just perform the edit once, then get in a few satisfying "thwocks" on the spacebar.(Note that to effectively create macros on the fly, you need to have a firm grasp on vi "as an editing language". If you are merely moving around with hjkl and otherwise treating it like nano, you aren't going to get much mileage out of this unless everything you are working on has the same number of lines.)
Also, you can do <num>@q (e.g. 4@q) anyways, and @@ to repeat a macro, so that isn't that useful of a remapping anyways.
edit: but . doesn't work for macros, as was pointed out.
<esc>qqq //clear q macro qq //start recording q macro /foo // search for something 3clbar // do some edit @q // call q macro q //done recording @q //invoke q macro
No need to guess how many times to call your macro.
(key-chord-define evil-insert-state-map "jj" 'evil-normal-state)
vrapper (for eclipse) is on par with emacs evil, actually.
People, especially vi users (compared to Emacs users, who in my experience have few qualms about heavily customizing their editor), like to say that, but in my many years of experience I just can't say this is true in practice. I don't use coworkers' accounts so alien configurations never trip me up, and when I find myself working on a prod host that doesn't have my configuration, I just don't find myself tripping up in practice (if I had to guess, perhaps the absence of my custom color scheme in those cases may be flipping a 'go back to compat mode' switch in my head).
I do not use any other programs that have "vim emulation". Tried that firefox 'total conversion mod' a while ago and hated it.
Executing macros the regular way is what I do for all macros I want to be long-lived (@q can get overwritten a dozen of times or more an hour for me, so complex operations I want to keep around longer I store in other registers), but even @@ does not have the low mental barrier to entry and satisfying nature that "twock" on a nice loud keyboard has.
(instead of [esc] for escape, I use [capslock] on windows and linux while on thinkpads, and [find](actually super) on linux on my chromebook. xmodmap/autohotkeys/xcape has my bases covered there.)
nnoremap <space> @@That being said, I do feel gimped in other editors without vi(m) commands. Most editors do have vim modes, but it doesn't quite feel the same.
Really learning to use vim effectively involves learning to think about text differently. It's about training your mind to think in terms of text objects and exploring the various ways to manipulate those objects.
The truth is that "vim mode" generally boils down to using h,j,k,l in lieu of arrow keys and a token nod to the idea of normal mode vs. command mode.
But, honestly, that's ok. Vim exists--why do I need another editor to behave like vim?
nnoremap ,r :'{,'}s/\<<C-r>=expand('<cword>')<CR>\>/
nnoremap ,R :%s/\<<C-r>=expand('<cword>')<CR>\>/
Another approach of the typical "multiple cursors" example, using the beautiful gn command. Hit ,x to "change" the word under the cursor then <Esc> and repeat for the next occurrences with the dot (or n to skip): nnoremap ,x *``cgn
nnoremap ,X #``cgN
Move to next and previous quickfix error: nnoremap <End> :cnext<CR>zv
nnoremap <Home> :cprevious<CR>zv
Traverse the buffer list effortlessly: nnoremap <PageUp> :bp<CR>
nnoremap <PageDown> :bn<CR>
In my lightweight "noplugin" vimrc (used on remote machines) I have these as well: set wildcharm=<C-z>
set path=.,**
" juggling with files
nnoremap ,f :find<Space>
nnoremap ,s :sfind<Space>
nnoremap ,v :vert sfind<Space>
" juggling with buffers
nnoremap ,b :buffer <C-z>
" juggling with tags
nnoremap ,t :tjump /
nnoremap ,p :ptjump /
Beside all those custom mappings, macros, Ex commands, motions, text-object and in general the whole "grammar" that ties everything are killer features.i - enter insert mode. ESC - leave insert mode. ZZ - save and quit :q! - quit without saving.
Since, in insert mode, vim basically behaves like a simple notepad, that's really all you need.
FYI, if you want a "simple," notepad like editor for console on linux, check out nano.
Perhaps the real question is do we want to attract more newbies? Why do we want to attract newbies? If more non-technical users are the solution to our problems, then why is Android (with their legions of newbies) such an absolute shitfest compared to traditional Linux distros?
KDE used to have some built in remote editing stuff in Konqueror, I don't know if it's still there or got moved into Dolphin, or removed.
Games and Notepad++ are the only real reasons I have had for using Windows on my desktop instead of Linux.
http://kate-editor.org/about-kate/
It's "vi imitation" mode is shit though.
"Development" is a loaded word given your usage. As such, I disagree that IDEs are "much nicer tools for development."
Which is one of the many reasons why people (including myself) don't consider IDEs as a nicer tool for the job.
> but ide's are much nicer tools for development
Just because you think they are doesn't mean everyone else does.
> Just because you think they are doesn't mean everyone else does.
? Of course, it's just my opinion.
This is mundane: "IDEs work much better for me."
This is controversial (and probably silly): "IDEs are the best."
Maybe the intent is obvious, but it wasn't to me and at least one other poster.
inoremap jj <ESC>
nnoremap ; :
vnoremap ; :
" Fix vim's terrible default regexp scheme
nnoremap / /\v
vnoremap / /\v
vnoremap ? ?\v
nnoremap ? ?\v
nmap <silent>]c :cnext<CR>
nmap <silent>[c :cprevious<CR>
nmap <silent>[C :cfirst<CR>
nmap <silent>]C :clast<CR>Hit jj instead of <Esc> which many people find too far.
inoremap jj <ESC>
Exchange ; and : because : is used a lot and you need to press Shift (on an american keyboard) while ; is less used and available without a modifier key: nnoremap ; :
vnoremap ; :
\v means "use verymagic mode for the rest of the pattern", normally, you'd have to use a lot of backslashes to escape parentheses and other "spacial" characters but "verymagic" allows you o type less and obtain more readable patterns. Example: /f\(oo\)ba\[zr\]
/\vf(oo)ba[zr]
With these mappings, search-based navigation is a lot less expensive because it use s "verymagic" by default: " Fix vim's terrible default regexp scheme
nnoremap / /\v
vnoremap / /\v
vnoremap ? ?\v
nnoremap ? ?\v
:cnext, :cprevious and friends are quickfix commands: thay allow you to navigate through the errors displayed in the quickfix window without using the window itself. Even in their shortened form (:cn, :cp, :cfir, :cla) they represent a lot of typing and a good occasion to create much more useful mappings: nmap <silent>]c :cnext<CR>
nmap <silent>[c :cprevious<CR>
nmap <silent>[C :cfirst<CR>
nmap <silent>]C :clast<CR>
nmap means "normal mode mapping".nnoremap means "non-recursive normal mode mapping", see learnvimscriptthehardway.stevelosh.com/chapters/05.html#nonrecursive-mapping
vnoremap means "non-recursive visual and select mode mapping", it should be xnoremap (visual mode only).
<silent> means "don't print the executed command".
What? The Jargon File lists it, and it is different from "understanding" to the point where "understanding" is further qualified in the definition. It came from 'Stranger in a Strange Land'.
It's as big of a difference as speaking German with an accent is from being fluent (along with thinking and dreaming in the language). Understanding "grok" is like understanding the German concept of "friend"-vs-"acquaintance" and thinking about your own friends in the same way, rather than our American way of "everyone's my friend". (In German culture, most people -- coworkers, teammates, etc -- are not __friends__. They're people you know, and maybe know well, but "friend" is much more similar to an American's concept of a "best friend", or group thereof. (I have about three.)
... none of that explains what "grok" means as well as reading the book. Wikipedia [1] doesn't quite even cover it, but has a good collection of newer uses of it that help.
In the case of this article, "grok" is entirely appropriate. It might even be the best word. As a user, I can figure out commands in vim, I can use a cheat sheet, but until I start thinking about using the tool in a way which fully embraces the tool in the way it was meant to be used (e.g., verbs + marks), I'll always be a poor and dissatisfied user.
set relativenumberPersonally, I disable the line-numbers column altogether (and display the current column:line in the status bar).
http://danielmiessler.com/study/vim
I go into a good amount of depth of how to get away from memorization and into thinking and having it happen.
In contrast, using emacs (which I have likely outed myself as a user of, via my above notation ;)) or vi require you to be more mindful (at first) of what you are doing while editing text. Both tools are likely to be frustrating if you don't think of things in a way that matches the worldview that each was built with.
To be a programmer, you have to learn a programming language. Learning an editor is easier than that. A lot of programmers probably don't invest the time to learn an editor, but it not much time in the long run, and it's worth learning your tools.