[link] vim scripts
From Sander Marechal: My list of must-have vim scripts.
From Sander Marechal: My list of must-have vim scripts.
Posted by
Ihar Filipau
at
6:23 AM
0
comments
This little thing:
command MM :exec ":make ".substitute( substitute(expand('%:p'), '\.[^\.]*$', '', ''), '^'.getcwd().'/', '', '')
defines a new VIM command ":MM" which does invoke ":make" with name of current file without extension. E.g. if you edit file "helloworld.c" and then type command ":MM" that would expand to command ":make helloworld"
Just in case I have also added stripping of $PWD (getcwd() in VIM universe) so that if you edit file from another directory, make would be called with relative path and Makefile from current directory would be used. That will not improve much make behavior, but if by chance you are using "cons", then that would work very well.
Edit1. Forgot to mention. VIM mandates that all user commands start with capital letter (all standard commands start with lower case letters). That's why I named the custom command "MM"
Posted by
Ihar Filipau
at
10:10 AM
0
comments
21 of the Best Free Linux Text Editors
Unfortunately, VI and Emacs clones are not presented. Emacs itself is too bloated to be used by people who like to remain in control of their text editor - but there are number of decent Emacs clones.
From Wikipedia: Emacs clones and VI clones. VIM is listed in VI clones.
P.S. Most important Emacs shortcuts: Ctrl-g - end minibuffer editing, if any; Ctrl-x Ctrl-c - exit Emacs. Ctrl-g you need because often, after entering shortcut from another text editor, you might end-up in Emacs minibuffer (internal command line). Ctrl-x Ctrl-c will not work in minibuffer - so you need to press Ctrl-g. After exiting Emacs, type in shell "vim" and press Enter to start real text editor ^_^
Posted by
Ihar Filipau
at
5:32 AM
3
comments
Labels: link
100 Vim commands every programmer should know
Nice summary of vim commands.
P.S. Though apparently the people are messing up "vim" and "vi". As things stand right now, "vim" has absolutely nothing to do with "vi". Hey I worked in "vi" (on both Solaris 10 and HP-UX 11.x) - that was most frustrating 5 minutes in my life. The *NIX vendors do not even bother adding keyboard support. Solaris' "vi" proudly says that it wasn't updated since 1996.
Posted by
Ihar Filipau
at
8:46 AM
0
comments
Labels: link
How to see how long selection (visual) is?
How to see whether you have accidentally entered any numbers which would act as repeat counter for the command?
The little thing I always forget about::set showcmd
In right bottom corner (before ruler) little useful bits about actual state of keyboard input in normal are displayed.
Most useful is of course to now how long visual selection is, which I use often to e.g. count number of characters.
P.S. Documentation says the showcmd setting will be changed if you changed compatible mode. Shouldn't be a problem since no sane person uses compatible mode anyway.
Posted by
Ihar Filipau
at
7:02 AM
0
comments
It's so much easier to suggest solutions when you don't know too much about the problem.
-- Malcolm Forbes
Posted by
Ihar Filipau
at
11:43 PM
0
comments
Simple Vim intro by Linux Magazine.
Posted by
Ihar Filipau
at
2:07 PM
0
comments
Another upgrade, another OS, another update... Well, new home directory - consequently new .vimrc.
Here is N hours into coding minimalistic usable .vimrc:
filetype plugin off
syntax on
imap <Insert> <Nop>
set bs=2 ruler title comments= nowrap
set cindent cinkeys-=: cinkeys-=0#
colo torte
let loaded_matchparen = 1
au BufReadPost * if line("'\"") > 0 &&
\ line("'\"") <= line("$") | exe "normal g'\"" | endif
I hope this time, Blogger/BlogSpot hadn't eaten any characters.
The set comment= creeped in before I have realized that filetype plugin is still on.
Posted by
Ihar Filipau
at
12:56 PM
0
comments
Always forget the very useful shortcut which is apparently intended for "Vim Easy":^O
When in insert mode (and, by definition, in easy vim you are always in the mode) to insert command from Normal mode, you press first ^O and then start typing the command.
e.g. to delete to the end of line press ^O followed by Shift-d. Pressing : you can also access all the ex commands too - but that will leave insert mode.
Posted by
Ihar Filipau
at
3:00 PM
2
comments
How would I use a vim function to insert the output of these commands at the current cursor position?
Well, that would look like a crude hack, yet here it goes:
:function InsertCmd( cmd )
: exe ':silent !'.a:cmd.' > /tmp/vim.insert.xxx 2>/dev/null'
: let l = readfile( '/tmp/vim.insert.xxx', '', 1 )
: exe "normal a".l[0]
: redraw!
:endfunction
:imap <silent> <F5> <Esc>:call InsertCmd( 'hostname' )<CR><Insert>
:map <silent> <F5> :call InsertCmd( 'hostname' )<CR>
Posted by
Ihar Filipau
at
4:40 AM
3
comments