Академический Документы
Профессиональный Документы
Культура Документы
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
Browse all
Download all
Karma
My Account
Ischenko)
[2004-02-17] tip #657 - have a question about vim? (Adam Wolff)
[2004-02-16] tip #656 - Recursive mappings - (2 examples to learn from)
Site Help
(Mohit Kalra)
Why tips?
(Yakov Lerner)
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
Browse all
Download all
Karma
My Account
search results
Showing 1 to 20 of 653
results
author
rating views
created
summary
659
Siegfried Bublitz
49 2004-02-18
Collect filenames of
current subtree
658
Max Ischenko
50 2004-02-18
657
Adam Wolff
191 2004-02-17
656
Mohit Kalra
14
202 2004-02-16
Recursive mappings - (2
examples to learn from)
655
vim_user
-4
654
Hyouck Kim
240 2004-02-15
special characters in
VIM substitution
383 2004-02-10
652
Andreas Berg
594 2004-02-06
651
Frank Price
11
461 2004-02-05
Edit gnupg-encrypted
files.
Site Help
650
Yakov Lerner
abbreviation that
391 2004-02-04 prompts whether to
expand it or not
649
Yakov Lerner
293 2004-02-04
expand existing
abbreviation
648
Michael Geddes
11
634 2004-02-01
Uniq - Removing
duplicate lines
647
Astrobe
-1
646
Frank Butler
37
927 2004-01-28
645
Girish Gajwani
Enabling Windows
shortcuts (eg alt+space,
589 2004-01-28
F10 etc) for gvim
window
644
stsi
16
643
Alfvaen
642
641
640
David Risner
Olivier Teuliere
Mark Fernandes
Disable built-in
command
13
17
Highlighting of method
727 2004-01-21 names in the definition
(C++)
prev | next
keywords
sort by
Rating
Descending
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
search
cancel
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Tip Download
You can download the vim tip database as a text file for easy reading offline. Benji Fisher has also written a vim script (vimtips.zip) that will emulate
"tip of the day" functionality.
download
Scripts
Tips
Browse all
Download all
Karma
My Account
Site Help
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
Add a Tip
author
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
as of
5.7
complexity basic
summary
Your tip should include some context to why one might want to use the tip and
references to vim help for additional reading. All HTML in descriptions will be escaped for
security reasons. If you want to use links, just enter "http://...." and it will be turned into a
link. Spaces and returns will be maintained so the general structure of your tip will be as
you entered it. If you want to refer to other tips or scripts you should use the syntax
"keyword #id" and it will be linked to the correct place. For example: vimtip #6 or
vimscript #10.
add
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
cancel
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
When a discussion started about learning vim on the vim list Juergen
Salk mentioned the "*" key as something that he wished he had know
earlier. When I read the mail I had to go help on what the heck the
"*" did. I also wish I had known earlier...
Using the "*" key while in normal mode searches for the word under
the cursor.
If that doesn't save you a lot of typing, I don't know what will.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
kunzem@optimiz.com, March 8, 2001 14:51
see vimtip #5 for more detail
jorge@paises.com, August 17, 2001 9:22
Oh boy! What a great discovery! I too wish I knew it earlier...but
better late than never.
dontsendjunk@mailcity.com, September 12, 2001 4:44
if you find "*" useful check out '#' does the same thing but in
reverse order ;-)
Regards
Jags
Anonymous, January 4, 2002 14:00
Jags, you're my hero!!! That was my next question...
matthew.krauski@mu.edu, March 1, 2002 12:44
if you like "#" and "*", and you do lots of nested loops, try using
"%"
sachinnb@rediffmail.com, March 3, 2002 9:27
U can also search patterns by just left clicking the mouse on the
word U want to search while keeping the shift button pressed !!!
--- sachin
http://www.vim.org/tips/tip.php?tip_id=1 (1 of 7) [18/02/2004 14:40:13]
Please pardon me, but I can't understand how on earth "*" command
can save me typing. Could somebody provide example scenarios where
it may be helpful?
juddkenneth@yahoo.com.hk, August 19, 2002 2:25
You normally would search for the occurence of a word by typing
"/_Your_Very_Big_And_Untidy_Word_That_Has_A_Lot_Of_UnderScores_<CR>"
followed by 'n's and 'p's. If you have the word you want to search
for under the cursor, you can just press '*' or '#' to go to the
next or previous occurence of that word.
milindacharya_2000@yahoo.com, September 4, 2002 3:27
That is just great. Thanks for giving this tip.
laloo@rabri.com, September 10, 2002 4:37
bahut aacha hai bhaiya .
koi ghotala nahi
Anonymous, September 12, 2002 22:43
stated using, looking at VIM today...good tip to start out with!
Anonymous, October 15, 2002 7:32
...and for those n00bs out there (like myself...) it's NOT the mouse
cursor we're talking about here! duh...
maylward@iprimus.com.au, October 15, 2002 19:21
Oh, now I see, always wondered how to do that. What is it 2002, I
started using vim exclusively in 1995, quick learner aren't I!!!
That is an exceptional tip, it should be kept back from newer vim
users to avoid them gaining an unfair advantage over old coots like
me.
Cheers and many thanks,
Matt
Anonymous, October 23, 2002 14:19
Ha! I started using vim a few days ago and I just learned this. :P
Anonymous, November 8, 2002 4:57
To heck with "*", in reading this thread I just found out how to put
comments in my _vimrc file for all those cryptic commands I'm
assigning to F-keys. RTFM? Hah! A real engineer only resorts to
documentation when the keyboard dents on the forehead get too
noticeable.
arnarbi@hi.is, November 24, 2002 10:42
Brilliant.. nothing but brilliant!
ssepiro@hotmail.com, January 11, 2003 0:43
fortunately..I have known #,*... ...I just say.that you do "gD" on
the word. :)
I think this is also great!
Anonymous, January 19, 2003 8:46
The fingers usually are closer to the gd combination than the '*',
that's why I don't find '*' to be such a great enhancment...
use "*" for to find out where a particular variable has been
down the file. But when I have done through its occurences, I
to get back to the line where I first used "*" and continue
the source. I usually just keep hitting "*" a many more times.
As a side comment: You can simply press 'n' instead of pressing '*'
to continue your search and move on to the next hit. '*' involves
holding down shift, while 'n' does not.
Anonymous, April 23, 2003 11:54
>> gsinclair@soyabean.com.au, Another thing worth knowing that is
related to this: when entering a search, hit <C-R><C-W> and the
word under the cursor will appear in your search. This is very
useful if you want to search for some variation of the word under
the cursor.
This is just about as phenomenal (if not more) as the '*' and '#'
commands themselves !! Thanks dude!
Anonymous, April 27, 2003 16:58
can anybody please tell me what <C-R><C-W> means?
thanks
vario uneseny
Anonymous, April 30, 2003 3:12
slemansadi@hotmail.com
fozemohammed@yahoo.com, July 25, 2003 11:41
nnoremap
nnoremap
nnoremap
nnoremap
nnoremap
nnoremap
nnoremap
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<the super star | use vim to quickly compile java files >>
Additional Notes
bstrohhaecker@hueller-hille.com, May 30, 2001 2:08
For not-unix-systems you need two backslashes, so use:
map ,e :e <C-R>=expand("%:p:h") . "\\" <CR>
Sometimes it may also be useful to change to the file's
directory.
map ,cd :cd %:p:h<CR>
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: advanced
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
<<easy edit of files in the same directory | Any word completion >>
Additional Notes
slabounty@netaphor.com, April 20, 2001 13:17
http://www.vim.org/tips/tip.php?tip_id=3 (1 of 8) [18/02/2004 14:40:18]
rate
Safer:
augroup filetypedetect
au BufNewFile,BufRead,BufEnter *.java
\ map <F9> :w<CR>:!javac "%"<CR> |
\ map <F6> :!java -cp %:p:h %:t:r<CR>
augroup END
Anonymous, September 20, 2003 9:52
Reading this tips, I've just found out that Windows XP
supports redirecting stderr.
Just do:
:set shellpipe=>\ %s\ 2>&1
Then, :make will be expanded to {makeprg} > {errorfile}
2>&1 and you'll see all the output from the make
program!
graziosi.fabio@tiscali.it, September 23, 2003 6:24
Also Win2K supports redirecting stderr. You can use tip
for Win Xp.
khulick@varco.com, October 15, 2003 21:30
I am a java developer forced to use Windows on occasion
and use Vim as my primary editing tool. I use the
shell redirection (on Win XP) and the output and
quickfix work fine, but what I really miss in the win
gui version is the "live" feed as the compile is
happening, like you get out of tail -ing the temp
output in a Unix system.
Anyone have suggestions?
zlhg@hotmail.com, October 23, 2003 19:34
how do I set java's classpath in vim just like batach
file in Win2k.
I do it with batch file in ultraEdit while build java
file in it ?
I'm a newbie. I don't know how to set envirorment in
Win2k.
Thank u in advance!
schloman@msu.edu, January 20, 2004 12:15
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<use vim to quickly compile java files | Quickly searching for a word >>
Additional Notes
scrott@users.sourceforge.net, February 25, 2001 12:10
See vimtip #11 for more details...
harry@slaughters.com, October 12, 2002 2:17
that is definitely a life changing tip.
especially when programming and trying to recal
variable names and so on. wow. i had no idea.
ajglist@izzy.net, February 2, 2003 1:38
Herman.
Anonymous, June 15, 2003 15:14
Damn, this saves me about 1000 keystrokes a day.
Anonymous, July 3, 2003 17:33
I love vim ;-p
spam@sukria.net, August 11, 2003 4:34
Of course this tip is a life changing one :)
Note that you can ask vim for a previous word
compeltion with <Ctrl>P
Yo ucan also, for use facilities, map this combo on a
not-often-used key such as the '' one.
But, does anyone know how to make Vim read the Pel
modules inculded for compeltion on function names ?
Such as it did when editing C code ?
Thanks a lot.
Anonymous, January 17, 2004 18:31
I wish I had known this earlier. Thank for the tip!
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
the opposite
direction, press the shift key and click on the word
using the
the right mouse button.
To get more help on these, use
:help
:help
:help
:help
:help
:help
*
#
g*
g#
<S-LeftMouse>
<S-RightMouse>
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
atheeban@yahoo.com, October 8, 2002 11:28
Very good tip!.
kubieziel@gmx.de, November 2, 2002 14:28
I'm quite happy to find that tip now. I'm start using
vim. So it will save lot of time. :-)
scherkas@tx.technion.ac.il, December 8, 2002 8:22
By default on Windows version <S-RightMouse> works [as
backwards search], but <S-LeftMouse> does not.
This is because mousemodel is set to
"popup". (somebody knows why?)
If you want to use this nice feature [<S-LeftMouse> as
forward word search], add
this line to _vimrc file, which is located in VIM
installation directory:
set mousemodel=extend
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
<<Quickly searching for a word | Jumping to the start and end of a code block >>
Additional Notes
Anonymous, February 28, 2001 11:00
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #7 - Jumping to the start and end of a code block : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
[{
]}
[(
])
Life Changing
Helpful
Unfulfilling
Additional Notes
alinets@yahoo.com, June 14, 2002 17:55
rate
Tip #7 - Jumping to the start and end of a code block : vim online
[[ and ]]
[[
sections backward or to the previous '{' in the first
column.
]]
sections backward or to the previous '{' in the first
column.
[]
sections backward or to the previous '}' in the first
column.
This has specially help me in jumping to the top of the
functions and jumping from one function to the next
function.
May be our coding convention played a part in this
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
'gd' command:
To jump to the declaration of a local variable in a C
program,
position the cursor on the name of the variable and use
the
gd command.
'gD' command:
To jump to the declaration of a global variable in a C
program,
position the cursor on the name of the variable and use
the
gD command.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Jumping to the start and end of a code block | Displaying a variable/macro definition >>
Additional Notes
scrott@users.sourceforge.net, February 25, 2001 12:06
This works in java, perl and a number of other
languages as well!
vinayns@hotmail.com, December 10, 2003 14:02
to jump back use `` (backquote backquote)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Jumping to the declaration of a local/global variable | Jumping to previosuly visited locations in a file
>>
Additional Notes
maneesh@india.hp.com, February 25, 2001 2:31
Use [I on a variable display all the lines having that
variable with line numbers. This is very useful for
browsing some C Code.
dp@orion.spectral-sys.com, February 28, 2001 10:58
You can also do ]<c-i> do JUMP to the place where it is
defined
bindu@wavell.net, November 11, 2001 14:28
gd
will also take you to where it is defined (unless it is
global, in which case gD works)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
complexity: basic
as of Vim: 5.7
Scripts
Tips
My Account
Site Help
Note that using the 'complete' option, you can complete keywords
defined in one of the include files, tag file, etc.
To get more help on this, use
:help
:help
:help
:help
i_Ctrl-N
i_Ctrl-P
ins-completion
complete
Life Changing
Helpful
Unfulfilling
Additional Notes
jmcpherson@bigfoot.com, August 17, 2001 14:26
rate
Unfortunately, this can also propagate errors, so use it carefully. I've had times when I've
misspelled a keyword or variable somewhere and then CTRL-P/N completed it five times before I
noticed what I was doing. (-: Of course, at least that gives you a consistent misspelling that's
easy to fix with :%s...
I have found myself performing a lot of CTRL-P/N commands on the same strings, and when this
happens, I generally add an abbreviation, which saves me a keystroke or two. I do a lot of
programming in ColdFusion, and I have these lines in my .vimrc:
ab Attr Attributes
ab Appl Application
ab Vari Variables
ab Req Request
ab CFQ CFQUERY
ab CFO CFOUTPUT
...
VIM will finish the word as soon as you type a character after the abbreviation. This is a lot of
fun, especially when you have non-VIM-using co-workers who think you're controlling the editor
with your mind as well as your keyboard. (-;
michael.garriss@abacus-direct.com, September 19, 2002 13:08
I shook with excitement after reading this......
dof@spamsocks-codepoets-foo-co-dot-uk, November 8, 2002 7:52
excitement ? is that all ? I've been using vim for a couple fo years now and have only just found
out about this... clearly I need to RTFM more.
ritesh_j_patel@indiatimes.com, November 28, 2002 5:52
It's great and making life easier.
Balu, January 17, 2003 15:12
How would I add multiline abbrevs? I've tried to edit them using ^V with no luck
salloum@computer.org, February 13, 2003 4:27
Awesome !!!!
Anon, March 13, 2003 22:41
Balu asked about multiline abbreviations?
ab mul Mult^V<Enter>iple lines
the above will probably look like "ab mul Mult^Miple lines".
Anonymous, March 15, 2003 5:08
http://www.vim.org/tips/tip.php?tip_id=11 (2 of 4) [18/02/2004 14:40:38]
If you've several words you'd like to complete, you can use CTRL-X CTRL-P to extend the match.
e.g.
a line exists in your file:
$res = mysql_query($q) or die(mysql_error());
you want to type the line:
$result = mysql_query($q) or die(mysql_error());
but don't want to have to type it in again. (BTW if you wanted the same line use CTRL-X CTRL-L to
complete whole lines)
type
$result = my
keep pressing CTRL-P until you get to mysql_query
then CTRL-X CTRL-P
will give you
$result = mysql_query($q
then keep pressing CTRL-X CTRL-P to complete all the words.
Have a play.
see:
:h i_CTRL-X_CTRL-P
:h i_CTRL-X_CTRL-N
return 0;<Enter>}
The autocompletion is great (I i-mapped it to <Tab>), but the abbreviation "ab" is at least as
good!
Thanks!
clamey@infonow.com, October 30, 2003 11:59
Well, cursor position can be done like this:
ab ff for (Iterator i =; i.hasNext())
{<LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT>
I've tried added a [count] before the <LEFT> but it doesn't seem to work.
Anyone else have an idea?
baitisj@yahoo.com, January 9, 2004 11:23
It would be great if we could have something like wildmode=longest,list in insert mode:
A lot of my friends think that the way VIM rotates through possible completions is annoying. We
would prefer the behavior to act like the default tab-completion in BASH, where you type <tab>
once, and if it can complete with only one match, the completion is performed. If there are other
possible completions, then an alphabetical list of completions is listed, giving you an
opportunity to type the next letter to further narrow your completion list.
Can anyone suggest how to do this?
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
glennj@canada.com, February 27, 2001 7:05
Also, see the :help smarttab option
jason@katzbrown.com, February 27, 2001 8:42
but tabs are better :-)
Dirk Ruediger <druediger@gmx.net>, March 6, 2001 3:57
I'm also using
set list listchars=tab:,trail:
to "highlight" any tabs and all trailing spaces -- to
catch them :).
peach@avaya.com, August 14, 2001 20:47
To turn off expandtab for editing makefiles, I put the
following in my .vimrc:
au FileType make setlocal noexpandtab
jzgoda@o2.pl, December 13, 2002 1:45
This feature is a "life preserver", when you edit
Python code.
smceligot@despammed.com, May 15, 2003 15:40
This makes the backspace key treat the four spaces like
a tab (so one backspace goes back a full 4 spaces).
I love vim.
iebnn@hotmail.com, December 3, 2003 10:25
Read this if you're interested in this tip. It explains
how tabs are actually much better than spaces, contrary
to many's opinion.
http://derkarl.org/why_to_tabs.html
misof, December 16, 2003 14:54
:!man expand
:%!expand
why shouldn't you use an external tool made especially
for this purpose?
d_ayles@telus.net, December 28, 2003 8:41
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Converting tabs to spaces | Highlighting all the search pattern matches >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #14 - Highlighting all the search pattern matches : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Additional Notes
Unfulfilling
rate
Tip #14 - Highlighting all the search pattern matches : vim online
Tip #14 - Highlighting all the search pattern matches : vim online
The tip:
map <F1> :let &hlsearch=!&hlsearch<CR>
Is good, but watch out for a invisible space at end
after <CR> which makes the cursor move right on each
F1 hit. I guess this is possible because vim does not
trim spaces at end of lines. (How do you keep this from
calling help in insert mode?)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Highlighting all the search pattern matches | Avoiding the "Hit ENTER to continue" prompts >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #16 - Avoiding the "Hit ENTER to continue" prompts : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Displaying status line always | Erasing previosuly entered characters in insert mode >>
Additional Notes
michael@endbracket.net, October 23, 2003 18:33
The "Hit ENTER to continue" commands that I find most
annoying are actually disabled by setting
shortmess="oO" rather than "a". shortmess is set to
"filnxtToO" by default, so these messages should not
appear by default anyhow.
Add Note
Tip #16 - Avoiding the "Hit ENTER to continue" prompts : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #17 - Erasing previosuly entered characters in insert mode : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Avoiding the "Hit ENTER to continue" prompts | Cleanup your HTML >>
Additional Notes
jsuntheimer@neo.rr.com, May 26, 2001 22:59
a convenient and oldly memorable abbreviation is
:set bs=2
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: advanced
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
scrott@users.sourceforge.net, May 2, 2001 23:05
There is also Jtidy (Java implementation of tidy):
http://sourceforge.net/projects/jtidy/
djkea2@mugca.cc.monash.edu.au, January 11, 2002 5:01
http://www.vim.org/tips/tip.php?tip_id=18 (1 of 2) [18/02/2004 14:40:54]
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<Cleanup your HTML | Are *.swp and *~ files littering your working directory? >>
Additional Notes
the_voice666@hotmail.com, August 19, 2001 17:00
A faster way to do this is
:set nu
bindu@wavell, November 11, 2001 13:48
An even faster way to do this :) is
:se nu
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #20 - Are *.swp and *~ files littering your working directory? : vim online
Home
Search
Tip #20: Are *.swp and *~ files littering your working directory?
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
backupdir=./.backup,.,/tmp
directory=.,./.backup,/tmp
Life Changing
Helpful
Unfulfilling
Additional Notes
christophe.badoit@free.fr, December 28, 2001 2:20
http://www.vim.org/tips/tip.php?tip_id=20 (1 of 3) [18/02/2004 14:41:07]
rate
Tip #20 - Are *.swp and *~ files littering your working directory? : vim online
Yes but remind that the swp files are very useful when
many users are working on the same directory, to
prevent you loosing datas...
Anonymous, July 25, 2002 8:13
I love you
Anonymous, November 25, 2002 7:24
I too, love you.
Anonymous, December 22, 2002 21:22
I dont love you, but the tip is great. Thank you.
Anonymous, January 7, 2003 5:40
I was not able to use it in Windows. Is there some
difference on how to properly write paths?
Anonymous, January 10, 2003 10:05
Yes it is. Use \\ instead of / in your path.
It should look like:
set
set
backupdir=.\\.backup,.,c:\\tmp
directory=.,.\\.backup,c:\\tmp
backupdir=./_backup,.,/tmp
directory=.,./_backup,/tmp
Tip #20 - Are *.swp and *~ files littering your working directory? : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
clipboard=unnamed
Life Changing
Helpful
Unfulfilling
rate
<<Are *.swp and *~ files littering your working directory? | handle common typos for :commands >>
Additional Notes
benji@member.AMS.org, March 4, 2001 11:27
You can also have the Visual selection automatically
copied to the clipboard. If you
:set go+=a
and then make a Visual selection, you can switch to
another application (such as your mail reader) and
paste.
:help guioptions
:help quotestar
slabounty@netaphor.com, October 28, 2001 17:34
http://www.vim.org/tips/tip.php?tip_id=21 (1 of 2) [18/02/2004 14:41:09]
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
dp@orion.spectral-sys.com, February 28, 2001 10:54
Or you can also do a cabbrev to change
:Wq to :wq.
Would be done like this:
cabbrev Wq wq
glennj@canada.com, March 21, 2001 14:31
I like that cabbrev tip. That lets you get away with:
cabbrev X x
The drawback is that it becomes tricky to use "X" as a
work in any
command. For example, with "cabbrev X x", you cannot
perform the
search "/X" --> the abbrev changes it to "/x"
http://www.vim.org/tips/tip.php?tip_id=22 (1 of 2) [18/02/2004 14:41:11]
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<handle common typos for :commands | changing the default syntax highlighting >>
Additional Notes
Anonymous, October 15, 2002 14:25
Merely commenting out "set notitle" will not do
it. Vim has the xterm title off by default. You need
to put "set title" in your .vimrc. Alternately, you
could just type ":set title" from within vim.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
http://www.vim.org/html/autocmd.html#new-
Read the
http://www.vim.org/html/syntax.html#mysyntaxfile
http://www.vim.org/html/syntax.html#mysyntaxfile
Life Changing
Helpful
Unfulfilling
Additional Notes
Anonymous, February 17, 2003 22:52
it says page not found
Anonymous, August 6, 2003 15:28
http://www.vim.org/tips/tip.php?tip_id=24 (1 of 2) [18/02/2004 14:41:15]
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<changing the default syntax highlighting | Getting rid of ^M - mixing dos and unix >>
Additional Notes
Anonymous, July 17, 2002 18:30
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #26 - Getting rid of ^M - mixing dos and unix : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Tip #26 - Getting rid of ^M - mixing dos and unix : vim online
Once again: BE SURE YOU MAKE the ^M USING "CTRL-V CTRLM" NOT BY TYPING "CARROT M"! This expression will
replace all the ^M's that didn't have carriage returns
after them with a carriage return.
Voila! Clean file. Map this to something if you do it
frequently.
:help ffs - for more info on file formats
thanks to jonathan merz, douglas potts, and benji fisher
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
wiwo@dcon.at, October 22, 2001 8:51
It also works with
:%s/\r//g
rpilkey@hotmail.com, January 29, 2002 9:01
If you want to put a map of this in your _vimrc file,
then you have to double the ^V character so that it
looks like this:
map M :%s/^V^V^M$//g^M
note: if you cut and paste this line, it won't
work. You have to type the control characters as
explained above.
It has something to do with it being interpreted
multiple times, I think.
Roger
Tip #26 - Getting rid of ^M - mixing dos and unix : vim online
Tip #26 - Getting rid of ^M - mixing dos and unix : vim online
Tip #26 - Getting rid of ^M - mixing dos and unix : vim online
Tip #26 - Getting rid of ^M - mixing dos and unix : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: advanced
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Getting rid of ^M - mixing dos and unix | add a line-number to every line without cat or awk alike
utilities. >>
Additional Notes
o.wegner@gmx.de, June 6, 2001 0:42
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #28 - add a line-number to every line without cat or awk alike utilities. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #28: add a line-number to every line without cat or awk alike
utilities.
tip karma
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Convert hex to dec | reverse all the line with only 7 keystroke in vim >>
Additional Notes
darren chamberlain <dlc@users.sourceforge.net>, July 2, 2001 4:50
Tip #28 - add a line-number to every line without cat or awk alike utilities. : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #29 - reverse all the line with only 7 keystroke in vim : vim online
Home
Search
Tip #29: reverse all the line with only 7 keystroke in vim
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
:g/^/m0
well,
1. : bring you to command-line mode(also known as exmode) from normal-mode(also known as command mode).
2. g means you'll take an action through the whole file,
generally perform a search, `v' also perform a search
but it match the line not match the canonical
expression.
3. / begins the regular express
4. ^ is a special character respect the start of a line.
5. the second / ends the regular express and indicate
that the remains is action to do.
6. m means move, `t` and `co' for copy, `d' for delete
7. 0 is the destination line.
you can use
:g/regexp/t$
to filter all lines and pick the match line together and
copy them to the end of the buffer or
:g/regexp/y A
to put them into a register(not eax, ebx...)
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<add a line-number to every line without cat or awk alike utilities. | Increasing or decreasing numbers
>>
Additional Notes
rufus@o-town.de, April 16, 2002 6:12
You can drop the '^' in the regexp, an empty regexp it
will match any line, too:
:g//m0
Tip #29 - reverse all the line with only 7 keystroke in vim : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
complexity: basic
as of Vim: 5.7
Scripts
Tips
My Account
To decrease, type:
Ctrl-X
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<reverse all the line with only 7 keystroke in vim | Find and Replace >>
Additional Notes
vim@suijsmail.com, October 10, 2001 0:30
I always looked for a possbility to create multiple
lines with the same content only differing by an
increasing or decreasing number. Probably haven't
searched hard enough:
Create the first line with the number.
Set the cursor on the number.
Do: mnYP`n^A
Or create a macro with this and call it multiple times.
The single quote must be the back quote ` not ',
because ' goes to the beginning of the line in the mark
and ` goes to the proper column/character-position.
Furthermore the ^A = <CTRL>-A (see this page). You can
as easily change to decreasing numbers.
Herman Suijs
:-)
- Mick
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
complexity: basic
as of Vim: 5.7
Scripts
Tips
My Account
Site Help
:%s/foo/bar/g
find each occurance of 'foo' and
replace it with 'bar' without asking for confirmation
:%s/foo/bar/gc
find each occurance of 'foo' and
replace it with 'bar' asking for confirmation first
:%s/<foo>/bar/gc
find (match exact word only) and
replace each occurance of 'foo' with 'bar'
:%s/foo/bar/gci
find (case insensitive) and
replace each occurance of 'foo' with 'bar'
:%s/foo/bar/gcI
find (case sensitive) and
replace each occurance of 'foo' with 'bar'
NB: Without the 'g' flag, replacement occurs only for
the first occurrence in each line.
For a full description and some more interesting
examples of the substitute command refer to
:help substitute
See also:
:help cmdline-ranges
:help pattern
:help gdefault
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
bstrohhaecker@hueller-hille.com, May 30, 2001 1:57
To match exact words only you need \<foo\>, not <foo>.
Anonymous, November 25, 2002 5:22
To find or replace line breaks or tab characters, use
Ctrl-v followed by the enter or tab key.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: advanced
as of Vim: 5.7
let var_Name=value
let var1=var2
like it does in c, except you must use let keyword
7. Can I use any ex-mode command in a function?
As I know, yes, just use it directly, as if every line
you type appears in the familar :
8. Can I call a function recurse?
Yes, but use it carefully to avoid infinte call.
9. Can I call another function in a function?
Course, like C does.
10. Must I compile the function?
No, you needn't and you can't, just :so script_name,
after this you can call the function freely.
11. Is it has integer and char or float data type?
No, like perl, vim script justify the variable type
depend upon the context
:let a=1
:let a=a."asdf"
:echo a
you'll get `1asdf'
:let a=1
:let a=a+2
:echo a
you'll get 3
But it differs from perl.
12. Must I append a `;' in every statement?
No, never do that.
; is required in C, and optional in shell for each
statement in a alone line.
But is forbidden in vim.
if you want combine servals statement in one single
line, use `|'.
Take your mind that every statement appears in
function should be valid in ex-mode(except for some
special statement).
rate this tip
Life Changing
Helpful
Unfulfilling
<<Find and Replace | toggle off the line-number when enter on-line help >>
Additional Notes
dp@orion.spectral-sys.com, March 14, 2001 13:29
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #33 - toggle off the line-number when enter on-line help : vim online
Home
Search
Tip #33: toggle off the line-number when enter on-line help
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Site Help
<<Write your own vim function(scripts) | control the position of the new window >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #34 - control the position of the new window : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
:se splitbelow
make the new window appears below the current window.
:se splitright
make the new window appears in right.(only 6.0 version
can do a vsplit)
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<toggle off the line-number when enter on-line help | For programmer: translate // style comment to
/* */and vice vesa >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #35 - For programmer: translate // style comment to /* */and vice vesa : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
<<control the position of the new window | Using Gnu-info help in vim >>
Additional Notes
leinfidel@netscape.net, August 31, 2003 14:29
wanted to, doesn't appear to work?
perhaps I'm no using it properly
rate
Tip #35 - For programmer: translate // style comment to /* */and vice vesa : vim online
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<For programmer: translate // style comment to /* */and vice vesa | The basic operation about vimboolean optionals >>
Additional Notes
Anonymous, January 14, 2004 1:36
Far better to use vimscript#21 - Info browsing within
vim.
Then e.g. :nnoremap <F1> :exe ":Info
".expand("<cword>")<CR>
Also, set your shell to alias info to use vim: (bash)
function viminfo () { vim -c "Info $1" -c "bdelete 1";
}
alias info=viminfo
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #37 - The basic operation about vim-boolean optionals : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
:set number
switch the number on
:set nonumber
switch it off
:set invnumber
or
:set number!
switch it inverse against the current setting
:set number&
get the default value vim assums.
replace number with any legal vim-boolean optionals,
they all works well.
for vim-non-boolean optionals
:set optional&
also works properly.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Using Gnu-info help in vim | Cursor one line at a time when :set wrap >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #38 - Cursor one line at a time when :set wrap : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
j gj
k gk
j gj
k gk
<Down> gj
<Up> gk
<Down> gj
<Up> gk
<Down> <C-o>gj
<Up> <C-o>gk
Life Changing
Helpful
Unfulfilling
rate
<<The basic operation about vim-boolean optionals | Undo and Redo >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Cursor one line at a time when :set wrap | Insert a file >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
:0r foo.txt
first line
:r !ls
below the cursor
:$r !pwd
inserts the current working directory
below the last line
For more information about the r[ead] command refer to:
:help read
See also:
:help cmdline-ranges
:help !cmd
Life Changing
Helpful
Unfulfilling
Additional Notes
andy@edespot.com, July 16, 2002 19:05
http://www.vim.org/tips/tip.php?tip_id=40 (1 of 2) [18/02/2004 14:41:52]
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: advanced
as of Vim: 5.7
execute ":$-".(linenum-1).",$m0"
%!uniq
if line("$")>100
101,$d
endif
b#
set splitbelow
sp ~/.sqlplus.history
au! BufEnter afiedt.buf
endf
au BufEnter afiedt.buf call VimSQL()
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
stephen@morley.net, April 19, 2001 5:59
I added the following:
set syntax=sql
at the start of the function and after loading the
history file, this way the files will be shown with
syntax highlighting.
Also the following map
map ZZ :close<cr>:b afiedt.buf<cr>:xit<cr>
will let the ZZ function close the second window and
save the afiedt.buf file and then exit (if the user has
no other dirty buffers).
Stephen
makoml@msn.com, October 19, 2002 11:39
Another solution (but not olny for vim editor) :
If your operating system is HP-UX, try below.
$ ied sqlplus <user>/<pass>@<db>
SQL> [Escape-Key]
SQL> [K-Key] or [J-Key]
ied is a utility command that is intended to act as an
interface
between the user and an interactive program such as bc,
sqlplus,
providing most of the line editing and history
functionality found in the Korn shell.
http://www.vim.org/tips/tip.php?tip_id=41 (2 of 3) [18/02/2004 14:41:55]
mako
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
'a
`a
d'a
d`a
mark a
c'a
mark a
y`a
mark a
:marks
Site Help
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
mbrubeck@cs.hmc.edu, December 10, 2001 14:41
I find that the most useful command is '' (that's a
pair of single quotes). This jumps to the special mark
' which is set automatically after every jump. This
allows you to easily return to your starting point
after a search, for example. This is similar to using
the jump stack (vimtip #10 or :help jump-motions).
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
:una[bbreviate] rtfm
list of abbreviations
:abc[lear]
abbreviations
remove all
Life Changing
Helpful
Additional Notes
berdim99@hotmail.com, March 13, 2001 8:22
Unfulfilling
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
:his s
Life Changing
Helpful
Unfulfilling
<<Repeat last changes | Win32 binaries with perl, python, and tcl >>
Additional Notes
rate
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #46 - Win32 binaries with perl, python, and tcl : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
Site Help
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Robert Bogomip <bob.bogo@milohedge.com>, June 6, 2001 1:38
If you have VisualC++ 6.0, then you are well
recommended to use the really cool delay loading
feature to delay-load the perl DLLs. The advantage of
this is that if your machine doesn't have a suitable
perl DLL available, then gvim will still run fine (so
long as you don't try to use any perl inside the vim
session of course). Oh, and since the Perl DLL uses the
C runtime in DLL form (msvcrt.dll), then gvim/vim
should also do this (that's "/MD" in uSoft speak). In
Makefile,w32 I use:
CFLAGS = $(CFLAGS) -DNDEBUG /Ox /G6 /Ob1 /Os /MD /Gy
PERL_LIB = /DelayLoad:perl56.dll
$(PERL)\Lib\Core\perl56.lib DelayImp.lib
(i.e., the link line has "/DelayLoad:perl56.dll" added.
Some stub code is required to support delay loading,
and uSoft supply this in DelayImp.lib). I also find
that I need to append "/I $(PERL)\Lib\MSWin32-x86\Core"
http://www.vim.org/tips/tip.php?tip_id=46 (1 of 2) [18/02/2004 14:42:05]
Tip #46 - Win32 binaries with perl, python, and tcl : vim online
to PERL_INC too.
gerhard@bigfoot.de, February 4, 2002 11:53
http://www.cs.fhm.edu/~ifw00065/vim/
The current CVS version of Vim (post 6.0.158) compiled
for Windows with the Python interface enabled (Python
2.2) plus VisVim and OLE. IOW, everything like the
standard 6.0.0 release from the Vim folks, just newer
and with Python 2.2 support. Using the latest NSIS
installer with bip2 compression, it's also much smaller
than the original. It's only 2.3 megs :-)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
<<Win32 binaries with perl, python, and tcl | Moving around >>
Additional Notes
Unfulfilling
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
$
<End>
0
<Home>
move
move
move
move
move
-
to
as
to
as
)
(
}
{
H
M
L
'm
`m
G
- jump to end of file
1G - jump to beginning of file
50G - jump to line 50
'' - return to the line where the cursor was before the
latest jump
http://www.vim.org/tips/tip.php?tip_id=48 (1 of 2) [18/02/2004 14:42:10]
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
pevans@lehman.com, June 19, 2002 4:51
^
g_
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
3~
g~~
text)
U
uppercase
gUU
u
lowercase
guu
gUaw
guaw
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
harri.haataja@cs.helsinki.fi, May 7, 2002 6:40
Not exactly case related but something I really like.
g?
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
joachim.hof@gmx.de, August 4, 2002 14:13
A little supplement:
German umlauts are: /, /, / , and moreover there
is ''.
These are CTRL-K plus:
a" resp A"
o" resp O"
u" resp U"
ss
-- Examples: -hnlich = similar
Rhre = tube
mde = tired
Strae = street
-- Some french words: -Ren - popular first name
Caf - coffee house
Ampre - French physicist, 1775 - 1836
The 'e' with a hat () is not german, it's french.
l in Danish is beer.
Joachim Hofmann (Schuttberg)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
Additional Notes
dp@orion.spectral-sys.com, April 20, 2001 13:43
rate
j
j
k
k
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Scrolling synchronously | View a Java Class File Decompiled thru Vim >>
Additional Notes
bindu@wavell.net, November 10, 2001 23:52
I just checked this in 6.0 and you no longer have to
turn syntax off and then back on.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #54 - View a Java Class File Decompiled thru Vim : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: intermediate
as of Vim: 5.7
Hi All,
Wish u could view a Java Class File using Vim,
Well ur query ends here.
First of all u will need a Java Decompiler to decompile
the Class File.
I would suggest the JAD decompiler by Pavel Kouznetsov
http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
Site Help
Tip #54 - View a Java Class File Decompiled thru Vim : vim online
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
b.cerrina@wanadoo.fr, August 21, 2001 13:54
Hi,
first I love this script
I modified this a little bit to use the improved file
runtime organisation of vim60, I don't know if other will
like it better but here it is:
I added to filetype.vim:
augroup filetypedetect
au! BufRead,BufNewFile *.jad setfiletype java
au! BufRead,BufNewFile *.class setfiletype class
augroup END
and created in ftplugin a class.vim with
%!jad.exe -noctor -ff -i -p %
set readonly
set ft=java
normal gg=G
set nomodified
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<View a Java Class File Decompiled thru Vim | how to avoid obliterating window layout >>
Additional Notes
max@malva.com.ua, April 6, 2001 6:26
For explanaition of # magic see :help expand
Btw, see :help CTRL-^ to toggle buffers
fma to be found at cci.dk, June 14, 2001 6:42
This is roughly the same as :e# except for completion
See also help for :_# and CTRL-^
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
scottu@apptechsys.com, January 16, 2002 15:15
See tip vimtip #199 for a way to map these keys to a
maximize window - return to split structure function.
drchipN@OcampbellSfamilyP.AbizM, December 4, 2003 12:18
Another solution is given by ZoomWin (vimscript#508)
which makes <c-w>o
toggle between the multi-window display and a single
window.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
Site Help
:'<,'>BCtrl-V
Just continue with the substitute or whatever...
:'<,'>B s/abc/ABC/g
and the substitute will be applied to just that block of
text!
Example: Ctrl-V Select..........|......Type
..................just the central....|......:B s/abc/ABC/g
..................four "abc"s..............|
..................----------------....|...------------..................abcabcabcabc............|......abcabcabcabc
..................abcabcabcabc............|......abcABCABCabc
..................abcabcabcabc............|......abcABCABCabc
..................abcabcabcabc............|......abcabcabcabc
(dots inserted to retain tabular format)
Life Changing
Helpful
Unfulfilling
rate
<<how to avoid obliterating window layout | Applying substitutes to a visual block >>
Additional Notes
Add Note
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: intermediate
as of Vim: 5.7
Site Help
:'<,'>BCtrl-V
Just continue with the substitute or whatever...
:'<,'>B s/abc/ABC/g
and the substitute will be applied to just that block of
text!
Example: Ctrl-V Select..........|......Type
..................just the central.......|......:B
s/abc/ABC/g
..................four "abc"s.................|
..................---------............|...------------..................abcabcabcabc............|......abcabcabcabc
..................abcabcabcabc............|......abcABCABCabc
..................abcabcabcabc............|......abcABCABCabc
..................abcabcabcabc............|......abcabcabcabc
(dots inserted to retain tabular format)
Life Changing
Helpful
Unfulfilling
rate
<<Applying substitutes to a visual block | Always set your working directory to the file you're editing >>
Additional Notes
Anonymous, June 15, 2001 6:51
I fear I may not have conveyed the idea properly. Its not
referring
merely to a block of lines but to a visual-block (ie. a
subset of the
characters) and restricting the substitute to refer only to
that visual
block.
I want to convert just the some of the central "cab"
strings to CAB;
use ctrl-v and motion (hjkl or cursor keys) to select the
"cab" strings
to be transformed via a visual-block selection:
to
---->
abcabcabcabcabc
abcabcabcabcabc
abcabcabcabcabc
abcabcabcabcabc
abcabcabcabcabc
abcabcabcabcabc
abcabCABcabcabc
abcabCABcabcabc
abcabCABcabcabc
abcabcabcabcabc
printf("...",
abc[0],DEF[0],ghi[0],
abc[1],DEF[1],ghi[1],
abc[2],DEF[2],ghi[2],
abc[3],DEF[3],ghi[3],
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #64 - Always set your working directory to the file you're editing : vim online
Home
Search
Tip #64: Always set your working directory to the file you're editing
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Applying substitutes to a visual block | Insert line number into the actuall text of the file. >>
Additional Notes
Alexey Marinichev, June 5, 2001 10:54
Tip #64 - Always set your working directory to the file you're editing : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #65 - Insert line number into the actuall text of the file. : vim online
Home
Search
Tip #65: Insert line number into the actuall text of the file.
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Although :set number will add nice line number for you
At time you may wish to actually place the line numbers
into the file. For example on GNU Unix you can acomplish
a simular task using cat -n file > new_file
In VIM you can use the global command to do this
:g/^/exec "s/^/".strpart(line(".")."
", 0, 4)
What this does is run the exec comand on every line that
matches /^/ (All)
The exec command taks a string and executes it as if it
were typed in.
line(".")."
" -> returns the number of the current
line plus four spaces.
strpart("123
", 0, 4) -> returns only the first four
characters ("123 ").
"s/^/123 " -> substituts the begining of the line with
"123 ".
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Always set your working directory to the file you're editing | Transfer text between two Vim
'sessions', >>
Additional Notes
ktohg@tritarget.com, April 5, 2001 17:02
Tip #65 - Insert line number into the actuall text of the file. : vim online
",0,4)
",0,&ts)
',0,5)
Tip #65 - Insert line number into the actuall text of the file. : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #66 - Transfer text between two Vim 'sessions', : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
<<Insert line number into the actuall text of the file. | Ascii Value >>
Additional Notes
http://www.vim.org/tips/tip.php?tip_id=66 (1 of 2) [18/02/2004 14:42:39]
rate
Tip #66 - Transfer text between two Vim 'sessions', : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
dp@orion.spectral-sys.com, May 9, 2001 6:35
You can also add options to the statusline option to
show what the
ascii value of the character under the cursor is.
set statusline=%<%f%h%m%r%=%b 0x%B %l,%c%V %P
^^^^^^^^
The underlined part is what does it.
scrott@users.sourceforge.net, May 9, 2001 22:29
The mnemonic I use to remember ga is "get ascii" but I
guess that is an obvious one...
stephane@tuxfinder.org, June 5, 2001 5:00
doesn't work with multibyte editing :-(
Alexey Marinichev, June 7, 2001 14:57
For multibyte use g8.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Anonymous, May 16, 2001 3:14
Does not work!
Try mapping.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
You can copy and paste the last changes you made in the
last insert mode
without using y and p by pressing . (just dot).
Vim memorizes the keys you pressed and echos them if you
hit the dot key.
You must be in command mode as usual.
It can be helpful...
Site Help
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
erhan@aybim.com.tr, May 30, 2001 23:22
You can also repeat the last command you write by
pressing dot.
So, it makes it easier to repeat 2-3 character long
commands.
Anonymous, June 4, 2001 13:23
duh.
Anonymous, September 10, 2001 1:11
You can insert last change with C-A in Insert mode too.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<dot makes life easier | Transfer text between two gvim sessions using clipboard >>
Additional Notes
amackay@s.gusnet.cx, June 4, 2001 19:07
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #71 - Transfer text between two gvim sessions using clipboard : vim online
Home
Search
Tip #71: Transfer text between two gvim sessions using clipboard
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
If you use gvim, you can transfer text from one instance
of gvim into another one using clipboard. It is
convenient to use * (star) register, like this:
In one instance yank two lines into clipboard:
"*2yy
Paste it in another instance in normal mode:
"*p
or in insert mode:
<Ctrl-R>*
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
benfranklin@sortonce.com, May 31, 2002 20:10
In gvim, for the "copy to clipboard" command, Ctrl+C
works just as well on highlighted text as "*p.
This works for both text in the edit buffer and
characters on the command line.
-- Ben
benfranklin@sortonce.com, May 31, 2002 20:11
Oops, I meant Ctrl+C works like "*y.
-- Ben
anthony, September 22, 2002 18:32
Now if you can only do the same between two vim's
runing in xterms!
Tip #71 - Transfer text between two gvim sessions using clipboard : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<Transfer text between two gvim sessions using clipboard | Using vim as calculator >>
Additional Notes
Anonymous, July 13, 2001 20:42
I know this may sound like trolling, but this makes me
wonder why there's not an option to rate suggestions
"Detremental".
Anonymous, January 13, 2004 1:00
Detrimental? In my opinion tips like these are useful
since they show up nicely when you for example
google for this little hint you just needed.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
Site Help
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
maxiangjiang@yahoo.com, July 25, 2001 16:20
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Using vim as calculator | Remap CAPSLOCK key in Windows 2000 Professional and NT4.0 >>
Additional Notes
Anonymous, June 9, 2001 20:15
Awesome.... just what I needed!
ned@bike-nomad.com, September 8, 2003 10:23
If you're interested in outlining in Vim, you should also
check out my TVO
http://www.vim.org/script.php?script_id=517
Add Note
SourceForge
Logo
Tip #75 - Remap CAPSLOCK key in Windows 2000 Professional and NT4.0 : vim online
Home
Search
Tip #75: Remap CAPSLOCK key in Windows 2000 Professional and NT4.0
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
If you're Windows 2000 Professional user and got tired to move your hands off
basic row when hitting <ESC> key
here the solution (not for Windows 9x.):
remap CapsLock key as <ESC> key. It's located in useful position.
Put this lines into <EscLock.reg> file and start it in explorer.Reboot.Enjoy.
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,01,00,3a,00,00,00,00,00
To restore you capslock back just delete this entry from Registry and reboot.
And below is remapping <capslock> as <Left Control>:
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
Life Changing
Helpful
Additional Notes
gmargo@yahoo.com, July 15, 2001 10:15
Unfulfilling
rate
Tip #75 - Remap CAPSLOCK key in Windows 2000 Professional and NT4.0 : vim online
Windows:
There is an excellent free tool available to remap the capslock to control ,
thereby putting a control key in "the right place"(tm).
I think the source code is included too.
There are versions for both WinNT/2000 and Win98/95/Me.
Look on http://www.sysinternals.com/.
While they are easy to find, here are the direct links:
http://www.sysinternals.com/ntw2k/source/ctrl2cap.shtml
http://www.sysinternals.com/win9x/utilities/ctrl2cap95.shtml
Linux/Unix:
Here's how to map the caps lock key to a control under X windows,
at least under xfree86-3.x and 4.x:
Add a file named ".Xkbmap" in your home directory with this content:
-option ctrl:nocaps
hans@fugal.net, July 19, 2001 7:01
It would be useful to remap caps lock to some other out-of-the-way key.
linux I map it to F4, but how would I do that in w2k?
In
Tip #75 - Remap CAPSLOCK key in Windows 2000 Professional and NT4.0 : vim online
Personally, I just hit ctrl-[ (that's holding the control key and the left angle
bracket down at the same time), which creates the escape key almost
anywhere. I'm so used to touch typing it I don't even think about it any more.
niczero@yahoo.com, August 15, 2002 9:31
Having such a large part of my UI for functionality as obscure as capslock is
strange indeed.
My ideal setup would be to have <CapsLock> do nothing at all so accidental hits
don't mess
up my blind typing, and to have it effective if I'm also holding down <Shift>
(for those rare
occasions when I feel like SHOUTING).
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
The Quickfix mode aims to "speed up the edit-compileedit cycle" according to ':help quickfix'. After
executing ':make' or ':grep' it is possible to skim
through the list of errors/matches and the appropriate
source code locations with, for instance, the ':cnext'
command.
Another way to get a quick overview is to use VIMs
folding mode, to fold away all the error-free/match-free
regions.
The script at the end of this message can be used for
this purpose. It is at the moment not elaborate enough
to put it up as a 'script'; but it might give someone
inspiration to do so.
Big restrictions / bugs are as follows:
1. Vim Perl interface is required, i.e. the output of
':version' must contain '+perl' (People with Vim
scripting knowledge might fix this)
2. Works only for one file, i.e. the current buffer.
3. It's a quick hack.
Sample usage: (a) edit a file, (b) do ':grep regexp %'
to get a quickfix error list and (c) ':source
foldqf.vim' will fold as described
Increasing the value of $CONTEXT gives you more context
around the error regions.
Here comes it, it should be 7 lines:
---foldqf.vim
cwindow
perl $CONTEXT = 0;
perl @A = map { m/\|(\d+)\|/; $1 +0 } $curbuf>Get(1..$curbuf->Count());
close
normal zD
perl sub fold { VIM::DoCommand( $_[0] . ',' . ($_[1]) .
"fold" ) if( $_[0] < $_[1] ); }
perl $last = 0; for (@A) { fold( $last+1+$CONTEXT, $_-1$CONTEXT ); $last = $_; }; VIM::DoCommand(($A[-
1]+1+$CONTEXT ) . ',$fold' );
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Remap CAPSLOCK key in Windows 2000 Professional and NT4.0 | Displaying search results using
folds >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
" Now create the last fold which goes to the end of the
file.
normal $G
let line2 = line(".")
"echo "end of file found at line # " line2
if (line2 > line1 && folded == 1)
"echo line1 . ":" . line2
"echo "A fold goes here."
execute ":". line1 . "," . line2 .
"fold"
endif
endfunction
" Command is executed as ':Fs pattern'"
command! -nargs=+ -complete=command Fs call
Foldsearch(<q-args>)
" View the methods and variables in a java source file."
command! Japi Fs public\|protected\|private
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
bismuti@cs.fsu.edu, June 11, 2001 15:38
The comments I added broke the script, just delete
before trying to run.
bismuti@cs.fsu.edu, June 11, 2001 15:41
This pattern works better to create a Java API, it
enforces white space
at the end of the word.
public\s\|protected\s\|private\s
igor@tyumbit.ru, June 20, 2001 21:18
If foldmethod=syntax then VIM complains " E352: Cannot
erase folds with current 'foldmethod' "
Need to check if foldmethod = syntax then normal zR
cz_butler@yahoo,com, June 16, 2002 20:50
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
For people using mutt and vim for mail, the following
script will allow you to insert a new signature (and
again and again if you don't like the current one) at
the bottom of your mail. This is usefull eg when you
don't want to send a potentially offensive quote to
someone you don't know very well (or a mailing list),
but are too lazy to delete the quote, open your quotes
file, and cut and paste another one in. (I put it here
in 'tips' and not in 'scripts' because it is imo too
short to be a 'real' script)
" rotate_sig.vim
" Maintainer: Roel Vanhout <roel@2e-systems.com>
" Version:
0.1
" Last Change: Tuesday, June 12, 2001
" Mapping I use:
" nmap ,r :call RotateSig()<CR>
" Usage:
" -Make sure you delimit your sig with '-- ', or adjust
the script
" -Adjust the last execute to a command that prints a
sig to stdout
" Known problems:
"
- You'll get an error message when you're below the
last
"
'^-- $' in your mail (nothing bad though - just an
not"
found marker)
function! RotateSig()
normal mQG
execute '?^-- $'
execute ':nohl'
normal o<ESC>
normal dG
normal <CR>
execute 'r !~/bin/autosig ~/.quotes \%'
normal `Q
endfunction
Life Changing
Helpful
Unfulfilling
rate
<<Displaying search results using folds | How to use :grep to get a clickable list of function names >>
Additional Notes
roel@2e-systems.com, June 13, 2001 0:55
...and ofcourse, tonight I had an idea that this could
be done better & shorter:
:nmap ,t mQG:?^-- $<CR>:nohl<CR>o<ESC>dG:r
!~/bin/autosig ~/.quotes \%<CR>`Q
heh :-)
harri.haataja@cs.helsinki.fi, May 7, 2002 8:34
Mutt has an extensive hooks system that allows things
like this.
set signature="fortune $HOME/.fortunes/other
$HOME/.fortunes/computer |"
send-hook
'~t @networksolutions' 'unset
signature'
send-hook
'~t @orkplace'
'set
signature=~/.signature_official'
etc.
Now what I'd like to see is a thing that does a light
keyword analysis on the message and select an
appropriate quote emulating an extremely kind
sigmonster :-)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #79 - How to use :grep to get a clickable list of function names : vim online
Home
Search
Tip #79: How to use :grep to get a clickable list of function names
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<rotating mail signatures | Restore cursor to file position in previous editing session >>
Additional Notes
tim@johnsons-web.com, June 14, 2001 9:11
Tip #79 - How to use :grep to get a clickable list of function names : vim online
Tip #79 - How to use :grep to get a clickable list of function names : vim online
Tip #79 - How to use :grep to get a clickable list of function names : vim online
Try this
function! ShowFunc(sort)
let gf_s = &grepformat
let gp_s = &grepprg
if ( &filetype == "c" || &filetype == "php" ||
&filetype == "python" ||
\ &filetype == "sh" )
let &grepformat='%*\k%*\sfunction%*\s%l%*\s%f %m'
let &grepprg = 'ctags -x --'.&filetype.'-types=f -sort='.a:sort
elseif ( &filetype == "perl" )
let &grepformat='%*\k%*\ssubroutine%*\s%l%*\s%f %m'
let &grepprg = 'ctags -x --perl-types=s -sort='.a:sort
elseif ( &filetype == "vim" )
let &grepformat='%*\k%*\sfunction%*\s%l%*\s%f %m'
let &grepprg = 'ctags -x --vim-types=f --languageforce=vim --sort='.a:sort
endif
if (&readonly == 0) | update | endif
silent! grep %
cwindow 10
redraw
let &grepformat = gf_s
http://www.vim.org/tips/tip.php?tip_id=79 (4 of 6) [18/02/2004 14:43:18]
Tip #79 - How to use :grep to get a clickable list of function names : vim online
Tip #79 - How to use :grep to get a clickable list of function names : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #80 - Restore cursor to file position in previous editing session : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<How to use :grep to get a clickable list of function names | Substitution of characters and lines in VIM is made far
easier with the s and S commands >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #81 - Substitution of characters and lines in VIM is made far easier with the s and S commands : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Substitute Characters
----------------------------------I was just editing a file that contained the same
leading string on many lines.
example:
foo_bar_baz1=a
foo_bar_baz1=abc674
foo_bar_baz1=qrs
foo_bar_baz1=m1
foo_bar_baz1=bz90
foo_bar_baz1=bc
...
Needing to only substitute a portion of the string, I
referred to a VIM reference card and discovered a
command answering my need exactly. The s command is used
to subsitute a certain number of characters. In my
example file above, if I only needed to subsititute the
characters foo_bar, I set the cursor on the first
character where I'd like the subsitution to begin and
type 7s. VIM drops the characters foo_bar and goes to
insert mode, waiting for the substitution text.
Substitute Lines
----------------------After years of using vi and VIM and always deleting
multiple lines in order to replace them, I just
discovered the S command. If you need to subsitute three
lines of text, simply type 3S. VIM drops the three lines
and goes into insert mode, waiting for the subsitution
text.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Tip #81 - Substitution of characters and lines in VIM is made far easier with the s and S commands : vim online
<<Restore cursor to file position in previous editing session | letting variable values be overwritten in a
script >>
Additional Notes
leifw at bigfoot dot com, July 11, 2001 14:12
Of course, if you're lazy like me and you don't want to
count that there are 7 characters that you want to
replace, you could use the c command and use a motion
to specify how much to kill. For example, in the
previous example, I'd type c2t_ to kill foo_bar and to
be left in insert mode.
bdr at users.sourceforge.net, August 29, 2001 8:11
You could have selected the "foo_bar" characters with
Ctrl+V (Visual Block), pressed "c" to change the block,
made your change to the first line, press ESC and,
voil, all the lines you selected will be changed the
same way.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Substitution of characters and lines in VIM is made far easier with the s and S commands | how to
indent (useful for source code) >>
Additional Notes
salmanhalim@hotmail.com, June 22, 2001 9:19
it seems as if the s: bit only works if the function is
defined as part of a script (using the s:GetVar)
notation (this is how i had it initially before
deciding it might be useful in general).
my apologies for the premature post.
salman.
salmanhalim@hotmail.com, July 18, 2001 13:51
i tweaked GetVar to no longer look for a script
variable (since i couldn't get it to work
anyway). instead, i have added an optional second
parameter which becomes the value returned if neither a
buffer or a global variable is found -- -1 is still
returned if the second parameter is unspecified:
function! GetVar(...)
let varName=a:1
if (exists("a:2"))
let retVal=a:2
else
let retVal=-1
endif
if (exists ("b:" . varName))
exe "let retVal=b:" . varName
elseif (exists ("g:" . varName))
http://www.vim.org/tips/tip.php?tip_id=82 (2 of 3) [18/02/2004 14:43:28]
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #83 - how to indent (useful for source code) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<letting variable values be overwritten in a script | Changing the behaviour of . to include visual mode
>>
Additional Notes
Debian@austin dot rr dot com, June 26, 2001 16:51
Tip #83 - how to indent (useful for source code) : vim online
rah! :))
soren.edzen@frontec.se, July 24, 2001 6:14
How do you unindent?
--se
eugenehuang @ canada.com, July 24, 2001 18:33
Tip #83 - how to indent (useful for source code) : vim online
Tip #83 - how to indent (useful for source code) : vim online
You can use pretty much any selection method for indent
"="
1. To indent within braces do " =%"
2. To indent a block
select the beginning of the block by placing a
bookmark
e.g.
" ma" where a is the name of the
buffer (any character)
scroll to the end of the block and do " ='a "
3. multiple lines
"n==" where n is the number of lines
michael.wardle@adacel.com, May 16, 2002 19:54
It is possible to add a line to a source file that says
how Emacs should display a file such as:
/* -*- Mode: C; tab-width:8 -*- */
Is this possible in vi/vim (and if so, then how?)?
michael.wardle@adacel.com, May 20, 2002 0:39
It seems possible by adding this near the top:
ex: set (options):
So to set tabstops to 8 spaces in a C source file, you
would do something like this:
/* ex: set ts=8: */
On my system, this causes vim to automatically use this
option as if it were specified
in my .vimrc, but you may also need to do ":set
modeline" for your editor to look for
these options in the source file.
ser at germane dash software dot com, September 8, 2002 18:18
All of these diverse ways of doing the same
thing. That is very cool.
Another way of cleaning the indentation of the entire
file:
:%=
seanahern@llnl.gov, June 20, 2003 21:25
Tip #83 - how to indent (useful for source code) : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #84 - Changing the behaviour of . to include visual mode : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Tip #84 - Changing the behaviour of . to include visual mode : vim online
Life Changing
Helpful
Unfulfilling
rate
<<how to indent (useful for source code) | How to mimic the vim 6.0 plugin feature with older versions
>>
Additional Notes
fatty@aol.com, July 10, 2001 20:32
Wow!
Tip #84 - Changing the behaviour of . to include visual mode : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #85 - How to mimic the vim 6.0 plugin feature with older versions : vim online
Home
Search
Tip #85: How to mimic the vim 6.0 plugin feature with older versions
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
If you do not have vim 6.0, but would like to mimic the
plugins directory feature then copy and paste this into
your vimrc:
exec "source " . substitute(glob($VIM."/plugins/*.vim"),
"\n", "\nsource ", "g")
It will automatically source every vim script file
located in the vim/plugins directory.
Now, to add a new plugin, just drop the script in this
directory and vim will automatically find it.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Changing the behaviour of . to include visual mode | Helps undo 1 line when entered many >>
Additional Notes
mankin@yahoo.no.com.spam, July 8, 2001 10:15
Does anybody know how to have vim look in your home
directory for the plugins directory?
-David Mankin
Anonymous, August 14, 2001 9:35
Use $HOME, or ~ (tilde), instead of $VIM. If you use
tilde, it must be inside the quotes. The $VIM (or
$HOME) may be placed inside the quotes as well glob("$VIM/plugins/*.vim") works just fine.
Add Note
Tip #85 - How to mimic the vim 6.0 plugin feature with older versions : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #86 - Helps undo 1 line when entered many : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<How to mimic the vim 6.0 plugin feature with older versions | Get vim 5.x window in vim 6.x >>
Additional Notes
rnd@softhome.net, July 9, 2001 14:26
nice tip. but U definitely should improve your English
:)
yozh@mx1.ru, July 13, 2001 11:17
Thanks for advice (about English :) Anywhen I'll learn
it :)
I saw 1 bug of this tip: autoindent don't work. How to
correct this?
Yozh.
yozh@mx1.ru, July 13, 2001 11:22
Tip #86 - Helps undo 1 line when entered many : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #87 - Get vim 5.x window in vim 6.x : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Helps undo 1 line when entered many | How to maximize vim on entry (win32) >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Get vim 5.x window in vim 6.x | Get more screen real estate by hidding toolbar and/or menus >>
Additional Notes
bindu@wavell.net, November 11, 2001 13:20
In Windows, you can control this from your VIM shortcut
(and even add a keyboard shortcut that will bring up
VIM from anywhere.) Right click on your Icon select
properties and fiddle with the Run and Short cut key
entries. I use Shift-Control-Alt-V to start VIM from
anywhere. If VIM is already running this will switch to
the most recently used instance of VIM.
kbgaddis@hotmail.com, January 10, 2002 21:59
anyone know how to get this functionality to work in X
with gvim? please email me if so...
libberspam@atlaswebmail.com, February 8, 2003 11:36
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #89 - Get more screen real estate by hidding toolbar and/or menus : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #89: Get more screen real estate by hidding toolbar and/or
menus
tip karma
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Additional Notes
tomk@emcity.net, July 29, 2002 12:17
Unfulfilling
rate
Tip #89 - Get more screen real estate by hidding toolbar and/or menus : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Get more screen real estate by hidding toolbar and/or menus | Dictionary completions >>
Additional Notes
rolando@extended.de, August 6, 2001 16:02
carefull!
vim asks only ONCE for the password -- if you happen to
misstype it -- then good luck finding out what you
misstyped.
Was that fixed in newer releases?
aloah Roland
charles.e.campbell.1@gsfc.nasa.gov, August 14, 2001 8:18
:%!pgp -f
:%!pgp -fc
u
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
shown below:
:set complete-=k complete+=k
Now, while in insert mode we can type the following to
complete our example:
acknow<CTRL-N><CTRL-N>
This shortcut may not save a whole lot of
typing. However, I find that it requires less hand
movement to only worry myself with two key combinations,
rather than 4.
I find that the completion facilites provided by vim
save me a *HUGE* amount of typing. These savings can be
realized in only a short amount of time if you are
editing some code with functions and variables that have
long names with underscores in them.
For more help:
help ins-completion
help compl-dictionary
help 'complete'
help 'dictionary'
help :set+=
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
mayureshk@aftek.com, January 25, 2002 0:23
thats really cool. Any idea how i can get to do the
same for Java/Perl/php/etc Key-words ? Lovely tip
though .. :)
Larry Clapp <vim@theclapp.org>, February 20, 2002 7:56
Very helpful.
I'm an emacs user, emacs has the same sort of thing
(via ESC-/)
I was wondering how vi does this. I was searching on vi
+ dabbrev with little success.
For anyone else doing a search, I'll add the words
'dabbrev' 'dabbrev mode' 'auto completion' 'dynamic
abbreviation'
'dynamic completion' META-/ in this post. 'dabbrev for
vi', as those were the words I was googling for.
One thing about vi that always impressed me was it's
fast startup time though. It runs a lot cleaner.
So, M-/ is ^X-I - ^X-N - ^X -P in vi. Vi does seem a
bit harder in that way, but, as far as I've seen, emacs
doesn't have the
dictionary functionality (emacs just uses M-/, after
the first time it considers additional M-/'s as VI
considers ^X-N's until you edit.)
I've been trying to learn vi so I can poke fun at vi
users properly. :-)
Well, that and so I'm not lost when the only editor in
town is /bin/vi.
<rant>
My dislike for vi started in the old days when internet
cost big $ to use ( I mean, long distance + hourly rate
+ terminal server) and.. I got dumped into vi w/out
knowing how to get out of it. Knowing ESC-:q! would
have saved me some cash. :-/ I do think editors (or at
least people who implement menu systems that dump new
users into editors) should show some place on the
status line how to exit.
</rant>
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Dictionary completions | if you use 'highlight search' feature, map a key to :noh >>
Additional Notes
rnd@softhome.net, July 23, 2001 5:48
there is a
set helpfile=/usr/share/vim/vim60u/doc/help.txt.gz
wichert@wiggy.net, July 30, 2001 3:43
For a demonstration of how this works you can look at
the Debian packages for
vim since, well, before the changelog starts at least
(which is september 1999).
wichert@wiggy.net, August 1, 2001 4:02
Silly typo, that should be 1997.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #93 - if you use 'highlight search' feature, map a key to :noh : vim online
Home
Search
Tip #93: if you use 'highlight search' feature, map a key to :noh
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Reducing 'doc' directory size | Questions & Answers about using tags with Vim >>
Additional Notes
Anonymous, August 3, 2001 9:56
"In order to run it off..." should read "In order to
turn it off...". And just in case it's not obvious
from my explanation, after you add the mapping to your
.vimrc file, you can turn off search highlights by
hitting control-n, or whatever other key you mapped
":noh" to.
Brandels_Mikesh@web.de, August 4, 2001 15:10
Tip #93 - if you use 'highlight search' feature, map a key to :noh : vim online
Tip #93 - if you use 'highlight search' feature, map a key to :noh : vim online
:echo "Highlights
Tip #93 - if you use 'highlight search' feature, map a key to :noh : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #94 - Questions & Answers about using tags with Vim : vim online
Home
Search
Tip #94: Questions & Answers about using tags with Vim
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Tip #94 - Questions & Answers about using tags with Vim : vim online
This
3. You can use jtags for generating tags file for java
programs.
You can download jtags from:
http://www.fleiner.com/jtags/
4. You can use ptags for generating tags file for perl
programs.
You can download ptags from:
http://www.eleves.ens.fr:8080/home/nthiery/Tags/
5. You can download scripts from the following links for
generating tags file for verilog files:
http://www.probo.com/vtags.htm
http://www.cs.albany.edu/~mosh/Perl/veri-tags
http://www.verilog.net/vrtags.txt
6. You can download Hdrtag from the following linke:
http://www.erols.com/astronaut/vim/index.html#Tags
This utility generates tags file for the following
programming
languages: assembly, c/c++, header files, lex,
yacc,LaTeX, vim,
and Maple V.
7. You can also use the following scripts which are part of
the Vim
runtime files:
pltags.pl - Create tags file for perl code
tcltags - Create tags file for TCL code
shtags.pl - Create tags file for shell script
Help keyword(s): ctags
3. How do I generate a tags file using ctags?
You can generate a tags file for all the C files in the
current
directory using the following command:
$ ctags *.c
You can generate tags file for all the files in the current
directory and all the sub-directories using (this applies
only to
exuberant ctags):
Tip #94 - Questions & Answers about using tags with Vim : vim online
$ ctags -R .
You can generate tags file for all the files listed in a
text file
named flist using (this applies only to exuberant ctags)
$ ctags -L flist
4. How do I configure Vim to locate a tags file?
You can set the 'tags' option in Vim to specify a particular
tags
file.
set tags=/my/dir/tags
Help keyword(s): 'tags', tags-option
5. How do I configure Vim to use multiple tags files?
The 'tags' option can specify more than one tags file.
The
tag
filenames are separated using either comma or spaces.
set tags=/my/dir1/tags, /my/dir2/tags
6. How do I configure Vim to locate a tags file in a directory
tree?
Note that the following will work only in Vim 6.0 and
above. You
can set the 'tags' option to make Vim search for the tags
file in a
directory tree. For example, if the 'tags' option is set
like
this:
set tags=tags;/
Vim will search for the file named 'tags', starting with the
current directory and then going to the parent directory and
then
recursively to the directory one level above, till it either
locates the 'tags' file or reaches the root '/' directory.
Help keyword(s): file-searching
7. How do I jump to a tag?
There are several ways to jump to a tag location.
1. You can use the 'tag' ex command. For example,
:tag <tagname>
will jump to the tag named <tagname>.
2. You can position the cursor over a tag name and then
Tip #94 - Questions & Answers about using tags with Vim : vim online
press
Ctrl-].
3. You can visually select a text and then press Ctrl-]
to
jump to the tag matching the selected text.
4. You can click on the tag name using the left mouse
button,
while pressing the <Ctrl> key.
5. You can press the g key and then click on the tag
name
using the left mouse button.
6. You can use the 'stag' ex command, to open the tag
in a new
window.
For example,
:stag func1
will open the func1 definition in a new window.
7. You can position the cursor over a tag name and then
press
Ctrl-W ].
window.
Help keyword(s): :tag, Ctrl-], v_CTRL_], <C-LeftMouse>,
g<LeftMouse>, :stag, Ctrl-W_]
8. How do I come back from a tag jump?
There are several ways to come back to the old location from
a tag
jump.
1. You can use the 'pop' ex command.
2. You can press Ctrl-t.
3. You can click the right mouse button, while pressing
the
<Ctrl> key.
4. You can press the g key and then click the right
mouse
button.
Help keyword(s): :pop, Ctrl-T, <C-RightMouse>, g<RightMouse>
9. How do I jump again to a previously jumped tag location?
You can use the 'tag' ex command to jump to a previously
jumped tag
location, which is stored in the tag stack.
Help keyword(s): tag
10. How do I list the contents of the tag stack?
Vim remembers the location from which you jumped to a tag in
the
tag stack.
Tip #94 - Questions & Answers about using tags with Vim : vim online
'tags' ex
command.
Help keyword(s): :tags, tagstack
11. How do I jump to a particular tag match, if there are
multiple
matching tags?
In some situations, there can be more than one match for a
tag.
For example, a C function or definition may be present in
more
than one file in a source tree. There are several ways to
jump to
a specific tag from a list of matching tags.
1. You can use the 'tselect' ex command to list all the
tag
matches.
For example,
:tselect func1
will list all the locations where func1 is
You can
then enter the number of a tag match to jump to that
location.
2. You can position the cursor over the tag name and
defined.
press g]
to get a list of matching tags.
3. You can visually select a text and press g] to get a
list
of matching tags.
4. You can use the 'stselect' ex command.
This will
open the
selected tag from the tag list in a new window.
5. You can position the cursor over the tag name and
press
Ctrl-W g] to do a :stselect.
Help keyword(s): tag-matchlist, :tselect, g], v_g],
:stselect,
Ctrl-W_g]
12. I want to jump to a tag, if there is only one matching tag,
otherwise a list of matching tags should be displayed. How
do I
do this?
There are several ways to make Vim to jump to a tag
directly, if
there is only one tag match, otherwise present a list of
tag
matches.
Tip #94 - Questions & Answers about using tags with Vim : vim online
For example,
:tjump func1
will jump to the definition func1, if it is defined
only
once. If func1 is defined multiple times, a list of
matching tags will be presented.
2. You can position the cursor over the tag and press g
Ctrl-].
3. You can visually select a text and press g Ctrl-] to
jump
or list the matching tags.
4. You can use the 'stjump' ex command.
the
matching or selected tag from the tag list in a new
window.
5. You can press Ctrl-W g Ctrl-] to do a :stjump.
Help keyword(s): :tjump, g_Ctrl-], v_g_CTRL-], :stjump,
Ctrl-W_g_Ctrl-]
13. How do browse through a list of multiple tag matches?
If there are multiple tag matches, you can browse through
all of
them using several of the Vim ex commands.
1. To go to the first tag in the list, use the 'tfirst' or
'trewind' ex command.
2. To go to the last tag in the list, use the 'tlast' ex
command.
3. To go to the next matching tag in the list, use the
'tnext' ex
command.
4. To go to the previous matching tag in the list, use the
'tprevious' or 'tNext' ex command.
Help keyword(s): :tfirst, :trewind, :tlast, :tnext,
:tprevious,
:tNext
14. How do I preview a tag?
You can use the preview window to preview a tag, without
leaving
the original window. There are several ways to preview a
tag:
1. You can use the 'ptag' ex command to open a tag in
the
preview window.
2. You can position the cursor on a tag name and press
Ctrl-W
} to open the tag in the preview window.
http://www.vim.org/tips/tip.php?tip_id=94 (6 of 11) [18/02/2004 14:43:57]
Tip #94 - Questions & Answers about using tags with Vim : vim online
Tip #94 - Questions & Answers about using tags with Vim : vim online
search character.
For example,
:tag /<pattern>
:stag /<pattern>
:ptag /<pattern>
:tselect /<pattern>
:tjump /<pattern>
:ptselect /<pattern>
:ptjump /<pattern>
2. If you have the 'wildmenu' option set, then you can
press
the <Tab> key to display a list of all the matching
tags
in the status bar.
move
between the tags and then use the <Enter> key to
select a
tag.
3. If you don't have the 'wildmenu' option set, you
can still
use the <Tab> key to browse through the list of
matching
tags.
Help keyword(s): tag-regexp, wildmenu
18. What options are available to control how Vim handles the
tags
file?
You can use the following options to control the handling
of tags
file by Vim:
1. 'tagrelative' - Controls how the file names in the tags
file
are treated. When on, the filenames are
relative to the directory where the tags
file
is present.
2. 'taglength' characters
Tip #94 - Questions & Answers about using tags with Vim : vim online
the
current file using a Vim script.
script
from the following link:
http://members.home.net/jayglanville/tagsmenu/TagsMenu.html
21. Is there a workaround to make the Ctrl-] key not to be
treated as
the telnet escape character?
The default escape characters for telnet in Unix systems is
Ctrl-]. While using Vim in a telnet session, if you use
Ctrl-] to
jump to a tag, you will get the telnet prompt. There are
two ways
to avoid this problem:
1. Map the telnet escape character to some other character
using
the "-e <escape character>" telnet command line option
2. Disable the telnet escape character using the "-E"
telnet
command line option.
Help keyword(s): telnet-CTRL-]
Life Changing
Helpful
Unfulfilling
rate
<<if you use 'highlight search' feature, map a key to :noh | How do I pipe the output from ex commands into the
text buffer? >>
Additional Notes
sunda4u@yahoo.com, March 29, 2002 4:32
Tip #94 - Questions & Answers about using tags with Vim : vim online
Tip #94 - Questions & Answers about using tags with Vim : vim online
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #95 - How do I pipe the output from ex commands into the text buffer? : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #95: How do I pipe the output from ex commands into the text
buffer?
tip karma
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Questions & Answers about using tags with Vim | Cooperation of Gvim and AutoCad [MTEXT] >>
Additional Notes
Yegappan, August 7, 2001 11:45
Tip #95 - How do I pipe the output from ex commands into the text buffer? : vim online
That's awesome!!
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
&AutoCad.Font.Arial \fArial;
&AutoCad.Font.Arial <Esc>`<i\fArial;<Esc>%
&AutoCad.Font.Symbol \Fsymbol;
&AutoCad.Font.Symbol <Esc>`<i\Fsymbol;<Esc>%
&AutoCad.Font.RomanC \Fromanc;
&AutoCad.Font.RomanC <Esc>`<i\Fromanc;<Esc>%
&AutoCad.Font.RomanS \Fromans;
&AutoCad.Font.RomanS <Esc>`<i\Fromans;<Esc>%
&AutoCad.Font.RomanD \Fromand;
&AutoCad.Font.RomanD <Esc>`<i\Fromand;<Esc>%
&AutoCad.Font.RomanT \Fromant;
&AutoCad.Font.RomanT <Esc>`<i\Fromant;<Esc>%
imenu
vmenu
imenu
vmenu
imenu
vmenu
imenu
vmenu
&AutoCad.Size.0_5x \H0.5x;
&AutoCad.Size.0_5x <Esc>`<i\H0.5x;<Esc>%
&AutoCad.Size.1_5x \H1.5x;
&AutoCad.Size.1_5x <Esc>`<i\H1.5x;<Esc>%
&AutoCad.Size.2x \H2x;
&AutoCad.Size.2x <Esc>`<i\H2x;<Esc>%
&AutoCad.Size.3x \H3x;
&AutoCad.Size.3x <Esc>`<i\H3x;<Esc>%
vmenu &AutoCad.Effects.Set_Out_1_5
<Esc>`>a\T1;<Esc>`<i\T1.5;<Esc>%
imenu &AutoCad.Effects.Set_Out_2 \T2;
vmenu &AutoCad.Effects.Set_Out_2
<Esc>`>a\T1;<Esc>`<i\T2;<Esc>%
imenu &AutoCad.Effects.-SEP3- :
imenu &AutoCad.Effects.Tilt_15deg \Q15;
vmenu &AutoCad.Effects.Tilt_15deg
<Esc>`>a\Q0;<Esc>`<i\Q10;<Esc>%
imenu &AutoCad.Effects.Tilt_20deg \Q20;
vmenu &AutoCad.Effects.Tilt_20deg
<Esc>`>a\Q0;<Esc>`<i\Q20;<Esc>%
imenu &AutoCad.Effects.Tilt_30deg \Q30;
vmenu &AutoCad.Effects.Tilt_30deg
<Esc>`>a\Q0;<Esc>`<i\Q30;<Esc>%
imenu &AutoCad.Effects.-SEP4- :
imenu &AutoCad.Effects.Change_Width_0_5x \W0.5;
vmenu &AutoCad.Effects.Change_Width_0_5x
<Esc>`>a\W1;<Esc>`<i\W0.5;<Esc>%
imenu &AutoCad.Effects.Change_Width_2x \W2;
vmenu &AutoCad.Effects.Change_Width_2x
<Esc>`>a\W1;<Esc>`<i\W2;<Esc>%
imenu &AutoCad.Effects.-SEP5- :
imenu &AutoCad.Effects.Justify_Down \A0;
vmenu &AutoCad.Effects.Justify_Down <Esc>`<i\A0;<Esc>%
imenu &AutoCad.Effects.Justify_Middle \A1;
vmenu &AutoCad.Effects.Justify_Middle <Esc>`<i\A1;<Esc>%
imenu &AutoCad.Effects.Justify_Up \A2;
vmenu &AutoCad.Effects.Justify_Up <Esc>`<i\A2;<Esc>%
imenu &AutoCad.Effects.Overlined_Characters \O\o<Esc>F\i
vmenu &AutoCad.Effects.Overlined_Characters
<Esc>`>a\O<Esc>`<i\o<Esc>%
imenu &AutoCad.Effects.Underlined_Characters
\L\l<Esc>F\i
vmenu &AutoCad.Effects.Underlined_Characters
<Esc>`>a\l<Esc>`<i\L<Esc>%
imenu &AutoCad.Effects.Index_Top \S^;
imenu &AutoCad.-SEP6- :
imenu &AutoCad.Help <CR><CR>***Quit Editor: press Alt-F4
and 'No' ***<CR><CR>
star
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<How do I pipe the output from ex commands into the text buffer? | How do I add a current time
string inside Vim? >>
Additional Notes
markst@gte.net, August 9, 2001 8:38
Thanks for the tip. Here I thought I was the only
person to use AutoCAD and Vim. Does anybody use Vim to
write there Autolisp programs? It beats the heck out of
the Vlisp editor.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #97 - How do I add a current time string inside Vim? : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Cooperation of Gvim and AutoCad [MTEXT] | Getting vim help from mailing lists and newsgroups.
>>
Additional Notes
none, August 9, 2001 4:27
The best thing to do is install cygwin from
http://sources.redhat.com/cygwin.
This will give you 'date' and a host of other UNIX
utilities under windows.
salmanhalim@hotmail.com, August 9, 2001 5:54
Tip #97 - How do I add a current time string inside Vim? : vim online
abbreviations
<c-r>=strftime("%a %d %b %Y")<cr>
<c-r>=strftime("%y%m%d")<cr>
<c-r>=strftime("%c")<cr>
<c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>
<c-r>=strftime("%H:%M:%S")<cr>
Tip #97 - How do I add a current time string inside Vim? : vim online
UpdateTimeStamp()|'s
--- CHAINSAW OFF --My time stamp has the format
Time-stamp: <09 Aug 2001 02:32:42 Editors Name>
It is searched for in the first line of the file only
(you can certainly change that) in columns > 1. I did
that mainly for security reasons (in source code, there
will be almost always a comment start, e.g. /* in c,
preceding the time stamp).
Kind regards
Sven
charles.e.campbell.1@gsfc.nasa.gov, August 14, 2001 8:12
I use the following insert-maps in my <.vimrc>:
" Dates/Times
imap \ymd
<C-R>=strftime("%y%m%d")<CR>
imap \mdy
<C-R>=strftime("%m/%d/%y")<CR>
imap \Mdy
<C-R>=strftime("%b %d, %Y")<CR>
imap \hms
<C-R>=strftime("%T")<CR>
So, while in insert mode, a \ymd will insert the year,
month, and day in
the form 010814.
For html I have an autocmd that I use which fires on
write:
au BufWritePre *.html exe "norm mz"|exe '%s/\(<!-- DATE
-->\).\{-}\d\d:\d\d:\d\d/\1'.strftime("%b %d, %Y
%X")."/e"|norm `z
That way a string of the form <!-- DATE -->Aug 13, 2001
14:19:50
embedded in the text which will be updated to the
current date
(using Vim's built-in strftime() function) and time
automatically -every time I save the file (the ...DATE... stuff is an
HTML comment
which won't appear).
Tip #97 - How do I add a current time string inside Vim? : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #98 - Getting vim help from mailing lists and newsgroups. : vim online
Home
Search
Tip #98: Getting vim help from mailing lists and newsgroups.
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
There have been a few "requests for tips" entered into the tips
database lately. If you have specific questions that aren't
answered by the existing tips, there are a couple of resources
that may be more appropriate:
The mailing list vim@vim.org is for vim users.
email to vim-help@vim.org, you'll get a message
how to subscribe, as well as how to request old
contact the list maintainer. This mailing list
at http://groups.yahoo.com/group/vim.
If you send an
back telling you
messages and
is also archived
Life Changing
Helpful
Unfulfilling
rate
<<How do I add a current time string inside Vim? | How to tell what syntax highlighting group *that* is! >>
Additional Notes
Anonymous, August 10, 2001 9:51
Tip #98 - Getting vim help from mailing lists and newsgroups. : vim online
I disagree with this. I see requests for tips become very handy
tips once the requests are answered.
If this is not desired, then it's a good idea to create
"requests for tips" location in addition to "tips". Then people
can post requests, and the answers can go into "Tips" place.
Cory T. Echols, August 10, 2001 10:44
I did not mean for this tip to be a policy statement (I can't
make policy for this site), or a troll, or an admonishment of
anyone for anything.
The fact that questions were being posted in the tips database
implied to me that there were people who weren't aware of the
newsgroup or mailing list, so I entered a tip to help them
out. That's all it meant. Nothing more, nothing less.
Anonymous, August 19, 2001 14:01
Further, as Cory pointed out, a request for a tip could very
well be misconstrued as a tip on a subject and therefore be
ignored by people who can help. One stands a better chance of
having questions answered when they are put up using the avenues
suggested by Cory.
iain-vim@dellah.anu.edu.au, May 20, 2002 14:19
See also http://groups.yahoo.com/group/vimtips/ - a regular
mailing of the tips from this database,
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #99 - How to tell what syntax highlighting group *that* is! : vim online
Home
Search
Tip #99: How to tell what syntax highlighting group *that* is!
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Getting vim help from mailing lists and newsgroups. | Jump to tag (e.g. help topic) with German
keyboard (PC) >>
Additional Notes
cec@NgrOyphSon.gPsfAc.nMasa.gov, December 19, 2001 7:33
Tip #99 - How to tell what syntax highlighting group *that* is! : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #100 - Jump to tag (e.g. help topic) with German keyboard (PC) : vim online
Home
Search
Tip #100: Jump to tag (e.g. help topic) with German keyboard (PC)
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<How to tell what syntax highlighting group *that* is! | Change automatically to the directory the file in
the current buffer is in >>
Additional Notes
salmanhalim@hotmail.com, August 20, 2001 6:13
if you know the ascii code of the ] (93 or 0x5d), you
could create a mapping to it to guarantee your
combination would work -- the german keyboard might
have some other character thereupon that could be used:
noremap <c-theChar> <c-]>
you can get the ] by typeing a control-v followed by
93<space> or control-v followed by x5d.
hope this helps,
salman.
Add Note
Tip #100 - Jump to tag (e.g. help topic) with German keyboard (PC) : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #101 - Change automatically to the directory the file in the current buffer is in : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #101: Change automatically to the directory the file in the current
buffer is in
tip karma
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Jump to tag (e.g. help topic) with German keyboard (PC) | smart mapping for tab completion >>
Additional Notes
sf@vikas.mailshell.com, September 24, 2001 11:03
As of Vim 6.0, I would recommend using the "lcd"
instead of "cd" since using ":cd: sometimes messes up
the :mkview / :mksession commands
Anonymous, November 28, 2003 0:42
Tip #101 - Change automatically to the directory the file in the current buffer is in : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Change automatically to the directory the file in the current buffer is in | Move to next/previous line
with same indentation >>
Additional Notes
igor@tyumbit.ru, August 26, 2001 2:01
WOW!
I've wanted this for year and now i've got it!
Thanks for the tip!
anon@xyz.com, September 2, 2001 1:23
This is pretty cool. How would we simulate ^X^N, I
wonder...
octorock@doubtful.com, September 5, 2001 17:56
this is wonderful. however it would be helpful if it
could be made to cycle through all completions like a
proper ctrl-p would.
octorock@doubtful.com, September 5, 2001 20:33
i'm a giant fool. nevermind. (when i copied and
pasted the snippet, it left trailing whitespace
characters.)
thank you for such a killer tip.
Anonymous, September 6, 2001 10:50
With a minor addition you can also go in either
direction:
function! InsertTabWrapper(direction)
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
elseif "backward" == a:direction
return "\<c-p>"
else
return "\<c-n>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper ("forward")<cr>
inoremap <s-tab> <c-r>=InsertTabWrapper
("backward")<cr>
Anonymous,
Good, actually in my setting I had define two wrappers
for tab and shift tab effectively achieving the same
effect.
By the way I made a mistake in my orginal e-mail, it is
.com not .fr
Benoit
Anonymous, December 9, 2001 23:52
This tip is great. But, when type in 'tab' , it will
have a additional space. How to fix it ? thanks.
lee@dashf.com, January 16, 2002 9:45
this tip truly does kick ass.
mayureshk@aftek.com, January 24, 2002 23:38
This is freaking fabulous. Thankx man !! Its way too
cool. i too, have been searching for this for quite
some time now. Kudos !
kgergely@mcl.hu, April 9, 2002 10:30
See also vimscript#182.
It is a complete system, and the completion remembers
the completion mode!
anon, April 29, 2002 22:10
This tip is absolutely fantastic. In response to the
problem of a space after hitting tab, there is most
likely a
space after the line
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
In your vimscript, remove this and you should be fine
anon, May 22, 2002 10:17
Darned space!
Vim user, July 9, 2002 6:52
shift-tab always gives me a 'I', whether I'm in insert
mode or not.
Something wrong with my termcap?
AK, August 23, 2002 12:50
This tip is truly kickass..!
luca-vim@llucax.hn.org, September 6, 2002 7:50
function! InsertTabWrapper(direction)
let oldisk=&isk "save the iskeyword options
set isk+=(,),, "add '(' ')' and ',' character
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
elseif "backward" == a:direction
return "\<c-n>"
else
return "\<c-p>"
endif
set &isk=oldisk "restore the iskeyword options
endfunction
timothy.aldrich@csfb.com, September 13, 2002 7:06
actually Mikolaj Machowski suggested the function :
fun! Iskcompletion()
let oldisk=&isk
set isk+=(,)
normal <C-P>
set &isk=oldisk
endfun
I just merged it with the Tab completion function Thank You Mikolaj
Anonymous, October 11, 2002 10:38
[Feral:".strftime('%j/%y@%H:%M')."]-".Filler."\<cr>"
return DaLine
elseif match(DaLine, '\c^\s*//\s$') > -1
return "\<bs>\<bs>\<bs>"
else
return "\<cr>"
endif
endfunction
inoremap
<cr>
<c-r>=SpecialCR()<cr>
This will make <cr> eat C++ line comments when they are
the only think on the line, or more precisely:
"//\s" will be get 3 backspaces which should erase it
and "//" will get a simple timestamp separator.
Modify to your hearts content of course.
Happy VIMing!
anders@trolltech.com, September 18, 2003 6:41
Hi
Cool function(s)
Would it be possible to extend InsertTabWrapper to make
a tab pressed at col('.') >= (indent '.') reindent the
line as with a == ? I could not find a simple way to do
this but I am very much a novice with vim.
Anders Bakken
ericzbeard@yahoo.com, October 8, 2003 9:48
Good Stuff!
Here's the section of my vimrc that has all this wired
up (this is on a windows box, I jumped on a unix
machine to run the shell script that makes all the dict
files). My addition is Ctrl-TAB to begin a keyword
search instead of hitting Ctrl-X Ctrl-K, then I can
regular TAB through the entries.
Watch out for those dang spaces at the end of the
lines!
Thanks to everybody who contributed, this is great.
" Remap TAB to keyword completion
function! InsertTabWrapper(direction)
let col = col('.') - 1
http://www.vim.org/tips/tip.php?tip_id=102 (9 of 11) [18/02/2004 14:44:21]
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #103 - Move to next/previous line with same indentation : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<smart mapping for tab completion | using vim to complement Perl's DBI::Shell >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: advanced
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Move to next/previous line with same indentation | combining move and scroll >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
with j,
the
map <CFirst,
Life Changing
Helpful
Unfulfilling
rate
<<using vim to complement Perl's DBI::Shell | Mail signature rotation: Supersimple one-line solution
>>
Additional Notes
vdvo@seznam.cz, February 2, 2003 12:45
And for Page-Up/Page-Down, see vimtip #320. My
solution:
map <PageDown> :set scroll=0<CR>:set scroll^=2<CR>:set
scroll-=1<CR><C-D>:set scroll=0<CR>
map <PageUp> :set scroll=0<CR>:set scroll^=2<CR>:set
scroll-=1<CR><C-U>:set scroll=0<CR>
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #106 - Mail signature rotation: Supersimple one-line solution : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Hallo,
next solution for _most_simple_ signature rotater:
You can only put one line to your .vimrc || _vimrc:
map <Leader>ms :e c:\sign.txt<CR>ggV/--<CR>k"*xG$a<CR><C-O>*<Esc>:w<CR>:bd<CR>G$a<C-M><Esc>"*P
Must exist file (from eg above) c:\sign.txt, with
content:
-first signature
-second signature
-third signature
-When You finished mail, only call shortcut \ms and
'first signature' will be insert in your mail. In
c:\sign.txt will be first signature pushed to the end of
this file. When You want use other signature, only press
'u' and \ms again
(Or You can change \ms to e.g. <F12>, indeed. ) You can
change this and append one part like 'basic' from
command and append 'changing' part from .signature file,
as you like...
Ok, one unpleasant thing is here: your signature must
not contain '--' (signature separator)...
Anyhow, I find it useful
brz* <brz@centrum.cz>
http://brz.d2.cz/
Life Changing
Helpful
Unfulfilling
<<combining move and scroll | C/C++: convert enum to string table >>
rate
Tip #106 - Mail signature rotation: Supersimple one-line solution : vim online
Additional Notes
dion@erebus.demon.nl, September 5, 2001 6:59
The official signature separator is '-- ' (i.e. dash
dash space.) It would be better to use that in the
expression and the signature file.
kgergely@mcl.hu, January 9, 2002 6:41
And also a patch could be not to search --, but ^--$,
then you can have -- in your signature.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
enum2String :s#[
"\\1"#<CR>o}<ESC>/sdfsdf<CR>
enum2String :s#[
"\\1"#<CR>o}<ESC>/sdfsdf<CR>
Life Changing
Helpful
Unfulfilling
rate
<<Mail signature rotation: Supersimple one-line solution | Toggle a fold with a single keystroke >>
Additional Notes
dion@erebus.demon.nl, September 5, 2001 6:56
You can use :noh to reset highlighting.
erwjjjsudu@eufguweguh.com, January 20, 2004 7:07
ilrhgodgfnhioergwergod doesnt exist anymore
boobies, January 20, 2004 7:07
ftvggyBlank note? Not much of a note eh?
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Additional Notes
Unfulfilling
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Below are two functions and a mapping which will convert lines of plain text into
HTML table code.
For example, you have several lines like:
----------------------------------------------1
2
3
4
5
6
--------------------------------------------------by visualizing all the 7 lines and press <F5>, you can change the text into
<table><tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr><tr>
<td>4</td>
<td>5</td>
<td>6</td>
</tr></table>
which will eventually render into a table.
So the rule is:
Every line is a table item, every empty line means starting of a new table row.
let i=start
wh i <= end
exe ":" . i
let e=Empty()
if e == 1
exe "normal I</tr><tr> "
else
exe "normal I<td> A</td> >>"
endif
let i=i+1
endwh
exe "normal o</tr></table> <<"
exe ":" . start
exe "normal O<table><tr> <<"
endfunc
vmap <F5> <ESC>:call Table()<CR>
func Empty()
let line_nr= line (".")
let a=getline ( line_nr )
let m=match(a, "\\S")
if m == -1
return 1
else
return 0
endif
endfunc
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<jump between files | Printing with syntax highlighting independent of your normal highlighting >>
Additional Notes
wzhliang@yahoo.com, September 7, 2001 2:48
Sorry. The character not properly displayed should be <CTL-[>
meezer@mailandnews.com, September 12, 2001 2:24
or
:s/\(\S\+\)/<TD>\1<\/TD><CR>:'<,'>s/^\s*$/<\/TR><TR><CR>'>o</TR></TABLE><ESC>'<O<TABLE><TR><ESC>
.. for those that like compact but unreadable
Anonymous, September 12, 2001 2:25
make that
:map <F5>
:s/\(\S\+\)/<TD>\1<\/TD><CR>:'<,'>s/^\s*$/<\/TR><TR><CR>'>o</TR></TABLE><ESC>'<O<TABLE><TR><ESC>
to work in the same manner as the original posting
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #111 - Printing with syntax highlighting independent of your normal highlighting : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
cterm=italic
gui=italic
gui=bold
Tip #111 - Printing with syntax highlighting independent of your normal highlighting : vim online
Life Changing
Helpful
Unfulfilling
rate
<<text->html table converter. | Back and forth between indented lines again >>
Additional Notes
Anonymous, September 7, 2001 14:06
This does, BTW, assume that you are already using a
colorscheme.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #112 - Back and forth between indented lines again : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
"
" NextIndent()
"
" Jump to the next or previous line that has the same
level or a lower
" level of indentation than the current line.
"
" exclusive (bool):
true: Motion is exclusive
"
false: Motion is inclusive
" fwd (bool):
true: Go to next line
"
false: Go to previous line
http://www.vim.org/tips/tip.php?tip_id=112 (1 of 3) [18/02/2004 14:44:48]
Tip #112 - Back and forth between indented lines again : vim online
true:
]l <esc>:call NextIndent(0, 1, 0,
[L <esc>:call NextIndent(0, 0, 1,
]L <esc>:call NextIndent(0, 1, 1,
[l
]l
[L
]L
:call
:call
:call
:call
NextIndent(0,
NextIndent(0,
NextIndent(1,
NextIndent(1,
0,
1,
0,
1,
0,
0,
1,
1,
1)<cr>
1)<cr>
1)<cr>
1)<cr>
Tip #112 - Back and forth between indented lines again : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Printing with syntax highlighting independent of your normal highlighting | Translator in vim
(Windows solution) >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
<<Back and forth between indented lines again | Browsing by paragraph >>
Additional Notes
Add Note
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: intermediate
as of Vim: 6.0
Site Help
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
uws@xs4all.invalid, July 11, 2003 2:51
Also look at the ( and ) movements, which will take
jump to the next (or previous) sentence.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<Browsing by paragraph | Search all occurances of the word under cursor in all the open files >>
Additional Notes
pnwms@themail.com, September 18, 2001 2:38
Documented in the quick ref...
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #116 - Search all occurances of the word under cursor in all the open files : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #116: Search all occurances of the word under cursor in all the
open files
tip karma
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
zellerin@volny.cz, September 21, 2001 6:19
Is this right? I always thought (and docs :he [I seems
to say) it shows occurences in current file and files
it includes (omitting comments), not in all open
files...
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
purpose.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Search all occurances of the word under cursor in all the open files | Configuring gVim as Internet
Explorer 'View Source' editor >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #118 - Configuring gVim as Internet Explorer 'View Source' editor : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Tip #118 - Configuring gVim as Internet Explorer 'View Source' editor : vim online
Vim v6.
oWShell.Run _
"""D:\Programs\Vim\Vim58\gvim.exe """ & _
"-R """ & sFile & """ " & _
"-c ""set syntax=html"""
' Destroy script object
set oWShell = NOTHING
The source editor now can be specified by adding the
following key to the registry:
HKEY_LOCAL_MACHINE
|- Software
|- Microsoft
|- Internet Explorer
|- View Source Editor
|- Editor Name
D:\Programs\Vim\gvim.vbs
(Default) =
Life Changing
Helpful
Unfulfilling
rate
<<FAST SEARCH ACROSS THE PROJECT | Explorer startup and shutdown >>
Additional Notes
jake.howlett@ebone.com, September 19, 2001 7:09
Great tip! Thanks....
Any ideas why this would work in IE 5.5 but not in IE 5.01
? Strange....
Jake
jake.howlett@ebone.com, September 19, 2001 7:19
Tip #118 - Configuring gVim as Internet Explorer 'View Source' editor : vim online
Tip #118 - Configuring gVim as Internet Explorer 'View Source' editor : vim online
Tip #118 - Configuring gVim as Internet Explorer 'View Source' editor : vim online
'author:
Tip #118 - Configuring gVim as Internet Explorer 'View Source' editor : vim online
Tip #118 - Configuring gVim as Internet Explorer 'View Source' editor : vim online
Tip #118 - Configuring gVim as Internet Explorer 'View Source' editor : vim online
Tip #118 - Configuring gVim as Internet Explorer 'View Source' editor : vim online
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet
Explorer\View Source Editor\Editor Name]
@="C:\\Program Files\\vim\\vim62\\gvim_ie.lnk"
This method was tested using Vim 6.2 on Win2K and Vim 6.1
on Win98.
yongbing@hotmail.com, August 7, 2003 17:07
Instead of using regedit to change "View Source Editor"
directly, we can also use TweakUI for Windows XP (one of
the "Powertoys for Windows XP").
Navigate to "Internet Explorer->View Source". Click
"Change Program".
It changes the registry for you. (Exactly the same effect
as using regedit.)
Regards.
rweaver at austin dot rr dot com, September 12, 2003 11:27
Love it! I've set up IE to do this (via the "shortcut"
method). Does anyone know how to do this for Mozilla
and/or Netscape 7.x?
Regards.
zzapper@ntlworld.com, September 26, 2003 9:14
I vote for the shortcut method! (simplest)
mrgrier at yahoo dot com, January 6, 2004 1:34
The easiest way to get rid of this spaces problem is to
rename your
Temporary Internet Files
folder to something without any spaces, i.e.
TempInetFiles
Windows will complain you're changing a system file folder
name, but it works great, at least on my Win98se.
molivieri@yahoo.com, February 11, 2004 13:47
Tip #118 - Configuring gVim as Internet Explorer 'View Source' editor : vim online
When I set this up, I had to create the keys for the View
Source Editor, and its subkey "Editor Name".
In regedit:
1. Right Click on
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer
and select "New" -> "Key".
2. Name the new key "View Source Editor"
3. Right click on the new key, select "New" -> "Key"
4. Name that new key "Editor Name"
5. In the right pane of regedit, double click "(Default)".
This will open a pop-up to edit the value.
6. Enter the name of the shortcut, as in C:\Program
Files\Vim\vim62\vim_ie.lnk
Right away I was able to View Source with VIM. If you have
tried to View Source before making these changes, I
suspect you would have to restart IE or even reboot.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
func CloseIfLast()
if exists("b:completePath") " this is how I determine
that I'm in an explorer window
let n = winnr()
wincmd p
if n == winnr()
quit " quit the window
endif
wincmd p
endif
endfunc
if has("autocmd")
if !exists("rudyautocommands")
let rudyautocommands = 1
autocmd VimEnter * call OpenFileWindow()
autocmd WinEnter * call CloseIfLast()
endif
endif
Life Changing
Helpful
Unfulfilling
rate
<<Configuring gVim as Internet Explorer 'View Source' editor | Compiling Java with Sun JDK (javac)
within VIM >>
Additional Notes
the_orn@yahoo.com, September 22, 2001 8:49
Ack.
.vimrc directly
let g:explDetailedList=1
"
default
let g:explVertical=1
"
let g:explStartRight=0
"
window to the left of the current
:Sexplore
set nonu
set winwidth=15
" Make the width of the
window match the explorer setting
"let g:explVertical=0
" Split vertically
doautocmd fileExplorer BufEnter " Forces the
directory refresh to occur
:winc l
" change to the
document window
endfunc
func CloseIfLast()
if exists("b:completePath") "
determine that I'm in an explorer
let n = winnr()
"
if the window number is the same
wincmd p
"
same window.
if n == winnr()
quit
"
endif
wincmd p
endif
endfunc
this is how I
window
pop between windows,
then they're the
if has("autocmd")
if !exists("rudyautocommands")
let rudyautocommands = 1
autocmd VimEnter * call OpenFileWindow()
autocmd WinEnter * call CloseIfLast()
endif
endif
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #120 - Compiling Java with Sun JDK (javac) within VIM : vim online
Home
Search
Tip #120: Compiling Java with Sun JDK (javac) within VIM
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
Additional Notes
bjorklid at jyu.fi, October 19, 2001 10:13
rate
Tip #120 - Compiling Java with Sun JDK (javac) within VIM : vim online
Tip #120 - Compiling Java with Sun JDK (javac) within VIM : vim online
Tip #120 - Compiling Java with Sun JDK (javac) within VIM : vim online
:!javac c:\xxx.java
ex:
:!java c:\xxx(xxx.class)
<===Exception in
thread "main" java.lang.NoClassDefFoundError: c:\xxx
shell returned 1
Hit any key to close this window...
how can i use java in vim
please tell me and send to my email because my english
is very bad!
thanks!
Anonymous, September 20, 2003 9:56
Yes, XP can redirect stderr.
Just do:
:set shellpipe=>\ %s\ 2>&1
Then, :make will be expanded to {makeprg} > {errorfile}
2>&1
hadding (at) remove_mailandnews.com, November 7, 2003 2:44
If you have foo.java after you run javac you do java
foo NOT java foo.class else you get the exception in
thread main message
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
nmap q :q<CR>
" To type the following line, type *two* C-V's followed
by two spaces. This
" is how you map the spacebar.
nmap ^V <C-F><C-G>
---8<---cut here---8<--Then, to use this .vimrc, add an alias. If you're using
tcsh, the syntax will
be something like:
alias vmore "vim -u ~/.vimrc.more"
Then you can type "vmore [filename]" to view a file in
this "pager". Spacebar
will move down, 'b' will move back up, and 'q' quits.
You can add mappings for
other keys if you want to, also.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Compiling Java with Sun JDK (javac) within VIM | Skip blank lines when folding text. >>
Additional Notes
Anonymous, September 24, 2001 19:41
If you are using vim 6, there is already something like
this - a shell script installed as
$VIMRUNTIME/macros/less.sh. It sets up keybindings as
if you were using the common pager "less".
For more information, ":help less" from vim.
ivo@mentation.nl, September 29, 2001 10:20
I don't have vim 6.0 yet, but I added this to
~/.vimrc.pager:
" No menu bar and tool bar
set guioptions=aiMr
nmap <Up> <C-Y>
nmap <Down> <C-E>
Cursor key scrolling and no menu/tool bar.
Sanjay Aiyagari <saiyaga1881@earthlink.net>, October 2, 2001 1:20
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #122 - Skip blank lines when folding text. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
I love the text folding capabilities of vim. I didn't like that it would display the first line of the
range as the "title" for the fold. I like to write my comments with the "/*" on a line by itself. So I
wrote this little function that will skip over anything that isn't a character, and then display whatever
it finds after that character.
Just include this in your ~/.vimrc (or ~/.gvimrc):
function GetFirstLineWithChars()
let line_num = 0
let charline = matchstr(getline(v:foldstart), '[a-zA-Z][a-zA-Z ]*')
while strlen(charline) == 0
let line_num = line_num + 1
let charline = matchstr(getline(v:foldstart + line_num), '[a-zA-Z][a-zA-Z ]*')
endw
return charline
endfunction
set
foldtext='+'.v:folddashes.substitute(GetFirstLineWithChars(),'\\\/\\\/\\\|\\*\\\|\\*\\\|{{{\\d\\=','','g')
set fillchars=fold:
hi folded guibg=black guifg=yellow gui=bold
And as an added bonus, for those new to text folding, add this to your .vimrc file too:
autocmd BufWinLeave *.* mkview
autocmd BufWinEnter *.* silent loadview
That way whatever folds you set won't get lost when you quit.
folding up a 3000+ line file. Happy vimming!
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Using vim as a syntax-highlighting pager | use functionality similar to the * search on multiple files >>
Additional Notes
Tip #122 - Skip blank lines when folding text. : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #123 - use functionality similar to the * search on multiple files : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
<<Skip blank lines when folding text. | Number a group of lines >>
Additional Notes
Add Note
rate
Tip #123 - use functionality similar to the * search on multiple files : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Here is an
apple
bob
pear
tree
1
2
3
4
apple
bob
pear
tree
" Description:
" This provides a command and a function. They both can
be called with or
" without a range. In addition, they can be called with
or without
" arguments. Without a range they operate on the
current line.
"
" There are two supported arguments. They are described
below:
"
arg1 -> the number to start at. The default is
one. This will
"
number your selected lines
sequentially. The start can be a
"
number, ., $, or, 'x (like getline).
"
arg2 -> Text to append after numbers. The default
is a space.
"
" Examples:
"
To provide your functionality:
"
:%Nlist 20
"
:%call Nlist(20)
"
To make a list start at 1:
"
:'<,'>Nlist
"
:'<,'>call Nlist()
http://www.vim.org/tips/tip.php?tip_id=124 (1 of 3) [18/02/2004 14:45:17]
"
To number the whole buffer (with it's actual line
number):
"
:%Nlist
"
:%call Nlist()
"
To number a subset of lines with their line number
(and put a '] ' in
"
front of every number):
"
:'<,'>Nlist . ]\
"
:'<,'>call Nlist(".", "] ")
command! -nargs=* -range Nlist <line1>,<line2>call
Nlist(<f-args>)
function! Nlist(...) range
if 2 == a:0
let start = a:1
let append = a:2
elseif 1 == a:0
let start = a:1
let append = " "
else
let start = 1
let append = " "
endif
" try to work like getline (i.e. allow the user to
pass in . $ or 'x)
if 0 == (start + 0)
let start = line(start)
endif
exe a:firstline . "," . a:lastline .
's/^/\=line(".")-a:firstline+start.append/'
endfunction
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<use functionality similar to the * search on multiple files | Auto commenting for "}" >>
Additional Notes
Brian Medley, October 1, 2001 22:25
There is now a plugin (nlist.vim) in the "scripts"
section that does this. The plugin also handles
justifying the numbers. I probably should have waited
and not made this tip...
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
I always wanted a script that would auto-comment the end of a conditional block. So, I wrote one. This
function searches for the previous matching "{", grabs the line, and inserts it as a comment after the "}".
there is no previous matching "{", it inserts nothing.
So...
if (test){
Site Help
will generate:
} // if (test)
This is obviously not work if you use a different style.
If you use
if (test)
{
then substituting 'getline(".")', use
Life Changing
Helpful
Unfulfilling
<<Number a group of lines | how do I get rid of that bold stuff with my xterm? >>
rate
If
Additional Notes
octorock@doubtful.com, October 2, 2001 8:34
sweet!
It takes into account the last note and some other things I noticed.
This was annoying when I had a short if(){}else{} statement, so I changed the mapping to }<CR>.
If there is an else statement, the comment inserted is the if statement. followed by an else {
>10 lines check put in.
< 30 char check put in
Notes:
This will not indent correctly unless you're using cindent. For some reason, a friend of mine with
smartindent and it didn't work
If your style is to put the curly bracket on it's own line after the "if", add "-1" to all the getline
calls.
au BufNewFile,BufRead *.c,*.cc,*.C,*.h imap }<CR> <ESC>:call CurlyBracket()<CR>a
function CurlyBracket()
let l:startline = line(".")
let l:result1 = searchpair('{', '', '}', 'bW', '')
if (result1 > 0)
let l:linenum = line(".")
let l:string1 = getline(l:linenum)
if (l:string1 =~ ".*}.*{.*")
sil exe "normal 0"
let l:result2 = searchpair('{', '', '}', 'bW', '')
if (l:result2 > 0)
let l:string1 = getline(".") . l:string1
endif
endif
let l:my_string = substitute(l:string1, '^\s*\(.*\){', '\1', "")
let l:my_string = strpart(l:my_string,0,30)."..."
sil exe ":" . l:startline
sil exe "normal i}"
if ((l:startline - l:linenum) > 10)
sil exe "normal a //" . l:my_string
endif
endif
endfunction
jhm@gmx.net, October 4, 2001 10:46
Hi!
I tried this script (and also the second) and get the following errors when entering a }. Seems like it's
stuck in recursion... :-( This happens with Vim 6.0final on Linux and Windoze...
Any Ideas?
Jrg
Error detected while processing function CurlyBracket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket..CurlyBracket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
acket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
acket..CurlyBracket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
acket..CurlyBracket..CurlyBracket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
acket..CurlyBracket..CurlyBracket..CurlyBracket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
acket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
acket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
acket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
acket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
acket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..Curly
Bracket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
acket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..Curly
Bracket..CurlyBracket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
acket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..Curly
Bracket..CurlyBracket..CurlyBracket:
line
2:
E31: No such mapping
http://www.vim.org/tips/tip.php?tip_id=125 (4 of 8) [18/02/2004 14:45:20]
let l:string1 = substitute(getline(l:linenum - 1), '^\s*\(.*\)\s*$', '\1', "") . " " . l:string1
sil exe "normal k"
endif
" get else part if necessary
if (l:string1 =~ "^}")
sil exe "normal 0"
let l:result2 = searchpair('{', '', '}', 'bW')
if (l:result2 > 0)
let l:linenum = line(".")
let l:string2 = substitute(getline(l:linenum), '^\s*\(.*\)\s*$', '\1', "")
if (l:string2 =~ '^{')
let l:string2 = substitute(getline(l:linenum - 1), '^\s*\(.*\)\s*$', '\1', "") . " " .
l:string2
endif
let l:string1 = l:string2 . " ... " . l:string1
endif
endif
" remove trailing whitespaces and curly brace
let l:my_string = substitute(l:string1, '\s*{[^{]*$', '', "")
let l:my_strlen = strlen(l:my_string)
if (l:my_strlen > 30)
let l:my_string = strpart(l:my_string,0,30)."..."
endif
sil exe ":" . l:startline
sil exe "normal i}"
if ((l:startline - l:linenum) > 10)
sil exe "normal a /* " . l:my_string . " */"
endif
endif
endfunction
pacman@huji.ac.il, June 26, 2002 3:42
I use: vim6.1.74 - Linux
Nice tip but it doesn't work for me!
Error detected while processing function
line
2:
Error detected while
line
2:
Error detected while
line
2:
Error detected while
acket:
line
2:
Error detected while
acket..CurlyBracket:
line
2:
Error detected while
http://www.vim.org/tips/tip.php?tip_id=125 (6 of 8) [18/02/2004 14:45:20]
CurlyBracket:
processing function CurlyBracket..CurlyBracket:
processing function CurlyBracket..CurlyBracket..CurlyBracket:
processing function CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
acket..CurlyBracket..CurlyBracket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
acket..CurlyBracket..CurlyBracket..CurlyBracket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
acket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
acket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
acket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
acket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
acket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..Curly
Bracket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
acket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..Curly
Bracket..CurlyBracket:
line
2:
Error detected while processing function CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
acket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..CurlyBracket..Curly
Bracket..CurlyBracket..CurlyBracket:
line
2:
E31: No such mapping
pacman@huji.ac.il, June 26, 2002 3:44
I use: vim6.1.74 - Linux
Nice tip but it doesn't work for me!
Error detected while processing function CurlyBracket:
line
2:
Error detected while processing function
line
2:
Error detected while processing function
line
2:
Error detected while processing function
acket:
line
2:
Error detected while processing function
acket..CurlyBracket:
line
2:
Error detected while processing function
acket..CurlyBracket..CurlyBracket:
line
2:
Error detected while processing function
acket..CurlyBracket..CurlyBracket..CurlyBracket:
http://www.vim.org/tips/tip.php?tip_id=125 (7 of 8) [18/02/2004 14:45:20]
CurlyBracket..CurlyBracket:
CurlyBracket..CurlyBracket..CurlyBracket:
CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
CurlyBracket..CurlyBracket..CurlyBracket..CurlyBr
line
2:
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #126 - how do I get rid of that bold stuff with my xterm? : vim online
Home
Search
Tip #126: how do I get rid of that bold stuff with my xterm?
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Additional Notes
hans@fugal.net, October 10, 2001 7:37
Unfulfilling
rate
Tip #126 - how do I get rid of that bold stuff with my xterm? : vim online
8-color xterms
versions of those
colors to work with)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
:call PreviewHTML_TextOnly()<CR>
Life Changing
Helpful
Unfulfilling
rate
<<how do I get rid of that bold stuff with my xterm? | grep, diff, patch, idutils, etc. for Windows systems
>>
Additional Notes
christophe.badoit@free.frNOSPAM, February 9, 2002 15:40
Better with dillo, a really fast an light browser... a
graphical lynx in some sort.
See http://dillo.sourceforge.net ; or "apt-get
install dillo" for debian users.
Anonymous, July 26, 2002 6:18
It gives me an error when I try it:
E15:
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #128 - grep, diff, patch, idutils, etc. for Windows systems : vim online
Home
Search
Tip #128: grep, diff, patch, idutils, etc. for Windows systems
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
benji@member.AMS.org, December 1, 2001 5:09
Another suggestion from the vim users' list is
http://sourceforge.net/projects/gnuwin32
I have not tried this myself.
zzapper@ntlworld.com, February 7, 2003 10:27
However if you do wish to try Cygwin
http://www.cygwin.com/
Tip #128 - grep, diff, patch, idutils, etc. for Windows systems : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<grep, diff, patch, idutils, etc. for Windows systems | disabling default ftplugins >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
complexity: intermediate
as of Vim: 5.7
Scripts
Tips
My Account
Site Help
:help :filetype
:help ftplugin-overrule
If you have your own ftplugins, and you want to disable
all the default ones, then
do NOT include a check for b:did_ftplugin in your
ftplugin files, and add the line
:autocmd BufEnter * let b:did_ftplugin = 1
to your VIMRC file, BEFORE the ":filetype ftplugin on"
line.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
benji@member.AMS.org, October 8, 2001 5:06
Oops:
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
complexity: basic
as of Vim: 6.0
Scripts
Tips
My Account
Site Help
fun! ScrollOtherWindow(dir)
if a:dir == "down"
let move = "\<C-E>"
elseif a:dir == "up"
let move = "\<C-Y>"
endif
exec "normal \<C-W>p" . move . "\<C-W>p"
endfun
PS: Original idea and discussion of this tip appeared on
vim@vim.org mailing list, I'm just prettified it a
little.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
pottsdl@yahoo.com, October 12, 2001 5:27
Note that the essential Vim commands are <c-_> which
maximizes the current
window by making all of the other windows 1-line
high. And <c-=> which makes
all window sizes the same.
The script just makes it easier to toggle.
salmanhalim@hotmail.com, October 12, 2001 6:21
i just like not having to explicitly maximize the
current window every time. i never said it couldn't be
done by hand at will. i just frequently have four or
five source windows open and it's easier to just have
them become bigger automatically.
salmanhalim@hotmail.com, October 13, 2001 12:42
i noticed that the bufenter commands only happen when
moving from one buffer to another (in a different
window) -- if you have two windows with the same
buffer, the bufenter commands don't get triggered and
the zooming doesn't happen. to make it happen for all
WINDOWS, change all the above BufEnter occurrences to
WinEnter.
glennj@canada.com, October 14, 2001 14:20
what is "<Leader>"?
tvon@etria.org, October 14, 2001 19:21
for info on <leader> see
:help mapleader
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
i like bufdo and windo but i don't like the fact that
the commands end in a different window/buffer than from
where i executed them. these versions (starts with a
capital letter) will restore the current window or
buffer when the command's done.
for example, to turn on line numbers everywhere, i use
:Windo set nu -- :windo set nu does the trick also but
leaves me in a different window than where i started.
" just like windo but restores the current window when
it's done
function! WinDo(command)
let currwin=winnr()
execute 'windo ' . a:command
execute currwin . 'wincmd w'
endfunction
com! -nargs=+ -complete=command Windo call WinDo(<qargs>)
" just like bufdo but restores the current buffer when
it's done
function! BufDo(command)
let currBuff=bufnr("%")
execute 'bufdo ' . a:command
execute 'buffer ' . currBuff
endfunction
com! -nargs=+ -complete=command Bufdo call BufDo(<qargs>)
rate this tip
Life Changing
Helpful
Unfulfilling
Additional Notes
rate
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
Site Help
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
scrott@users.sourceforge.net, October 12, 2001 8:11
Also worth looking at vimtip #118 which deals with
defaulting the syntax to html and eating extra spaces.
webmaster@wltx.com, May 7, 2002 8:48
I wanted to use wordpad when i choose "view source" in
ie 6. this tip made it possible. just follow tip #134
and you can do this also.
wordpad lets you use your most common keyboard commands
such as ctrl-s, ctrl-a etc. basically all the ones that
notepad does not. no need for any extra script file if
you use wordpad. THANKS VIM !
json
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
in several ways:
1. Use the ":buffer" ex command passing the name of
an existing buffer
or the buffer number. Note that buffer name
completion can be used
here by pressing the <Tab> key.
2. You can enter the buffer number you want to
jump/edit and press the
Ctrl-^ key.
3. Use the ":sbuffer" ex command passing the name of
the buffer or the
buffer number. Vim will split open a new window
and open the
specified buffer in that window.
4. You can enter the buffer number you want to
jump/edit and press the
Ctrl-W ^ or Ctrl-W Ctrl-^ keys. This will open
the specified buffer
in a new window.
Help keyword(s): :buffer, :sbuffer, CTRL-W_^, CTRL-^
10. How do I browse through all the available buffers?
You can browse through the buffers in the buffer
list in several ways:
1. To jump to the first buffer in the buffer list,
use the ":bfirst" or
":brewind" ex command.
2. To jump to the first buffer in the buffer list in
a new window, use
the ":sbfirst" or ":sbrewind" ex command.
3. To edit the next buffer in the buffer list, use
the ":bnext" ex
command.
4. To open the next buffer in the buffer list in a
new window, use the
":sbnext" ex command.
5. To edit the previous buffer in the buffer list,
use the ":bprevious"
or ":bNext" ex command.
6. To open the previous buffer in the buffer list in
a new window, use
the ":sbprevious" or ":sbNext" ex command.
7. To open the last buffer in the buffer list, use
the ":blast" ex
command.
8. To open the last buffer in the buffer list in a
new window, use the
http://www.vim.org/tips/tip.php?tip_id=135 (4 of 11) [18/02/2004 14:45:45]
":sblast" ex command.
Help keyword(s): :bfirst, :brewind, :sbfirst,
:sbrewind, :bnext,
:sbnext, :bprevious, :bNext,
:sbprevious, :sbNext,
:blast, :sblast
11. How do I open all the buffers in the buffer list?
You can open all the buffers present in the buffer
list using the
":ball" or ":sball" ex commands.
Help keyword(s): :ball, :sball
12. How do I open all the loaded buffers?
You can open all the loaded buffers in the buffer
list using the
":unhide" or ":sunhide" ex commands. Each buffer
will be loaded in a
separate new window.
Help keyword(s): :unhide, :sunhide
13. How do I open the next modified buffer?
You can open the next or a specific modified buffer
using the
":bmodified" ex command. You can open the next or a
specific modified
buffer in a new window using the ":sbmodified" ex
command.
Help keyword(s): :bmodified, :sbmodified
14. I am using the GUI version of Vim (gvim), is there a
simpler way for
using the buffers instead of the ex commands?
Yes. In the GUI version of Vim, you can use the
'Buffers' menu, which
simplifies the use of buffers. All the buffers in
the buffer list are
listed in this menu. You can select a buffer name
from this menu to
edit the buffer. You can also delete a buffer or
browse the buffer
list.
Help keyword(s): buffers-menu
15. Is there a Vim script that simplifies using buffers
with Vim?
http://www.vim.org/tips/tip.php?tip_id=135 (5 of 11) [18/02/2004 14:45:45]
,w
/[.,;]<CR>
Life Changing
Helpful
Unfulfilling
rate
<<View Source in IE6 using VIM | Remapping Alt, Ctrl and Caps in Win2k >>
Additional Notes
Anonymous, March 25, 2003 16:22
Something simple, using gvim
just detach the buffer menu and place it on the right
hand side of the screen.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #136 - Remapping Alt, Ctrl and Caps in Win2k : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Since I installed Win2K on my laptop, I had been unable to locate a utilitie that
simply enable me to remap my Crtl Alt and Caps the way I think they should be and
they were until MS kill all competition in computing, that is Crtl on the left of
letter A, Alt to the left bottom of the letter Z and Caps approximately until the
would
the way
the
C.
After some research, I came across a tip posted here by juano@mindspring.com. I tried to
make sense of it and then downloaded the MS scan keys map at the URL he mentionned.
Extrapolating his tip, I wrote this ASCI file that I named keys2000.reg :
Regedit4
[HKey_Local_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode
Map"=hex:00,00,00,00,00,00,00,00,04,00,00,00,3A,00,38,00,38,00,1D,00,1D,00,3A,00,00,00,00
Once you have saved this file, left click on it from Explorer and answer yes to the
prompt "do you want to enter this into the registry".
Reboot and you are done.
A few explanations :04 stands for 3 remappings (Caps lock to Control, Control to Alt and
Alt to Caps Lock) plus the closing one which is always required (1 remapping would
require 02, 2 would require 03, and so on). 3A,00,38 remaps Caps to Left Alt, 38,00,1D
remaps Left Alt to Left Ctrl and 1D,00,3A remaps Left Ctrl to Caps Lock since 3A=Caps,
1D=Left Ctrl and 38=Left Alt.
Based on Juano tip and on this one, I believe a lot of remapping can be done as long as
you keep the separators 00 and remember to add one to the number of remappings. What I do
not know is how far you can extend this instruction without getting into trouble with the
registry. At worst, if you keyboard does not behave as expected, go into the registry and
delete this instruction (be careful here since it is easy to confuse this instruction
Tip #136 - Remapping Alt, Ctrl and Caps in Win2k : vim online
with the Keyboard LayoutS (S for emphasis) which must not be deleted.
Again, thanks to Juano@mindspring.com who got me going and suggested I post my tip. Took
me some time to retrieve the VIM Url but fortunately, I had printed his tip.
Regards
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
leifw @(at)@ bigfoot .(dot). com, December 13, 2001 6:40
I had to make the "Regedit4" at the beginning of the registry entry all caps for this
to work on NT4.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
:call WrapLeft()<cr>
:call WrapRight()<cr>
function! WrapLeft()
let col = col(".")
if 1 == col
" don't wrap if we're on the first line
if 1 == line(".")
return
endif
normal! k$
else
normal! h
endif
endfunction
function! WrapRight()
let col = col(".")
if 1 != col("$")
let col = col + 1
endif
if col("$") == col
" don't wrap if we're on the last line
if line("$") == line(".")
return
endif
normal! j1|
http://www.vim.org/tips/tip.php?tip_id=137 (1 of 2) [18/02/2004 14:45:50]
else
normal! l
endif
endfunction
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Remapping Alt, Ctrl and Caps in Win2k | Getting name of the function >>
Additional Notes
vimonline@geert.triple-it.nl, October 15, 2001 0:45
There is an existing feature for this in Vim:
"set whichwrap=<,>,h,l,[,]"
this causes the cursorkeys, as well as h and l, to wrap
when used at beginning and end of lines.
(the <> and [] differ in that <> are the cursorkeys
used in normal and visual mode, and the [] are the
cursorkeys in insert mode)
See :help whichwrap
So imho no complex scripting needed.
grtz,
Geert van der Ploeg
vschum1 at towson dot edu, November 30, 2003 9:20
I love you for this tip!
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Hi All,
While browsing code one always needs to know which
function you are currently looking. Getting the name is
very painful when the functions are lengthy and you are
currently browsing NOT near to the start of the
function. You can get the function's name by using this
simple mapping.
Just place this in your .vimrc.
map _F ma[[k"xyy`a:echo @x<CR>
now _F will display which function you are currently in.
Enjoy the power of Vim
-Nitin Raut
PS: The working is as follows, mark the current line
with a, jump to the previous '{' in the first column, go
one line up, yank the line in register x, return to the
mark a, echo the value of register x, which is the
wanted function name.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<automatically wrap left and right | Alignment: =, LaTeX tables, declarations, etc >>
Additional Notes
Anonymous, October 16, 2001 3:53
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Check out
http://www.erols.com/astronaut/vim/textab.html
and see some examples of text alignment (its hopeless to
do it here with
proportional fonts). You'll be able to download textab
source, a Windows-based
textab executable, and a scriptfile containing a
convenient interface (ttalign.vim). The textab program
coupled with <ttalign.vim> lets you:
1. align C language statements on their = += -= /= etc
symbols
2. align C language declararations: separate columns for
types, *[, variable
names, initializations (=), and comments (// or /* ..
*/)
3. align C/C++ language comments (//, /* .. */)
4. align C/C++ language (ansi) function argument lists
5. align LaTeX tables on their && separators
6. align HTML tables with </TD><TD> separators
7. align on several characters: < ? : | @ ; (or modify
them to handle whatever
alignment characters you want)
rate this tip
Life Changing
Helpful
Unfulfilling
<<Getting name of the function | tip using embedded perl interpreter >>
Additional Notes
cec@NgrOyphSon.gPsfAc.nMasa.gov, May 7, 2002 11:14
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: advanced
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Alignment: =, LaTeX tables, declarations, etc | Add your function heading with a keystroke >>
Additional Notes
benoit.cerrina@writeme.com, October 19, 2001 14:27
For an example of the technics described see vimscript
#100,
it is while developping this script that I found most
of this.
benoit.cerrina@writeme.com, October 29, 2001 23:02
little changes to the tip
perl << EOF
sub mySub
{
#some usefull perl stuff
}
EOF
function! MyFunction()
perl mySub "an argument", "another"
endfunction
to pass computed argument to your perl sub use the vim
exec command
function! MyFunction()
exec "perl mySub " . aLocalVar . ", " b:aBufferLocalVar
endfunction
another way to do this is to get the arguments from
within the perl function
perl << EOF
sub mySub
{
my $anArg=VIM::Eval("a:anArg");
#some usefull perl stuff
http://www.vim.org/tips/tip.php?tip_id=140 (3 of 4) [18/02/2004 14:45:57]
}
EOF
function! MyFunction(anArg)
perl mySub
endfunction
finaly to be able to return something from perl
perl << EOF
sub mySub
{
my $anArg=VIM::Eval("a:anArg");
#some usefull perl stuff
VIM::DoCmd "let retVal=". aMeaningfullThingToReturn;
}
EOF
function! MyFunction(anArg)
perl mySub
if exists('retVal')
return retVal
endif
endfunction
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #141 - Add your function heading with a keystroke : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Below is a tip that the C/C++ Newbies may find interesting and handy
to use. The following code will add a function heading and position
your cursor just after Description so that one can document as one
proceeds with code.
function FileHeading()
let s:line=line(".")
call
setline(s:line,"/***************************************************")
call append(s:line,"* Description - ")
call append(s:line+1,"* Author Mohit Kalra")
call append(s:line+2,"* Date ".strftime("%b %d %Y"))
call append(s:line+3,"*
*************************************************/")
unlet s:line
endfunction
imap <F4>
<esc>mz:execute FileHeading()<RET>`zjA
Life Changing
Helpful
Unfulfilling
rate
<<tip using embedded perl interpreter | Automatic function end commenting for C++ and Java >>
Additional Notes
indiaguru100@yahoo.com, November 6, 2002 11:39
Hi:
What key has to be typed for this to be working. I am fairly new to
this board.
imap <F4> mz:execute FileHeading()`zjA
The last 3 chars (zjA) is it typo ? or I have to include in file?
mohit kalra, November 8, 2002 6:23
Tip #141 - Add your function heading with a keystroke : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #142 - Automatic function end commenting for C++ and Java : vim online
Home
Search
Tip #142: Automatic function end commenting for C++ and Java
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Add your function heading with a keystroke | Use of Vim folds for javadocs >>
Additional Notes
bjorklid at jyu.fi, October 19, 2001 10:05
Whoops. It seems that a tip like this has allready been
sent here (see vimscript #125). Sorry about that.
bjorklid at jyu.fi, October 19, 2001 10:07
and of course I meant vimtip #125 (not script). I begin
to feel a little foolish here ;-)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Hi,
The fold-method marker can be effectively use to set the folds
in your Java source. Define some marker and place it inside
HTML comments <!-- xx -->. This way, it does not affect the
Javadocs generated without the necessity of a seprate comment
line.
e.g.
/**
* <!-- zz.FOLDSTART class AbcClass -->
* The class description.
* ...
*/
public class AbcClass {
/**
* <!-- method zz.FOLDSTART someMethod() -->
* Method description.
*/
public void someMethod();
...
} /* zz.END: AbcClass */
/* Put this at the end of your file */
/* vim:fdm=marker fmr=zz.FOLDSTART,zz.END fdl=2 fdc=2: */
Now, the files will be opened with the methods neatly folded.
You can use "zR" to open all folds (or click on the "+" at the
left column).
Sameer.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Automatic function end commenting for C++ and Java | recording keystrokes by "q" for repested jobs >>
Additional Notes
dsummersl@yahoo.com, July 11, 2002 6:43
Another thing you might try, if you don't feel like mucking up
your code by adding markers everywhere(I really love folding
but I don't like the idea of having to modify my sources to get
it to work just right) is to set your foldmarker to the javadoc
comment blocks:
fdm=/**,*/
Seems to work pretty well, doesn't interfere with normal /* */
chunks anyway.
Koenraad Heijlen, July 26, 2002 13:28
Really nice folding on /** */ if you are editing source that's
overcommented....
I use these settings to autoload java files :
autocmd FileType java :set fmr=/**,*/ fdm=marker fdc=1
Eric Bowman, July 30, 2002 14:38
It seems like the last idea is a bit buggy. Not all javadoc
comments fold automatically, and some really weird behavior
results. But the following works like a charm:
In java.vim, change the javaDocComment line to:
syn region javaDocComment
start="/\*\*" end="\*/"
transparent fold keepend
contains=javaCommentTitle,@javaHtml,javaDocTags,javaTodo,@Spell
(added "transparent fold").
Then in my .vimrc I added:
set foldmethod=syntax
Voila!
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #144 - recording keystrokes by "q" for repested jobs : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Use of Vim folds for javadocs | Changing DOS style end of line to UNIX, or vise-versa >>
Additional Notes
revscat@swbell.net, November 1, 2002 12:56
Tip #144 - recording keystrokes by "q" for repested jobs : vim online
This is well and good, but how do you make macros work
across buffers or a split-screen? I frequently compare
two files in split-screen mode, and can't get recorded
macros to work it I have to move between screens. Any
ideas?
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #145 - Changing DOS style end of line to UNIX, or vise-versa : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
This
Life Changing
Helpful
Unfulfilling
rate
<<recording keystrokes by "q" for repested jobs | opening multiple files from a single command-line >>
Additional Notes
Anonymous, October 22, 2001 13:27
Tip #145 - Changing DOS style end of line to UNIX, or vise-versa : vim online
I still
Tip #145 - Changing DOS style end of line to UNIX, or vise-versa : vim online
Tip #145 - Changing DOS style end of line to UNIX, or vise-versa : vim online
^M as might
be present in a
the other is
CTRL-V CTRL-RETURN - generate the ^M representation of
a Unix carriage-return
So you might find that you want to replace CTRL-V CTRLM with CTRL-V CTRL-RETURN
i.e.
http://www.vim.org/tips/tip.php?tip_id=145 (4 of 5) [18/02/2004 14:46:16]
Tip #145 - Changing DOS style end of line to UNIX, or vise-versa : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #146 - opening multiple files from a single command-line : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Tip #146 - opening multiple files from a single command-line : vim online
<<Changing DOS style end of line to UNIX, or vise-versa | How to write a plugin >>
Additional Notes
warlocky@pchome.com.tw, June 26, 2003 0:50
This is great! It saves the effort of typing multiple
:sp under vim. I have 2 suggestions
1. If I use
vim
:Sp a b c
It results in 4 windows in vim. One is empty. Is
this could be improved?
2. Is there a way to make a new_cmd that splits a
window to 3, each one for a file specified in the
command line?
For example,
vim a b c
:new_cmd
then I could see 3 windows in vim. One for a, one
for b, and one for c.
Anyway, still thanks for your :Sp.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: advanced
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<opening multiple files from a single command-line | Make great use of those homemade menus >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #148 - Make great use of those homemade menus : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<How to write a plugin | Automatically update your diff upon writing. >>
Additional Notes
salmanhalim@hotmail.com, October 24, 2001 18:39
i suspect you're referring to the tearoff capability of
the gui menus. your 'guioptions' must include a 't' in
the value for them to be enabled. they are the very
first thing (looks like a small pair of scissors
surrounded by hyphens) in each menu and CAN be clicked
with the mouse also.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #149 - Automatically update your diff upon writing. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Make great use of those homemade menus | Generating a column of increasing numbers >>
Additional Notes
jaldri1 at gl dot umbc dot edu, June 16, 2003 15:05
Just knowing that :diffupdate exists is
useful. Thanks.
Add Note
Tip #149 - Automatically update your diff upon writing. : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
vector[0]=
vector[0]=
vector[0]=
vector[0]=
vector[0]=
1;
1;
1;
1;
1;
-->
vector[0]=
vector[1]=
vector[2]=
vector[3]=
vector[4]=
1;
1;
1;
1;
1;
This script works with both vim 5.7 (:so visincr.vim) or vim 6.0 (source it
as for vim 5.7 or drop it into the .vim/plugin directory).
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
sitar@procaut.sk, November 21, 2001 3:26
" another way of generating incremented numbers
"=============================================================================
" File: increment.vim
" Author: Stanislav Sitar (sitar@procaut.sk)
" Help:
" Put increment.vim into a plugin directory.
" Use in replacement strings
" :let I=0
" :%s/my_token_word_to_be_replaced_by_the_auto_incremented_numbers/\=INC(1)/
" or
" :let I=95
" :%s/@/\=INC(5)/
" to replace each occurence of character @ with numbers starting with 100 and
" growing by 5 (100, 105, 110, ...)
"
" Instalation: save this text as increment.vim in your plugins directory
"=========================================================================
let g:I=0
function INC(increment)
let g:I =g:I + a:increment
return g:I
endfunction
cec@NgrOyphSon.gPsfAc.nMasa.gov, November 28, 2001 13:04
Visincr.vim has been improved -- it now uses virtual column calculations
which avoid problems with leading tabs -- you may even mix leading
tabs and spaces, incrementing only the visually selected column.
With
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Site Help
<<Generating a column of increasing numbers | Spelling checkers for: Dutch, English, German, Hungarian, and
Yiddish >>
Additional Notes
Anonymous, November 1, 2001 7:13
The table does not list all ascii characters, for instance [az], [A-Z] and [0-9] are missing....
shlompi@hotmail.com, November 1, 2001 17:43
In fact it's not an ASCII table at all.
ASCII is 7-bit, codes 0x00 to 0x7F.
This table lists the C0, C1 and G1 ranges of ISO-8859-1 (ISOLatin1).
C0 - lower control codes, 0x00 to 0x1F (and 0x7F, DEL)
C1 - higher control codes, 0x80 to 0x9F
G1 - ISO-8859 extension range, 0xA0 to 0xFF
What is referred to as ASCII characters is the G0 range, 0x20
to 0x7E.
Anonymous, November 7, 2001 3:22
Note that you can get the ascii value (or whatever-value ;-)
of the character under cursor with 'ga' (think of it as "Get
Ascii" to remember it)
digitect@mindspring.com, March 24, 2002 18:55
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #152 - Spelling checkers for: Dutch, English, German, Hungarian, and Yiddish : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #152: Spelling checkers for: Dutch, English, German, Hungarian, and
Yiddish
tip karma
complexity: intermediate
as of Vim: 5.7
Under
http://www.erols.com/astronaut/vim/index.html#vimlinks_scripts
are links to spelling checkers for Dutch, English, German,
Hungarian,
and Yiddish, all based on the original engspchk.vim. The
spelling
checker provides as-you-type spell checking; with vim6.0 it
will avoid
checking on partially typed words.
Provided are several maps:
\et
file
\es
\en
\ep
\ea
: add
:
:
:
:
save
move
move
look
so engspchk.vim
Life Changing
Helpful
Unfulfilling
<<an ascii table | Making Parenthesis And Brackets Handling Easier >>
Additional Notes
http://www.vim.org/tips/tip.php?tip_id=152 (1 of 2) [18/02/2004 14:46:31]
rate
Tip #152 - Spelling checkers for: Dutch, English, German, Hungarian, and Yiddish : vim online
If you do
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #153 - Making Parenthesis And Brackets Handling Easier : vim online
Home
Search
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
=======================================================================================
1) ++++++++++++++++++++++++++ "Automatic" bracket setting +++++++++++++++++++++++++++++
To automatically insert a closing parenthesis when typing an opening
parenthesis you can insert the following simple mapping to your vimrc:
:inoremap ( ()<ESC>i
This ends up with the cursor between the opening and the closing parenthesis
in insert mode.
You can apply this and the following tips, of course, with the kind of
parenthesis/bracket
character you want to, i.e. (, {, [, < ..... and, pretty useful as well,
quotation marks ",',.... (to be continued)
2) +++++++++++++++ Further improvement of parenthesis/bracket expanding
++++++++++++++++++
I you are ready with filling the parenthesis/brackets, you likely want to
"escape" from the brackets again to continue coding.
To make this pretty comfortable, I invented the following kind of mappings, which get
out
of the last expanded parenthesis/bracket, regardless of the actual type of it, and
enter append mode again.
I mapped this kind of "getaway" with CTRL_j, you may use your favorite keystroke with
Tip #153 - Making Parenthesis And Brackets Handling Easier : vim online
it.
...
:inoremap ( ()<ESC>:let leavechar=")"<CR>i
:inoremap [ []<ESC>:let leavechar="]"<CR>i
...
:imap <C-j> <ESC>:exec "normal f" . leavechar<CR>a
Explanation: The variable "leavechar" contents the actual char which is to "escape"
from.
3) ++++++++++++++++++++++++++++ "Late" bracketing of text +++++++++++++++++++++++++++++
Occasionally I later want already written text parts to put in parenthesis.
I use the following macro, which brackets previously visually selected text.
I mapped it with _(.
:vnoremap _( <ESC>`>a)<ESC>`<i(<ESC>
Furthermore, a sort of mapping for bracketing a *single word* is conceivable.
Because this is not as general like the kind of visual mode mapping, I use
this kind of "word bracketing" only for surrounding the word right behind the cursor in
insert mode with **. I use the following macro to "emphasize" the word i just typed,
for newsgroup articles.
:imap _* <Esc>bi*<Esc>ea*<Space>
4) ++++++++++++++++++++++++++++++ Conclusion ++++++++++++++++++++++++++++++++++++++++++
Since I use these macros, I never caused a syntax error because of missing
brackets, and furthermore I can quickly insert parenthesis and qutotes into codeand non-code files.
JH 04.11.2001
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Spelling checkers for: Dutch, English, German, Hungarian, and Yiddish | Mappings to facilitate the creation of text >>
Additional Notes
http://www.vim.org/tips/tip.php?tip_id=153 (2 of 7) [18/02/2004 14:46:35]
Tip #153 - Making Parenthesis And Brackets Handling Easier : vim online
inoremap { {<CR><BS>}<ESC>ko
to be used in conjunction with my autoindent setup:
set
set
set
set
set
expandtab
shiftwidth=4
smarttab
autoindent
smartindent
Tip #153 - Making Parenthesis And Brackets Handling Easier : vim online
This one
Tip #153 - Making Parenthesis And Brackets Handling Easier : vim online
I really like the last implementationl, but I noticed a slight problem. The spacing
inside the curly braces is not a single tab, it also includes spaces. How do we get
a single tab inside the curly braces.
grojas@strategicinc.com, July 3, 2003 9:39
Sorry, wrong email address
drennalls@canada.com, July 7, 2003 7:32
I ran into this too. If there's actually a space in the mapping in your .vimrc file
it will get added to the mapping. So just make sure to remove the space.
If you check the current mapping by doing a
:inoremap {
if you did have that trailing whitespace it would show the mapping as
{ {<cr>}<esc>:call BC_AddChar("}")<cr><esc>kA<cr><Space>
Vim shouldn't interpret the whitespace as part of the mapping, perhaps this is a bug
?
maksimkim@mail.ru, July 17, 2003 0:14
And what about abbreviations?
for example:
iab psvm public static void main(String[] args) {<CR><CR>}
with all of those mappings it produce :
public static void main(String[] args){
} }])
How to avoid this?
Anonymous, July 21, 2003 17:17
Use inorea instead of iab
This won't trigger the autobracketing.
Anonymous, July 24, 2003 22:22
Thanks!
breadman@byu.edu, July 31, 2003 16:07
Tip #153 - Making Parenthesis And Brackets Handling Easier : vim online
The following may be a little more complex than it needs to be, but allows me to type
the closing character to get out of the delimiter, if I'm already at the end.
inoremap ( ()<ESC>i
inoremap [ []<ESC>i
inoremap { {<CR>}<ESC>O
autocmd Syntax html,vim inoremap < <lt>><ESC>i| inoremap > <c-r>=ClosePair('>')<CR>
inoremap ) <c-r>=ClosePair(')')<CR>
inoremap ] <c-r>=ClosePair(']')<CR>
inoremap } <c-r>=CloseBracket()<CR>
inoremap " <c-r>=QuoteDelim('"')<CR>
inoremap ' <c-r>=QuoteDelim("'")<CR>
function ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return "\<Right>"
else
return a:char
endif
endf
function CloseBracket()
if match(getline(line('.') + 1), '\s*}') < 0
return "\<CR>}"
else
return "\<ESC>j0f}a"
endif
endf
function QuoteDelim(char)
let line = getline('.')
let col = col('.')
if line[col - 2] == "\\"
"Inserting a quoted quotation mark into the string
return a:char
elseif line[col - 1] == a:char
"Escaping out of the string
return "\<Right>"
else
"Starting a string
return a:char.a:char."\<ESC>i"
endif
endf
http://www.vim.org/tips/tip.php?tip_id=153 (6 of 7) [18/02/2004 14:46:35]
Tip #153 - Making Parenthesis And Brackets Handling Easier : vim online
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
"
" Mappings to facilitate the creation of text
"
" Author: Suresh Govindachar sgovindachar@yahoo.com
" Date:
November 5, 2001
"
" While typing text to create a document, I often end up
hitting
" <Esc>, issuing some commands (with or without ":") and
getting back
" to typing by issuing a command such as "i", "O", "s"
etc.
"
" I looked into using "set insertmode" to speed up such
actions, but
" found that too confusing.
"
" I have come up with a set of mappings that have
speeded up my process
" of creating documents. I have saved these mappings in
a file, named
" FullScreenVI.vim, in vim's plugin directory.
"
" Perhaps you will find these mappings helpful too.
"
" Please send me feedback.
"
"To
set
"To
the
set
imap <A-;>
<C-o>:
"Basic motions
imap <A-h> <Left>
imap <A-j> <Down>
imap <A-k> <Up>
imap <A-l> <Right>
imap <A-f> <PageDown>
imap <A-b> <PageUp>
imap <A-^> <Home>
imap <A-$> <End>
"Numbers for repeats
imap <A-1> <C-o>1
imap <A-2> <C-o>2
imap <A-3> <C-o>3
imap <A-4> <C-o>4
imap <A-5> <C-o>5
imap <A-6> <C-o>6
imap <A-7> <C-o>7
imap <A-8> <C-o>8
imap <A-9> <C-o>9
"Basic searches
imap <A-/> <C-o>/
imap <A-*> <C-o>*
imap <A-#> <C-o>#
imap <A-n> <C-o>n
imap <A-N> <C-o>N
"Deleting
imap <A-x>
imap <A-d>
imap <A-D>
<C-o>x
<C-o>d
<C-o>D
imap <A-!>
imap <A-w>
imap <A-e>
<C-o>:!
<C-o>:w<CR>
<C-o>:e
"Other commands
imap <A-u> <C-o>u
imap <A-.> <C-o>.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Making Parenthesis And Brackets Handling Easier | Decompile Java .class files automatically >>
Additional Notes
Anonymous, November 7, 2001 4:07
BUG:
In the section "Common prefixes: marking, matching
etc.":
imap <A-h> <C-o>:h
conflicts with the "move to left" command; the
preceding
could be changed to:
imap <A-H> <C-o>:h
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
<<Mappings to facilitate the creation of text | describe <table name> from vim >>
Additional Notes
maxiangjiang@hotmail.com, November 7, 2001 10:14
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
if you get away from vim and get any other editor that
was built *after* 1970....
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<describe <table name> from vim | Using Computer Modern TT as gvim font (Win32) >>
Site Help
Additional Notes
demian0311@yahoo.com, November 7, 2001 10:53
my note is the Truth.
kbgaddis@hotmail.com, November 8, 2001 10:16
go away troll...
champion@equuleus.com, November 8, 2001 11:31
Dude, know you are a loser, get a life. Want some
publicity do something more fulfilling
Anonymous, November 8, 2001 15:41
go back to slashdot, please.
Anonymous, November 10, 2001 11:59
maybe its time to introduce some sort of moderation?
this forum has been my favourite since it was started
and it feels bad that its been
defiled like this...
on the other hand, i do get some kind of morbid
satisfaction giving him a -ve rating for once :)
Anonymous, November 10, 2001 12:03
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #158 - Using Computer Modern TT as gvim font (Win32) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
put
Life Changing
Helpful
Unfulfilling
rate
Tip #158 - Using Computer Modern TT as gvim font (Win32) : vim online
Additional Notes
Anonymous, November 8, 2001 13:00
grr typo!
"Now install the cmtt.pfm file" should of course be
"Now install the cmtt8.pfm file"
bobnotbob@byu.edu, November 9, 2001 8:43
I couldn't get the font to install on my win2k
box. What exactly should the name of the file
be? Should I change the cmtt8.pfb to cmtt8.pfm? I
tried making the modifications as per the instructions,
and when I tried copying it to my fonts directory,
windows told me that it was an invalid font. I kept
the right number of spaces, and I set fineformat=mac,
but it didn't work. Maybe somebody could post a
version of the font that works OK?
Vince, November 9, 2001 12:42
If you have downloaded the full bluesky package, you
will have *both* .pfb and .pfm files. Do not rename the
.pfb file to .pfm! The .pfm file will appear with a red
'a' as its icon in Win2k.
(Thinking I should have marked this tip as advanced, as
messing with Type 1 fonts even in Win2k is fairly nonintuitive....)
pdwalker@quagmyre.com, November 11, 2001 8:57
One of the nicest mono spaced fonts that I have found
has come from Microsoft.
They have a nice selection of screen legible fonts
located at http://www.microsoft.com/typography.
The monospaced font is called Andale Mono and can be
downloaded as a self installing executable (ugh.) under
Windows.
Take a look if you need a good font.
- Paul
argherna@core.com, November 12, 2001 5:05
Tip #158 - Using Computer Modern TT as gvim font (Win32) : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Searching for resp. Substituting of the current word under the cursor ++++++
a) Searching ............
If you don't know how to look for the next occurence of the word under the cursor,
you
should *now* type
:help * or
:help star
or refer to the tips vimtip #1 or vimtip #5
((Tip within tip: To make your pattern more visible, look for :help hls))
b) Substituting .........
The following macro extends the one above with automatically inserting the current
word
under the cursor into the from - pattern of the :s command.
:map <S-F4> :%s/<C-r><C-w>//gc<Left><Left><Left>
To complete it, just enter
-> mynewpattern<RETURN>
I use this i.e. for reliable and quickly renaming a variable in the entire buffer.
I mapped it to Shift-<F4>. You may map it to the keystroke you want.
Explanation: CTRL-v+CTRL-w expands to the word under the cursor.
3) ++ Searching and Substituting for an arbitrary visually selected part of text ++++
If you want to look or substitute (for) an *arbritary* pattern (which already exists
at
least once in your text), the following 2 mappings do it for you.
The advantage is that you dont have to type again or cut & paste the appropriate text
but only have to visually select it.
a) Searching ...........
:vmap / y:execute "/".escape(@",'[]/\.*')<CR>
This immediately finds to the next occurence of the previously visually selected
text.
b) Substituting .........
Conclusion +++++++++++++++++++++++++++++++++++++
With the appropriate mappings in your vimrc you can save keystrokes when Searching or
Substituting and avoid typing errors. That way, you can take lunch sooner
rate this tip
Life Changing
Helpful
Unfulfilling
<<Using Computer Modern TT as gvim font (Win32) | Dutch spelling checker >>
Additional Notes
maxiangjiang@hotmail.com, November 12, 2001 10:43
rate
Thanks
Great to find escape()
I have the following map, as a consequence:
cm <C-A> <C-R>=escape(@",'[]/\.*')<CR>
vm * y/<C-A><CR>| vm / y:%s/<C-A>/
vm # y?<C-A><CR>| vm ? y:g/<C-A>/t$<CR>
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Download at
http://www.thomer.com/thomer/vi/nlspchk.vim.gz.
This sciript is based on Charles E. Campbell's English
spelling checker script for ViM
(http://users.erols.com/astronaut/vim/) and Piet
Tutelaers' Dutch word list (http://www.ntg.nl/spell-nlv5b/) using Thomas Khler's script (http://jeanlucpicard.de/vim/gerspchk/create). In other words, I didn't
do much.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Keystroke Saving Substituting and Searching | write plugin with explorer like interfaces >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #162 - write plugin with explorer like interfaces : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Tip #162 - write plugin with explorer like interfaces : vim online
Tip #162 - write plugin with explorer like interfaces : vim online
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<write plugin with explorer like interfaces | Make non-ASCII characters displayed on console >>
Site Help
Additional Notes
hermitte@free.fr, November 12, 2001 7:07
You can also do something like :
noremap XX :set hlsearch!<cr>:set hlsearch?<cr>
<advertize>
And take a look at
http://vim.sourceforge.net/scripts/script.php?script_id=48
for more complex toggle actions.
</adv>
coryechols@yahoo.com, November 14, 2001 4:52
I think the simplest way to do this is :noremap XX :set
invhlsearch<CR>
For options which have only "on" or "off" settings, giving
the 'inv' prefix to the option causes it to be toggled.
hermitte@free.fr, November 15, 2001 5:07
The "inv" prefix only works with versions 6.x of VIM. It
seems to do strictly the same
thing '!' does. But it does not echoes the value of the
option.
Hence, 'set option?<cr>' is still useful if you want to
know its new current state.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<Toggle Search Highlighting | Deleting a buffer without closing the window >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #165 - Deleting a buffer without closing the window : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Tip #165 - Deleting a buffer without closing the window : vim online
<<Make non-ASCII characters displayed on console | Mapping caps lock to esc in XWindows >>
Additional Notes
bindu@wavell.net, December 19, 2001 0:09
The MiniBufExplorer.vim plugin (in the scripts area)
provides this capability with a really simple and small
user interface...
Anonymous, June 24, 2002 22:58
This tip didn't seem to work in gvim 6, I placed it in
my _vimrc file as instructed, but deleting buffers
still closes the windows they are in, as before ;-(.
Anonymous, November 16, 2002 6:16
I didn't try the tip, but this is the solution I came
up with:
You can use the :BufClose command with or without an
argument. The argument can be the filename associated
with a buffer, or a buffer number. You don't have to
be in the window that has the buffer open if you use an
argument.
command! -nargs=? -complete=buffer -bang BufClose
\ :call BufClose(expand('<args>'),
expand('<bang>'))
function! BufClose(buffer, bang)
if a:buffer == ''
let buffer = bufnr('%')
else
let buffer = bufnr(a:buffer)
endif
if buffer == -1
echohl ErrorMsg
echomsg "No matching buffer for" a:buffer
echohl None
return
endif
let current_window = winnr()
let buffer_window = bufwinnr(buffer)
if buffer_window == -1
echohl ErrorMsg
http://www.vim.org/tips/tip.php?tip_id=165 (2 of 3) [18/02/2004 14:47:00]
Tip #165 - Deleting a buffer without closing the window : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Deleting a buffer without closing the window | Using vim as a man-page viewer under Unix >>
Additional Notes
leifw @at@ bigfoot dot.dot com, November 19, 2001 11:21
Oh, and I really didn't mean for those <br>'s to show up in the
file. It should look like
-----------start-----------! Swap caps lock and escape
remove Lock = Caps_Lock
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock
------------end------------jani@turkia.com, July 2, 2002 21:06
Great tip!!! And I might try the other tip on the Dvorak mappings :)
-------start
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard
Layout]
"Scancode
Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,01,00,3a,00,00,00,00,00
--------end
Then double-click on it and reboot.
The syntax is explained in
http://www.vim.org/tip_view.php?tip_id=285
gtg947a@<nospam>mail.gatech.edu, September 13, 2003 18:05
I had this script working nicely before, but now it gives me this
error:
xmodmap: .speedswapper:1: bad keysym in remove modifier list
'Caps_Lock', no corresponding keycodes
xmodmap: .speedswapper:3: bad keysym target keysym 'Caps_Lock', no
corresponding keycodes
xmodmap: 2 errors encountered, aborting.
Anybody know what's up?
http://www.vim.org/tips/tip.php?tip_id=166 (2 of 3) [18/02/2004 14:47:03]
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #167 - Using vim as a man-page viewer under Unix : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Put one of the above two lines into your <.profile> or <.login>
file as
appropriate for your shell.
The man pages will then be displayed with vim called as "view"
and will use
the <man.vim> syntax highlighting. I myself use some additional
highlighting
which is enabled by putting the following file into
<.vim/after/syntax/man.vim>.
I usually use the <astronaut> colorscheme (also available from
this archive);
those who use bright backgrounds may find the colors selected for
manSubSectionStart and manSubSection something they'll want to
change:
-------------------------------------------------------------------" DrChip's additional <man.vim> stuff
syn match manSectionHeading
"^\s\+[0-9]\+\.[0-9.]*\s\+[AZ].*$" contains=manSectionNumber
syn match manSectionNumber
"^\s\+[0-9]\+\.[09]*"
contained
syn region manDQString
start='[^a-zA-Z"]"[^",
)]'lc=1
end='"'
contains=manSQString
syn region manSQString
start="[ \t]'[^',
)]"lc=1
end="'"
syn region manSQString
start="^'[^',
)]"lc=1
end="'"
syn region manBQString
start="[^a-zA-Z`]`[^`,
)]"lc=1
end="[`']"
syn region
manBQSQString
start="``[^),']"
end="''"
syn match manBulletZone
transparent "^\s\+o\s"
Tip #167 - Using vim as a man-page viewer under Unix : vim online
contains=manBullet
syn case
match
syn keyword manBullet contained
syn match
manBullet contained
syn match
manSubSectionStart
nextgroup=manSubSection
syn match
manSubSection
o
"\[+*]"
"^\*"
skipwhite
".*$"
contained
hi link manSectionNumber
Number
hi link manDQString
String
hi link manSQString
String
hi link manBQString
String
hi link manBQSQString
String
hi link manBullet
Special
hi manSubSectionStart
term=NONE cterm=NONE gui=NONE
ctermfg=black ctermbg=black guifg=navyblue guibg=navyblue
hi manSubSection
term=underline cterm=underline
gui=underline ctermfg=green guifg=green
set ts=8
--------------------------------------------------------------------
Life Changing
Helpful
Unfulfilling
rate
<<Mapping caps lock to esc in XWindows | Viewing the actual XPM data in GVIM >>
Additional Notes
Douglas Potts <pottsdl@bigfoot.com>, November 26, 2001 6:10
As part of the man filetype plugin delivered in Vim 6.0, the
user command :Man
is setup to view man pages in a similar fashion. (On Unix)
I've sym-linked the
man.vim filetype plugin from the distribution into the plugin
directory. That
was the :Man command is available whenever you need it.
Hope that was useful.
Alper Ersoy <aersoy@tfz.net>, December 1, 2001 0:38
I had to use PAGER variable instead of MANPAGER. Version of
the man tool I use is 2.3.10. People who would like to try
this may like to check tip #121 too.
scottu@apptechsys.com, January 30, 2002 11:24
Tip #167 - Using vim as a man-page viewer under Unix : vim online
Two things:
1. Some versions of sh don't support setting environment
variables and exporting on the same line. In that case, you'd
have to do:
> MANPAGER="col -b | view -c 'set ft=man nomod nolist' -"
> export MANPAGER
2. Another comment mentioned that their man doesn't support
the MANPAGER env var, so they had to use PAGER. You probably
don't want to do that on a permanent basis, since PAGER is used
for many other things besides man. Instead, you might create a
small script in your $HOME/bin that sets it in a subshell, for
example (vman.sh):
#!/bin/sh
PAGER="col -b | view -c 'set ft=man nomod nolist' - "
export PAGER
man $*
and then do 'vman ls' or whatever. Replace PAGER with MANPAGER
if your man supports it and you want to use the script.
3. You might want to add ignorecase to the list of settings
passed to vim (view) to more closely match the searching of
most man pagers (less and more).
Ok, I lied - 3 things.
supergrass@gmx.net, February 9, 2002 3:36
even simpler way
what I did was:
1) renamed my less to less.orig
2) edited the less.sh script :
if test $# = 0; then
vim -c 'so $VIMRUNTIME/macros/less.vim' elif test $* = "-is"; then
less.orig $*
else
vim -c 'so $VIMRUNTIME/macros/less.vim' $*
fi
3) symlinked $VIMRUNTIME/macros/less.sh to /usb/bin/less
so as you can see when the man is called it just passes the
parameters to less.orig
simple, fast works
have phun :)
Tip #167 - Using vim as a man-page viewer under Unix : vim online
Tip #167 - Using vim as a man-page viewer under Unix : vim online
I'm having the same problem as ajw. Seems that it's either
":Man", or vim as pager for man from the command line. Making
sure that MANPAGER is only set for interactive shells, and then
doing "let $MANPAGER='/usr/bin/less'" in .vimrc does help some,
as ajw suggests, but it means that you're stuck with less once
you've jumped out of the first man page via K. Anybody know how
to make vim as MANPAGER and ":Man" from man.vim play nice
together?
cec@NgrOyphSon.gPsfAc.nMasa.gov, November 27, 2002 6:56
There's now a while-you're-in-vim solution -- check out
vimscript#489 for <Manpageview.vim> for a new :Man command
and support for the K normal-mode command.
Anonymous, December 18, 2002 3:04
Great!
cec@NgrOyphSon.gPsfAc.nMasa.gov, December 27, 2002 7:25
Using MANPAGER doesn't work so well with vimscript#489;
instead, I now use a Korn shell function. Similar
functions could be developed for other shells (bash, zsh),
I'm sure:
# man:
function man
{
/usr/bin/man $* | col -b | /usr/local/bin/view -c 'set ft=man
nomod nolist' }
jhf.remmelzwaal at europe.com, January 2, 2003 3:06
Reading man pages on NT, Win2000 etc.
Windows NT, etc has remote shell client support. This can be
used to read the man pages on a unix system. I changed script
vimscript#489 in the following way:
----------------------------------------------*** manpageview.vim~ Thu Jan 2 11:42:14 2003
--- manpageview.vim Thu Jan 2 11:44:48 2003
***************
*** 87,94 ****
enew!
set mod
" call Decho("manpagebook<".manpagebook.">
topic<".manpagetopic.">")
!
exe "r!man ".manpagebook." ".manpagetopic
!
%!col -b
setlocal ft=man nomod nolist
set nolz
endfunction
--- 87,98 ---enew!
set mod
Tip #167 - Using vim as a man-page viewer under Unix : vim online
Tip #167 - Using vim as a man-page viewer under Unix : vim online
Tip #167 - Using vim as a man-page viewer under Unix : vim online
}
kerosin at gmx dot de, June 25, 2003 3:25
To avoid the problems with vim in the PAGER or MANPAGER
variable, use the following bash-function:
vman() { man $* | col -b | vim -c 'set ft=man nomod nolist' -;
}
If you view a manpage within vim now, the K-button will work
right.
Anonymous, July 26, 2003 15:16
In bash, adding:
alias man='vman'
... after the vman function, in your .bashrc file, will let you
use the man command again. Simply renaming the vman function to
'man' gave me a string of errors.
vilover@thomer.com, August 21, 2003 23:15
When using UTF-8 as your locale, bad things happen.
how to make it work:
So this is
function man {
/usr/bin/man $* | col -bp | iconv -c | view -c 'set ft=man
nomod nolist' }
westphal@informatik.uni-oldenburg.de, October 29, 2003 12:23
If MANPAGER does not work and PAGER should not be used for the
aforementioned good reasons then the lucky ones with GNU man
simply write (csh)
alias man
'/usr/bin/man -P "col -bp | iconv -c | view -c '"'"'set ft=man
nomod nolist'"'"' -" \!*'
(this is tick-quotes-tick-quotes-tick in the middle) resp. (sh)
alias man="/usr/bin/man -P \"col -bp | iconv -c | view -c
'set ft=man nomod nolist' -\""
and the ones without write (csh)
alias man 'env PAGER="col -bp | iconv -c | view -c '"'"'set
ft=man nomod nolist'"'"' -" man \!*'
resp. (sh)
alias man="env PAGER=\"col -bp | iconv -c | view -c 'set
ft=man nomod nolist' -\" /usr/bin/man"
and are done.
westphal@informatik.uni-oldenburg.de, October 29, 2003 14:42
Tip #167 - Using vim as a man-page viewer under Unix : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #168 - Viewing the actual XPM data in GVIM : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<Using vim as a man-page viewer under Unix | <Tab> = <C-I> and <Esc> = <C-[> >>
Additional Notes
carll@online.no, November 21, 2001 10:28
This requires search highlighting to be turned on, see
vimtip #14 (or just type :set hlsearch). It should also
work with 5.7
Anonymous, November 29, 2001 5:28
instead of searching for something nonexistant like
/foo, just type :noh (for no highlighting)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Viewing the actual XPM data in GVIM | Repeating a sequence of commands without defining a
macro >>
Additional Notes
realblades@yahoo.com, August 15, 2002 23:11
If you mean the piece of plastic, it might just send
something other than the two other pieces of plastic.
Depending on the operating environment, it may be
possible to change them though the change is most
likely going to be system-wide.
I'm pretty sure that for example X allows very easy
reconfiguration. I'm also quite sure that this is a
very bad idea to be thinking about at all.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #170 - Repeating a sequence of commands without defining a macro : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Imagine.
Tip #170 - Repeating a sequence of commands without defining a macro : vim online
Life Changing
Helpful
Unfulfilling
rate
<<<Tab> = <C-I> and <Esc> = <C-[> | Do you know the "g/" and "g?" commands? >>
Additional Notes
jmcpherson@bigfoot.com, December 5, 2001 11:38
You can also bring up the command line history while in
Normal mode by typing:
q:
which is just a touch faster than :<Ctrl-F>. (-:
(Actually, I didn't even know about Ctrl-F in : mode
until I read this tip. Neat!)
sathishvj@yahoo.com.__spam_stop, May 2, 2003 14:48
Lemme add a note that I saw elsewhere.
Once you execute a command line or search command you
can retrieve the text thus:
i<C-R>:
command line command
i<C-R>/
command
Tip #170 - Repeating a sequence of commands without defining a macro : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #171 - Do you know the "g/" and "g?" commands? : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Then
Tip #171 - Do you know the "g/" and "g?" commands? : vim online
g? - search backwards
Visual searches behave like normal searches. The 'n'
and 'N' commands
work as they should, and the search history correctly
records each search.
Multi-line searches behave as they should (this corrects
the 'yank-only'
method mentioned in the Vim help files). Block visual
searches do not work
yet. Hopefully, someone can figure out a way to do this
easily.
I've only tested this on Win2000 and Redhat Linux
7.1. I'm not really clear
on how the carriage returns are dealt with on other
systems.
Anyway, enjoy!
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Repeating a sequence of commands without defining a macro | Using Ispell on a highlighted region
>>
Additional Notes
cec@NdjOinnSi.gPsfAc.nMasa.gov, August 26, 2003 7:59
Here's YAW (Yet Another Way): put the following lines
into your <.vimrc>:
vnoremap <silent> g/
'\\/.*$^~[]')<CR><CR>
vnoremap <silent> g?
'\\/.*$^~[]')<CR><CR>
y/<C-R>=escape(@",
y?<C-R>=escape(@",
gv to restore the
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Do you know the "g/" and "g?" commands? | Switch between splits very fast (for multi-file editing)
>>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #173 - Switch between splits very fast (for multi-file editing) : vim online
Home
Search
Tip #173: Switch between splits very fast (for multi-file editing)
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Tip #173 - Switch between splits very fast (for multi-file editing) : vim online
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
cec@NgrOyphSon.gPsfAc.nMasa.gov - NOSPAM, December 14, 2001 13:25
One may also do the dual thing for vertical
splits/window changes:
set wmw=0
nmap <c-h> <c-w>h<c-w><bar>
nmap <c-l> <c-w>l<c->w<bar>
fallman@jpl.se, February 11, 2002 7:35
It should be
nmap <c-l> <c-w>l<c-w><bar>
of course...
slyphon@example.net, May 14, 2002 17:51
wonderful wonderful wonderful wonderful....
thanks so much, great tip!
Anonymous, August 26, 2002 14:36
This is so useful, perhaps it can be made part of
"standard" VIM! (Although I would probably leave out
the "maximize" portion: <c-w>_)
rosta@coware.be, September 2, 2002 0:38
I have solved the same problem by setting:
set winminheight=0
set winheight=999
winheight is always bigger than my window so
the current window is maximized.
I do not have to set mapping and I can use other
commands to change buffer, fi C-W C-W, mouse click
on status line of the buffer etc.
jerome.bosch@netcourrier.com, September 10, 2002 6:46
very useful tip, thanks
Tip #173 - Switch between splits very fast (for multi-file editing) : vim online
\<c-w>k"
\<c-w>j"
\<c-w>l"
\<c-w>h"
Tip #173 - Switch between splits very fast (for multi-file editing) : vim online
else
echo "oops. check your ~/.vimrc"
return ""
endif
endfunction
" /*}}}*/
This was an easy extension to the function I use for
resizing windows:
See the note I added to:
Tip #427: Fast window resizing with +/- keys
http://www.vim.org/tips/tip.php?tip_id=427
michael.denio@morganstanley.com, November 12, 2003 5:31
Why have a whole function when you can simply:
nmap
nmap
nmap
nmap
<silent>
<silent>
<silent>
<silent>
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
ab (1 [1]<esc>:/^--\s/-1/<cr>o<insert><cr>Footnotes:<cr>---------<cr>[1]
ab (2 [2]<esc>:/^Footnotes\:/+2/<cr>o<insert>[2]
ab (3 [3]<esc>:/^Footnotes\:/+3/<cr>o<insert>[3]
ab (4 [4]<esc>:/^Footnotes\:/+4/<cr>o<insert>[4]
ab (5 [5]<esc>:/^Footnotes\:/+5/<cr>o<insert>[5]
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Switch between splits very fast (for multi-file editing) | how to make VIM as ur default editor even
without root ac. >>
Additional Notes
rjbs, April 5, 2002 4:50
Although I can tell what these does, I imagine that
much of the intended audience ('basic' tips users)
can't just tell by looking. Perhaps some annotation is
in order.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #175 - how to make VIM as ur default editor even without root ac. : vim online
Home
Search
Tip #175: how to make VIM as ur default editor even without root ac.
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
hi,
if u have installed vim in your home directory somewhere
and u don't have a root account, and you want to
make VIM the default editor for anything u do.
i.e if ur using SQLplus and want to edit a sql command.
normally typing edit brings up the vi editor and not vim
editor.
to solve this problem.
define these three variables in your .profile
VIM=<base directory where vim executable is placed>
VIMRUNTIME=<base direcoty where vim runtimes are kept>
EDITOR=$VIM/vim
note if u have installed vim with another name, say
vim.exe then
change EDITOR=$VIM/vim to EDITOR=$VIM/vim.exe
source the .profile and viola. next time u start an
editor from any
program u have the vim editor.
Njoy.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
none@none.com, December 9, 2001 6:41
This tip might be more useful if translated into
English.
Anonymous, December 10, 2001 14:17
Tip #175 - how to make VIM as ur default editor even without root ac. : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
endif
endif
endif
endfunction
if !exists("au_p4_cmd")
let au_p4_cmd=1
au BufEnter * call IsUnderPerforce()
au FileChangedRO * call P4Checkout()
endif
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<how to make VIM as ur default editor even without root ac. | Highlight matching brackets as one
moves in normal mode (plugin) >>
Additional Notes
joseph@plaxo.com, August 18, 2003 15:37
Great tip!! However, I think it only works if you've
checked out the entire depot. I only have one branch
checked out (//depot/main/...) and it doesn't work
because the substitution just puts in //depot and not
//depot/main. I just fixed that in my version of the
code and it works now, but I think in addition to
$P4HOME one needs a $P4ROOT or some such for the root
of what you checked out. Of course you could get both
of these from p4client, but it sounds like in the
original tip this was undesirable...just something to
be aware of for other users of this excellent tip.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #177 - Highlight matching brackets as one moves in normal mode (plugin) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Check out
http://www.erols.com/astronaut/vim/index.html#VimFuncs
for
a plugin script which highlights matching brackets. The
script has
two always-on maps:
\[i
: start [HiMtchBrkt] mode
\[s
: stop [HiMtchBrkt] mode
The plugin will save all user maps and options that the
plugin uses and
will restore them when the mode is stopped.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Autocheckout from perforce | Making a "derived" colorscheme without copy & paste >>
Additional Notes
cec@NgrOyphSon.gPsfAc.nMasa.gov - NOSPAM, December 12, 2001 8:21
The script is under the title "Highlighting Matching
Brackets"
parlorinventor@hotmail.com, December 27, 2001 2:46
Nice script, but the 'Special' highlighting of most
color-schemes isn't very bright, so I changed the
'Special' in line 158 of the script to 'Search',
because the 'Search' highlighting is much brighter in
most colorschemes, like the one I use (asu1dark). Now
the other bracket really 'flashes' on, and I don't have
to hurt my eyes searching for a somewhat different
coloured bracket.....
Tip #177 - Highlight matching brackets as one moves in normal mode (plugin) : vim online
Tip #177 - Highlight matching brackets as one moves in normal mode (plugin) : vim online
call <SID>HMBStart()
endfunction
fu! BStop()
call <SID>HMBStop()
endfunction
===========original continues...============
" HMBStart:
fu! <SID>HMBStart()
if exists("b:dohimtchbrkt") && b:dohimtchbrkt == 1
" already in HiMtchBrkt mode
echo "[HiMtchBrkt]"
return
endif
.........
....etc.....
....etc.....
=====================================
Now (as I am real newbie) I can easy and "reliable"
start and stop breackets highlighting by executing
commands:
:call BStart()
and
:call BStop()
-----------------------This comment was intended only for real vim newbies who
just want it to put in work (no more).
I need no credits because hack is very rude and stupid.
Thanks for attention.
--vim newbie.
I_hat3_s_pamers@hotmail.com, June 29, 2002 14:18
Sorry for misleading a bit: at homedir must be created
"~/.vim/plugin"
NOT "~/.vim/plugins"
Anonymous, July 13, 2002 21:20
I-hat...: did you ever realize that \[i should be typed
from normal mode?
The colon puts you into command mode, and admittedly
\[i is not defined
there.
maxiangjiang@hotmail.com, February 10, 2003 23:09
Tip #177 - Highlight matching brackets as one moves in normal mode (plugin) : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #178 - Making a "derived" colorscheme without copy & paste : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Tip #178 - Making a "derived" colorscheme without copy & paste : vim online
<<Highlight matching brackets as one moves in normal mode (plugin) | Simplify help buffer navigation
>>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
<buffer>
<buffer>
<buffer>
<buffer>
<buffer>
<buffer>
<CR> <C-]>
<BS> <C-T>
o /'[a-z]\{2,\}'<CR>
O ?'[a-z]\{2,\}'<CR>
s /\|\S\+\|<CR>
S ?\|\S\+\|<CR>
Life Changing
Helpful
Unfulfilling
rate
<<Making a "derived" colorscheme without copy & paste | Reload your filetype/syntax plugin >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: advanced
as of Vim: 6.0
filetype/syntax
Life Changing
Helpful
Unfulfilling
rate
<<Simplify help buffer navigation | get the vim patched source >>
Additional Notes
Cory T. Echols, December 14, 2001 4:40
This tip really oversimplifies the issue.
Your plugin may be designed to only run once per
buffer, no matter how many times that buffer has ":e"
run on it. Also, if you remove a mapping or option
setting from your plugin, and then just call ":e" on
your sample buffer, the mapping will still be there, as
no commands were run to clear it out.
The absolutely most effective way I can think of to
test your plugin is to edit it in one instance of vim,
and another instance of vim for testing the plugin. As
you save changes to your plugin, you'll need to exit
and restart the "test" instance of vim. Luckily, vim
has a very fast startup time :)
There may be other less brute-force methods of doing
http://www.vim.org/tips/tip.php?tip_id=180 (1 of 3) [18/02/2004 14:47:40]
this.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Hi,
there has been a number of person (including) asking in
the vim list how to keep up with Bram's incredible bug
correction
and patch writing skills, but there is a great way to do
this!
Use the cvs source which is available at
http://sourceforge.net/cvs/?group_id=8
it is kept up to date and its a lot easier than applying
all the patch in order.
Benoit
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Reload your filetype/syntax plugin | Keep your cursor centered vertically on the screen >>
Additional Notes
quesadaj@psych.colorado.edu, August 31, 2003 21:20
but cvs.sourceforge is down most of the time (for me at
least). I haven't been able to download the whole
source tree in the whole weekend...
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #182 - Keep your cursor centered vertically on the screen : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<get the vim patched source | Select a buffer from those matching a pattern >>
Additional Notes
jmcpherson@bigfoot.com, December 17, 2001 18:00
This might work, but it isn't necessary to remap your
keys to get this effect. Vim has a built-in option for
this called 'scrolloff' (or 'so' for short). This sets
how many lines of context are maintained above and
below the cursor. If you set this to a very big number,
your cursor will stay in the center of the screen when
it can.
set so=9999
Try it and see what happens. (-: It's also compatible
with PgUp/Down, arrow keys, ^B/^F, and other scrolling
commands.
feline, January 2, 2002 8:40
Tip #182 - Keep your cursor centered vertically on the screen : vim online
doh!
i didnt know about the scrolloff setting. i love it
so many settings, not enough hours in the day to find
out what they all do
pedro, April 29, 2002 23:21
The "set so=9999" setting works better, but it renders
"H", "M", "L" useless which is a pain
none., July 26, 2002 10:24
absolutely not, not in vim 6.1 atleast... haven't tried
others, don't bother neither :)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #183 - Select a buffer from those matching a pattern : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Tip #183 - Select a buffer from those matching a pattern : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Keep your cursor centered vertically on the screen | How to obscure text instantaneously >>
Additional Notes
Cory T. Echols, December 18, 2001 8:02
I guess I should test my stuff more rigorously before
posting.
The above function doesn't take into account the
situation where no buffers match the supplied
pattern. The function below corrects the problem.
"Select from buffers matching a certain pattern
function! s:BufSel(pattern)
let bufcount = bufnr("$")
let currbufnr = 1
"flag to determine if matches are found
let foundmatch = 0
while currbufnr <= bufcount
if(bufexists(currbufnr))
let currbufname = bufname(currbufnr)
if(match(currbufname, a:pattern) > -1)
echo currbufnr . ":
".
bufname(currbufnr)
let foundmatch = 1
endif
endif
let currbufnr = currbufnr + 1
endwhile
if(foundmatch > 0)
let desiredbufnr = input("Enter buffer number: ")
if(strlen(desiredbufnr) != 0)
exe ":bu ". desiredbufnr
endif
else
echo "No matching buffers"
endif
endfunction
salmanhalim@hotmail.com, December 18, 2001 12:19
Tip #183 - Select a buffer from those matching a pattern : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Hi,
Lets say your writing some imp. doc. and your colleague
comes along. you don't wan't him to see what you are
typing.
so u start fumbling to type :wq! or switch with Alt-TAB.
etc.
but wouldn't it be nice to just obsucre the text
temporarily,
so that u don't have to quit or swith to another
application using Alt-tab.
(and if u don;t have any other window open u can;t even
use alt-tab)
well rot-13 comes to help. vim has a built in rot-13
encoder.
jut put the follwoing in your .vimrc
map <F3> ggVGg?
so next time some body comes along just press <F3> and
all the buffer will
be rot-13 encoded. to decode just press <f3> again.
Njoy
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Select a buffer from those matching a pattern | Make vim the editor for files with unregistered
extensions in Windows >>
Additional Notes
salmanhalim@hotmail.com, December 18, 2001 12:27
:se rl
Or nn K :se rightleft<CR>
it is fun
Anonymous, October 14, 2003 16:28
The beauty of rot13 is that you don't have to
"undo". When you rot13 again, it is the reverse
operation, because there are 26 letters in the
alphabet. It's a symmetric cypher.
Anonymous, December 11, 2003 22:22
Some other options:(1)
ZZ
(2)
:%d " to blank the VIM window by deleting all
lines and then press
u
- to restore all of the deleted lines
(3) Don't edit things when you should be doing
something else -- like working. ;-)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #185 - Make vim the editor for files with unregistered extensions in Windows : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #185: Make vim the editor for files with unregistered extensions
in Windows
tip karma
complexity: basic
as of Vim: 6.0
This can be
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
ilan@pointer.co.il, January 1, 2002 23:49
It doesn't work for Windows 2000.
abraund@writeme.com, January 2, 2002 0:43
Too bad...
Tip #185 - Make vim the editor for files with unregistered extensions in Windows : vim online
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Make vim the editor for files with unregistered extensions in Windows | Making search powerful >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Making search powerful | Searching for more than one word at the same time. >>
Additional Notes
kgergely@mcl.hu, January 15, 2002 9:48
Some of your mapping is needless.
Eg. you can search for the word under the cursor with *
and #.
See vimtp#1
arunke@yahoo.com, February 7, 2002 21:15
In response to kgergely's comment.
It is not redundant. If you are using regular
expression for search, you can still continue search
with my mappings, but not with */#
arunke@yahoo.com, February 7, 2002 21:18
sorry I did not read your comment properly. Yeah, its
kinda redundant. But if you wish to restore your cursor
position after a lot of searches, it might be useful.
(with */#, you have to do that many <c-o>s)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #188 - Searching for more than one word at the same time. : vim online
Home
Search
Tip #188: Searching for more than one word at the same time.
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Did you know that with VIM u can search for more
than one word with a single command.
say you want to search all occurances of "bill" or
"ted", or
"harry" in a text.
in normal mode do the following.
/\(bill\)\|\(ted\)\|\(harry\) <Enter>
this will match all instances of either "bill", or
"ted", or "harry" in your
text. the key is the \(\) and \| operators.
\(\) group characters in a word and \| is for ORing.
this is so cool u can even use it for replacing text.
to replace all instances of "bill" or "ted" or "harry"
with "greg"
do the following
:%s/\(bill\)\|\(ted\)\|\(harry\)/greg/g <enter>
(note :- if u have set the option "gdefault" u don't
need the "g" at the
end of the above command)
I don't know of any other editor which can do this, with
so much ease.
Rock on VIM
Njoy
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Making search powerful | Make Ctrl-Backspace delete previous word (like GTK inputs) >>
Additional Notes
davidi@msn.com, December 28, 2001 15:36
Tip #188 - Searching for more than one word at the same time. : vim online
1) Simplified Search
If you don't want to do replaces with captured text you
can simplify eliminating the escaped parentheses, thus
/\(bill\)\|\(ted\)\|\(harry\) <Enter>
becomes
/bill\|ted\|harry <Enter>
Note that you do still have to escape the pipe symbol
2) Simplified Replace
In the example given you don't need the escaped parens
to replace the text 'bill' 'ted' or 'harry' with the
word 'greg,' thus
:%s/\(bill\)\|\(ted\)\|\(harry\)/greg/g <enter>
becomes
:%s/bill\|ted\|harry/greg/g <enter>
3) Capturing the enclosed text
If you do want to capture the enclosed text for
replacement it's still simpler to enclose the whole
statement in one set of parens, thus
/\(bill\)\|\(ted\)\|\(harry\) <Enter>
becomes
/\(bill\|ted\|harry\) <Enter>
4) The full monty
Since using escaped parens -- as in \(bill\|...\) -captures the enclosed text in a regex \1 variable you
can do replacements that would otherwise be sick and
wrong, like put every instance of 'bill' 'ted' or
'harry' in quotes, thus
:%s/\(bill\|ted\|harry\)/"\1"/g
Note: These tricks may work in other versions of vi as
well (for instance it works in vile). I never realized
you had to escape the pipe to do the 'or' trick before
and assumed regexes just weren't fully implemented.
sitar@procaut.txt, January 14, 2002 5:34
There are a few other editors that can do the trick.
Like TextPad for windows,
or Emacs or ..... . Any editor that uses Regular
expressions.
duvell@beer.com, January 25, 2002 21:30
Tip #188 - Searching for more than one word at the same time. : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #189 - Make Ctrl-Backspace delete previous word (like GTK inputs) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Searching for more than one word at the same time. | XP > I-Explorer > HTML Editor < REG files
>>
Additional Notes
jmcpherson@bigfoot.com, January 2, 2002 10:50
Vim has a built-in keyboard command for deleting the
previous word while in Insert mode: Ctrl-W, which works
the same way it does on the command line of your
favorite shell (bash, right? (-;)
So this also works:
:imap <C-BS> <C-W>
Anonymous, January 7, 2002 13:23
Tip #189 - Make Ctrl-Backspace delete previous word (like GTK inputs) : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #190 - XP > I-Explorer > HTML Editor < REG files : vim online
Tip #190: XP > I-Explorer > HTML Editor < REG files
Home
Search
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Tip #190 - XP > I-Explorer > HTML Editor < REG files : vim online
[HKEY_CLASSES_ROOT\.htm\OpenWithList\Vim\shell\edit\command]
@="\"C:\\Program Files\\Vim\\vim60\\gvim.exe\" \"%1\""
; Do NOT add to .html, registry for .htm type suffices
;[HKEY_CLASSES_ROOT\.html\OpenWithList\Vim]
;[HKEY_CLASSES_ROOT\.html\OpenWithList\Vim\shell]
;[HKEY_CLASSES_ROOT\.html\OpenWithList\Vim\shell\edit]
;[HKEY_CLASSES_ROOT\.html\OpenWithList\Vim\shell\edit\command]
;@="\"C:\\Program Files\\Vim\\vim60\\gvim.exe\" \"%1\""
; OPTIONAL: Within Internet Explorer "View Source" with gvim
; but prefer to use Edit button (got to add this) on Toolbar
;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source Editor]
;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source Editor\Editor Name]
;@="C:\\Program Files\\Vim\\vim60\\gvim.exe"
; ============================================= EOF
-------------------------------------------------------CUT HERE--------------Windows Registry Editor Version 5.00
;
;
;
;
;
;
[-HKEY_CLASSES_ROOT\.htm\OpenWithList\Vim]
[-HKEY_CLASSES_ROOT\.html\OpenWithList\Vim]
[-HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source Editor]
http://www.vim.org/tips/tip.php?tip_id=190 (2 of 3) [18/02/2004 14:48:06]
Tip #190 - XP > I-Explorer > HTML Editor < REG files : vim online
; ============================================= EOF
-------------------------------------------------------CUT HERE--------------Happy Vimming...
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Make Ctrl-Backspace delete previous word (like GTK inputs) | Transposing >>
Additional Notes
Anonymous, January 2, 2002 17:52
When using vim to 'view source' from IE, you need to wrap it.
IE requires an editor that can open files with embedded spaces - see vimtip #118 for a
windows scripting solution.
doug@polands.org, July 16, 2002 6:16
Can this be done in the Mozilla as well?
liuch@alum.rpi.edu, September 25, 2002 11:06
I am using opera as my web browser.
www.opera.com
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
You can easily move lines with these maps using <C-Up>
and <C-Down> (only in GUI version :( )
(Works in normal, insert, and visual mode, but you can't
add a count to them)
" Transposing lines
nmap <C-Down> :<C-u>move .+1<CR>
nmap <C-Up> :<C-u>move .-2<CR>
imap <C-Down> <C-o>:<C-u>move .+1<CR>
imap <C-Up> <C-o>:<C-u>move .-2<CR>
vmap <C-Down> :move '>+1<CR>gv
vmap <C-Up> :move '<-2<CR>gv
" Transpose chars (like Ctrl-T in emacs, shell...)
imap <C-F> <Esc>Xpa
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<XP > I-Explorer > HTML Editor < REG files | Latex Help for VIM >>
Additional Notes
Anonymous, January 6, 2002 20:50
There is another way to transpose chars.
Simply type xp in command mode.
Douglas Potts <pottsdl@yahoo.com>, January 7, 2002 5:04
Nice touch using the ex move commands.
'polluting' registers
with the text you are transposing.
Add Note
Keeps from
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
Site Help
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
mikmach@wp.pl, January 7, 2002 14:38
Sorry all :(((((((((((((((((((
http://www.vim.phg.pl/latexhelp.zip
mikmach@wp.pl, January 7, 2002 14:39
Sorry all :(((((((((((((((((((
http://www.vim.phg.pl/latexhelp.zip
maxiangjiang@hotmail.com, January 8, 2002 8:46
Thanks.
Any tools to get the job done?
Hopefully, all applications will have a help file in
vim format shipped out.
maxiangjiang@hotmail.com, January 8, 2002 8:50
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #193 - Insert the current filename at cursor postion. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
<C-R>=expand("%:t:r")<CR>
Enjoy!
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
bindu@wavell.net, January 22, 2002 17:38
I often use <C-R>% when in insert mode... It does the
same thing, except you also get your file extension.
isaac.sparrow@engineer.com, March 1, 2002 14:44
Cool tip. I find myself needing to do this whenever I
create a new Java file.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
<<Insert the current filename at cursor postion. | Switching between files >>
Additional Notes
jmcpherson@softhome.net, January 8, 2002 15:17
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
glen_ap@yahoo.com, September 6, 2002 16:34
I don't know which way is better, but I couldn't get
that way to work. So I use this instead.
:map <C-Tab> :bn<CR>
:map <C-S-Tab> :bp<CR>
(Reminds me of Perl, TMTOWTDI)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
<<Switching between files | Open file in already running vim from elsewhere >>
Additional Notes
Anonymous, September 17, 2002 7:41
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #197 - Open file in already running vim from elsewhere : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<FileName Completion in Shell Scripts | Pasting code with syntax coloring in emails >>
Additional Notes
hari_vim@yahoo.com, January 15, 2002 16:11
Just wanted to add to this that there are builtin functions
available that let you do the same thing from within
running Vim session. It is cool, if you want some sample
code, see the following script:
http://vim.sourceforge.net/scripts/script.php?script_id=180
schabungbam@hss.hns.com, January 24, 2002 4:02
Tip #197 - Open file in already running vim from elsewhere : vim online
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #198 - Pasting code with syntax coloring in emails : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Tip #198 - Pasting code with syntax coloring in emails : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Open file in already running vim from elsewhere | maximize window and return to previous split
structure >>
Additional Notes
benji@member.AMS.org, January 15, 2002 20:16
1. If you are using gvim then you can convert to HTML
from the Syntax menu, so you do not have to remember
the right file to source.
2. I got it to work using Netscape. I converted to
HTML, saved the file, opened the file in Netscape, and
chose "Send Page..."
from the file menu. This sends the HTML as an
attachment. When I got the message, the attachment was
displayed in-line;
this depends on how preferences are set. It would
probably also work to simply save the file and then
attach it.
raycast@hotmail.com, February 21, 2002 11:59
Internet Explorer??? What the heck is that? I don't
have that... :-P
hari_vim@yahoo.com, February 23, 2002 13:40
Well, you can always send HTML mail, but it will
probably not easy to send some inlines snippets that
way. More over, I use this to include sample code while
writing design documents in MS word too.
"Soren Andersen" <perlspinr@att.net>, May 1, 2002 14:22
Tip #198 - Pasting code with syntax coloring in emails : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #199 - maximize window and return to previous split structure : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Pasting code with syntax coloring in emails | Bouncing Parentheses (during insertion) >>
Tip #199 - maximize window and return to previous split structure : vim online
Additional Notes
scottu@apptechsys.com, January 16, 2002 17:34
There is a bug in the function such that the session
file used is "s:maximize_session" in the current
directory rather than the temp file created with
tempname (). Replace the function with this:
function! MaximizeToggle()
if exists("s:maximize_session")
exec "source " . s:maximize_session
call delete(s:maximize_session)
unlet s:maximize_session
let &hidden=s:maximize_hidden_save
unlet s:maximize_hidden_save
else
let s:maximize_hidden_save = &hidden
let s:maximize_session = tempname()
set hidden
exec "mksession! " . s:maximize_session
only
endif
endfunction
bhoang99@yahoo.com, April 24, 2003 8:25
perhalf you can leave that complex window alone and
open another gvim session...
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<maximize window and return to previous split structure | The meaning of life >>
Additional Notes
cec@NgrOyphSon.gPsfAc.nMasa.gov, January 17, 2002 12:58
Somewhat better map:
inoremap ) )<left><c-o>%<c-o>:sleep 500m<CR><c-o>%<co>a
There was a problem when inserting parentheses into
previously
existing text which the <left> handles.
mbrubeck@hmc.edu, January 17, 2002 14:58
Vim 6 has this functionality built-in.
'showmatch' and 'matchtime' options.
salmanhalim@hotmail.com, January 17, 2002 20:07
See the
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
(Based on a posting at comp.editors), January 25, 2002 9:53
Also check out
:help!
and
:help holy-grail
horsch@cs.usask.ca, November 10, 2002 12:30
But the question is wrong!
The right question is:
"What is the answer to the ultimate
question of life the universe and everything?"
Anonymous, August 27, 2003 4:12
seems to be a serious VIM bug!
;-)) Thomas
Michael-o-mendolsohn@vsnl.com, December 12, 2003 19:39
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: advanced
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
hari_vim at yahoo.com, January 21, 2002 19:04
While going through the help pages, I figured this
feature is documented with the following example:
:debug edit <file>
This should let you debug autocommands that get
triggered by loading a new buffer.
Hari
Mark Hillebrand, February 19, 2002 6:31
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<debugging window autocommands | Some mappings for using cscope with vim. >>
Additional Notes
Anonymous, January 27, 2002 20:21
great
salmanhalim@hotmail.com, January 29, 2002 6:01
since typing :Make is a bit troublesome compared to
:make (which i also find a bit tiresome :)) i have a
mapping:
:map <Leader>j :Make<cr>
then, just hit \j and away you go.
Chad, June 17, 2002 13:59
Great tip. I came to this site looking exactly for
this information (like I can remember the errors w/out
seeing them :-)). Thanks alot.
daniel@brot.t0c.de, October 18, 2002 6:17
Chad: with :cc you can see the current error and with
:cn and :cp you can switch between the errors.
vim even goes to the position in sourcecode where they
occured.
ezaydens@optonline.net, January 13, 2003 10:14
Does anybody know how to display a complete error
message that is too long for the line? By default it
inserts ellipsys in the middle of it and only displays
the beginning and the end...
Thanks a bunch.
EZ
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #204 - Some mappings for using cscope with vim. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
These mappings can make using cscope a fun. You can copy
the word under the cursor in one window, and search for
it from other window.
" Copy and paste the word under cursor
map <silent> <C-Space> :let@m=expand("<cword>")<CR>
" Use the C-Space word as
map <C-F6> :cscope find s
map <C-F5> :cscope find c
map <C-F7> :cscope find g
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: advanced
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Some mappings for using cscope with vim. | Highlight doubled word errors in text >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Highlight doubled word errors in text | Alter the display of buffers in the buffers menu >>
Additional Notes
mark@summersault.com, January 31, 2002 10:28
When I have a some SQL in vim that I want to see the
results of, I use this simple technique to send it to
Postgres:
1. Highlight the the SQL.
2. :!psql -d my _database
(for Postgres)
Vim will filter my lines through that command replace
them with the result set. When I'm done reviewing the
results, I use "u" to undo the change.
If I repeat this cycle, I can use use :CTRL-P to get
back the previous command to use, and instead of typing
it again.
For larger pieces of SQL, I put it in a file and use:
:!psql -d my_db -f %
to send the whole script to Postgres.
Wolfgang.Stroh@chello.at, February 1, 2002 2:41
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #208 - Alter the display of buffers in the buffers menu : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
If you use the buffers menu, here's where you can change
how the buffernames are displayed:
menu.vim, function s:BMMunge
OLD:
displays:
Site Help
.vimrc (1)
menu.vim (2)
NEW:
displays
1. .vimrc
2. menu.vim
(with the 1 and the 2 underlined)
which is more useful, because you can (almost) always
pick the buffer you want with one keystroke, the
buffernumber, until you get to buffer 10 anyway.
Roger
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Anonymous, October 15, 2002 10:12
Tip #208 - Alter the display of buffers in the buffers menu : vim online
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Alter the display of buffers in the buffers menu | compiling the actual file with gcc >>
Additional Notes
rmadhu@cisco.com, February 1, 2002 12:20
Similarly Ctrl-I in the reverse order. Ctrl-I is also
as useful as Ctrl-o. Try it for yourself.
saisanthosh@yahoo.com, August 21, 2002 15:06
type u<char> bookmarks the current position.
'<char> to return to that
position
vim@campbell-lange.net, January 9, 2003 14:49
Type
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #210 - compiling the actual file with gcc : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
This tip is for those who like to change their vim color themes pretty
often. I like different themes just for a change in my work environment.
achieve this just add the following to your .vimrc or _vimrc file.
To
let themeindex=0
function! RotateColorTheme()
let y = -1
while y == -1
let colorstring =
"#blue.vim#elflord.vim#evening.vim#koehler.vim#murphy.vim#pablo.vim#ron.vim#"
let x = match(colorstring,"#",g:themeindex)
let y = match(colorstring,"#",x+1)
let g:themeindex = x+1
":echo x y g:themeindex
if y == -1
let g:themeindex = 0
else
let themestring = strpart(colorstring,x+1,y-x-1)
echo("Setting Theme to-> ".themestring)
return ":so $VIMRUNTIME/colors/".themestring
endif
endwhile
endfunction
Change the value of colorstring above by changing the line
let colorstring =
"#blue.vim#elflord.vim#evening.vim#koehler.vim#murphy.vim#pablo.vim#ron.vim#"
You can add your favorite color themes in this string so that you can rotate
between them. Just make sure that any string that you add is in between the
# as shown above. Just follow the format above and things will work.
Then assign a key to roate the theme.
map <F8> :execute RotateColorTheme()
Dunno if there are better ways to do the same.
wrote the above.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<compiling the actual file with gcc | Setting file attributes without reloading a buffer >>
Additional Notes
Anonymous, February 7, 2002 1:15
note that its usually much better to put things like this
in your $HOME/vimfiles or $HOME/.vim directory instead of
or ~/_vimrc.
that makes the vimrc nice and simple and also portable to
of vim which might not have some of the things which this
instance.
as a script file
in the ~/.vimrc
earlier versions
function uses for
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #212 - Setting file attributes without reloading a buffer : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Additional Notes
Add Note
Unfulfilling
rate
Tip #212 - Setting file attributes without reloading a buffer : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<Setting file attributes without reloading a buffer | Current buffer based menus >>
Additional Notes
seenutn@cdotb.ernet.in, February 18, 2002 22:53
Can I get this tips in my INBOX??
Regards,
Seenu.
pdwalker@usa.net, August 17, 2003 22:36
use g/^$/d to delete all the blank lines in your file.
(I think there is an easier/faster way to do this, but
I forget how)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<delet all lines containt TXT | Edit configuration files for a filetype >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
fun! Edit_ft_conf(name)
" we may not do this with a loaded file, since this
won't trigger the
" configuration file loading as desired.
" try calling with 'call
Edit_ft_conf("nonexistingfile.<EXT>")' if this
" gives you troubles
if bufexists(a:name) && bufloaded(a:name)
echo "!Attention: buffer for " . a:name . " is
loaded, unload first."
return
endif
" split-open the file with verbose set, grab the
output into a register
" (without clobbering)
let safereg = @u
redir @u " redirect command output to register @u
exec "silent 2verbose split " . a:name
" verbose level 2 suffices to catch all scripts
which get opened
redir END
" Parse register @u, looking for smth like:
'sourcing"/usr/local/share/vim/vim60/syntax/c.vim"'
let pos = 0
let regexp = 'sourcing "[^"]\+"'
while match(@u,regexp,pos) >= 0
let file = matchstr(@u,regexp,pos)
let pos = matchend (@u,regexp,pos)
let file = strpart(file,10,strlen(file)-11)
exec "silent below split " . file
endwhile
" restore the register
let @u = safereg
endfun
Life Changing
Helpful
Unfulfilling
<<Current buffer based menus | calculate equations from within vim >>
Additional Notes
billG@megasoft.com, February 15, 2002 10:55
this is supposed to be a tip section.
so submit a TIP not a PhD thesis
rate
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
3 +
4 2 * (1 / (3 + 2)) = 6.60000000000000000000
define rad (x) {
return (x / 180) * 4 * atan (1)
}
cos (rad (45)) = .70710678118654752440
Fun, no?
file:
Life Changing
Helpful
Unfulfilling
rate
<<Edit configuration files for a filetype | Translate &#nnn; in html source to readable ascii >>
Additional Notes
Anonymous, February 16, 2002 15:22
PLEASE do not give such things as tips! make this as a
script and put this in the scripts section. starting
from version 6.0 (which is hopefully what most people
are using),
vim provides the ability to have "plugins". (:he
plugin). imho, its bad practice to keep extending your
~/.vimrc. the rc file should be used for tweaking vim's
settings and such.
it is not a good place to put functions etc. this make
the .vimrc very bloated.
also it ofcourse makes it just a bit harder for users
of vim.sf.net :) now one has to cut and paste the file
into a new file, save it as a file and in most browsers
strip trailing
blanks and stuff which might screw the maps. and if you
care about aesthetics, then you will often have to
repair the indentation. (my browser makes this tip not
have absolutely
any indentation). when you provide a simple
downloadable file, it becomes plug-and-play.
btw, nice tip!
i am not quite sure what others think of this.
personally i prefer functions etc to be in the scripts
section.
tsurban@attbi.com, February 16, 2002 15:56
Good points - I've uploaded it as vimscript #219 - with
a fix that escapes ";" chars.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #217 - Translate &#nnn; in html source to readable ascii : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
exec '%s/&/\&/g'
47
exec '%s///\//g'
exec '%s/&#' . n . ';/' . nr2char(n) .
Life Changing
Helpful
Unfulfilling
rate
<<calculate equations from within vim | Check for comments, independent of the filetype >>
Additional Notes
Larry, again, February 21, 2002 12:53
Tip #217 - Translate &#nnn; in html source to readable ascii : vim online
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #218 - Check for comments, independent of the filetype : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: advanced
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Translate &#nnn; in html source to readable ascii | make from command line, open vim on errors >>
Additional Notes
Add Note
Tip #218 - Check for comments, independent of the filetype : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #219 - make from command line, open vim on errors : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Check for comments, independent of the filetype | Regexp: Match every word except 'foo' >>
Additional Notes
Anonymous, February 22, 2002 15:57
err,
:%s/add a not/add a note/
Anonymous, February 25, 2002 13:20
faster (is there a tip for this yet?):
:%s/add a not/&e/
davef@tetsubo.com, February 27, 2002 14:33
http://www.vim.org/tips/tip.php?tip_id=219 (1 of 2) [18/02/2004 14:49:24]
Tip #219 - make from command line, open vim on errors : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #220 - Regexp: Match every word except 'foo' : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<make from command line, open vim on errors | indenting "throws" in java >>
Additional Notes
david@tvis.co.uk, March 30, 2002 10:04
Very good explanation of difficult to grasp features,
zero-width matching, keyword matching and very magic.
very magic \v appears to save a lot of backslashing!!!
ben.leighton@wizardis.com.au, May 2, 2002 17:08
Tip #220 - Regexp: Match every word except 'foo' : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Regexp: Match every word except 'foo' | Building vim with color on HP-UX >>
Additional Notes
Alexey Marinichev, March 4, 2002 12:03
Patch 6.1a.026 adds a more general solution to java
indent file.
jmcnair@guarded.net, November 13, 2003 10:35
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Additional Notes
Unfulfilling
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
cec@NgrOyphSon.gPsfAc.nMasa.gov, March 12, 2002 12:49
Interesting idea, but it will only work for those whose
vim has the
+rightleft option. For those who don't have such a
vim, use "ma" to
(mark a) and move the cursor to the last line to be
affected, and:
\fr: will reverse the order of lines (vertical mirror)
nmap \fr
:set lz<CR>o<Esc>mz'aO<Esc>ma:'a+1,'z-1g/^/m
'a<CR>'addma'zdd:set nolz<CR>
\fR: will mirror image the lines (horizontal mirror)
nmap \fR
:set
lz<CR>o<Esc>mzkO<Esc>maj:s/./&\r/g<CR>:'a+1,'z-1g/^/m
'a<CR>:'a+1,'z-1j!<CR>'add'zddk:set nolz<CR>
http://www.vim.org/tips/tip.php?tip_id=223 (1 of 2) [18/02/2004 14:49:37]
Regards,
Charles Campbell
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
I use the < and > commands on blocks a lot, and it has
always annoyed me that if you want to shift more than
one 'shiftwidth', you have count how many 'shiftwidth's
you want to enter the '[count]>', or restore the
selection with "gv". So I've cooked up two mappings that
come in very handy:
:vnoremap < <gv
:vnoremap > >gv
These mappings will reselect the block after shifting,
so you'll just have to select a block, press < or > as
many times as you like, and press <ESC> when you're done
to unselect the block.
I know it's not rocket science, but it sure has helped
me a lot.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Anonymous, March 13, 2002 9:35
I use "." (repeat previous command) to shift the block
again
Anonymous, March 18, 2002 19:44
"." is nice, but it only moves in the same
direction. It's not the same thing as the tip.
Anonymous, March 19, 2002 1:46
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
vim can interact with the tricks that the latest xdvi
does:
* If one clicks at some place in xdvi, vim automatically
jumps to the
corresponding line in the LaTeX source file ("reverse
search")
* Also, from inside vim, one can jump to the
corresponding line in xdvi
which becomes highlighted ("forward search").
Here is how to do it:
* Reverse search:
We start a vim server by: vim --servername xdvi
We start xdvi(k) on file.dvi by:
xdvik -editor "vim --servername xdvi --remote +%l
%f" file.dvi
At the desired location in xdvi, we press:
<ctrl><left_mouse>
Then, vim will jump to the corresponding line in the
source file.
* Forward search:
Inside vim, we type, for example, _g which is the
following mapping:
(the following should be a single line)
map _g :execute "!xdvik -name xdvi -sourceposition "
. line(".") . expand("%") . " " . expand("%:r") . ".dvi"
<cr><cr>
[the command to go to the point of xdvi that
corresponds to line, eg, 77
of the source file is (no space after 77)
xdvik -name xdvi -sourceposition 77file.tex
file.dvi ]
Life Changing
Helpful
Unfulfilling
rate
<<Shifting blocks visually | Edit file under cursor after a horizontal split >>
Additional Notes
benji@member.AMS.org, March 20, 2002 20:09
If you use the MikTeX distribution on Win32, you
can play the same game with vim and yap.
I use the following with vim 6.0 and (old) MikTeX 1.20b
.
From my vim script for tex files:
execute '!start yap -1 -s' line(".") . expand("%:t")
expand("%:p:r")
(Of course, I have a :map and :menu to do this.)
expands to something like
!start yap -1 -s 1353foo.tex c:\path\to\foo
In yap, from the View/Options panel, choose the
"Inverse Search" tab and enter
D:\vim\vim60\gvim.exe --remote +%l %f
in the "Command line" box. This can probably be
improved: doesn't the installer put a .bat file
somewhere? ...
Mark A. Hillebrand, March 21, 2002 4:02
This
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #226 - Edit file under cursor after a horizontal split : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
I use the command 'gf' quite often. But with this command the current buffer is
hidden. To avoid that I use the following mapping :
map gw <Esc>:sp %<CR> gf
With this mapping the file under the cursor is opened after a horizontal split.
rate this tip
Life Changing
Additional Notes
shakti@ti.com, March 23, 2002 22:12
Helpful
Unfulfilling
rate
Tip #226 - Edit file under cursor after a horizontal split : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
document by one
:.,$g/^\d/exe "normal! \<c-a>"
Comment (C) lines containing "DEBUG" statements
g/^\s*DEBUG/exe "norm! I/* \<Esc>A */\<Esc>"
A Reverse lookup for records
(eg: An address book, with Name on start-of-line and
fields after a space)
:g/<patern>?^\w?p
"if only name is
interested
:g/<patern>/ka|?^\w?p|'ap
"if name and the
lookup-line is interested
:g/<patern>/?^\w?|+,/^[^ ]/-1p "if entire record is
interested
Reverse a file (just to show the power of 'g')
:g/^/m0
Foot note 1: use :v to negate the search pattern
Foot note 2: Some explanation of commonly used commands
with :g
:2,8co15 => Copy lines 2 through 8 after line 15
:4,15t$ => Copy linesa 4 through 15 towards end of
document (t == co)
:-t$ => Copy previous line to end of document
:m0 => Move current line to the top of the
document
:.,+3m$-1 => Move current line through cur-line+3 to the
last but one line
of the document
Foot note 3: Commands used with :g are ex commands, so a
help search should
be,
:help :<help-topic>
eg. :help :k
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Edit file under cursor after a horizontal split | Deleting nested reply threads in emails >>
Additional Notes
david@tvis.co.uk, March 28, 2002 7:10
To answer
kkgahlot's question:
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Additional Notes
salmanhalim@hotmail.com, March 25, 2002 6:15
Unfulfilling
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #229 - First thing to try before asking help : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Deleting nested reply threads in emails | copy current file to another location from within vim >>
Additional Notes
Anonymous, March 27, 2002 19:20
Forgot to add that <c-d> can be used for listing other
matches also.
For eg:
:e <c-d> "to show list of files matching the pattern
:buf <c-d> "to show list of open buffers etc.
-Arun
Tip #229 - First thing to try before asking help : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #230 - copy current file to another location from within vim : vim online
Home
Search
Tip #230: copy current file to another location from within vim
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<First thing to try before asking help | Localized color schemes >>
Additional Notes
maxiangjiang@homail.com, April 2, 2002 15:11
Why not
:w %:t c:/Progra~1/Tomcat/webapps/console/pages/
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<copy current file to another location from within vim | Search JDK help for keyword at cursor >>
Additional Notes
@, April 8, 2002 5:28
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #232 - Search JDK help for keyword at cursor : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
If you are using the Win32 version of Vim you can use this tip to
search the Jdk help for the keyword under the cursor.
You need the winhlp32 version of the Jdk docs from this URL http://www.confluent.fr/javadoc/indexe.html.
It is a 16mb D/L and approx 85mb unzipped!
I added a command to the popup menu
:amenu PopUp.JavaHelp :!start winhlp32 -k <cword>
F:\jdk\winhelp\JDK13.HLP <CR
And also made a keymapping
map J :!start winhlp32 -k <cword> F:\jdk\winhelp\JDK13.HLP <CR>
Trivial yes, but I find it quite useful.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Localized color schemes | Some tips for using Vim to write Lisp code >>
Additional Notes
jmcpherson@softhome.net, April 9, 2002 9:29
Not a bad idea. Here is one for ColdFusion programmers on
Windows:
map K :!"C:\Program Files\Internet Explorer\iexplore.exe"
http://servername/cfdocs/searchmain.cfm?searchstring=<cword><CR>;
where "servername" is the name of a server that has the
ColdFusion documentation installed.
By the way, I mapped it to K because K is Vim's default "help on
keyword under cursor" function, which (traditionally) calls up
the Unix 'man' program. Vim on Windows doesn't use man, though,
so it makes sense to map that to something specific to the
language I use most. (If you work with multiple languages, why
not add language-specific K mappings for each to filetype.vim?
You could get the right help program for whichever language you
were working with.)
In a standard Vim install, J is used in command-mode to join
http://www.vim.org/tips/tip.php?tip_id=232 (1 of 2) [18/02/2004 14:50:03]
Tip #232 - Search JDK help for keyword at cursor : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #233 - Some tips for using Vim to write Lisp code : vim online
Home
Search
Tip #233: Some tips for using Vim to write Lisp code
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
For some tips on how to use Vim for writing Lisp code,
see http://www.lisp-p.org/i000/15-vim.
Life Changing
Helpful
Unfulfilling
rate
<<Search JDK help for keyword at cursor | Vi(M) Command Line tips & tricks >>
Site Help
Additional Notes
srinathava at yahoo dot com, April 9, 2002 18:19
The link above doesnt work (as of April 9, 2002).
since tip editing doesnt work, add the correct link as
a comment below...
Anonymous, April 10, 2002 4:38
Try adding a / to the end.
find from www.lisp-p.org
http://www.lisp-p.org/i000/15-vim/
Anonymous, April 14, 2002 11:23
Beware! The correction (10 April) *still* doesn't
include the trailing "/" if you attempt to click on it.
Typing in the full URL (including the trailing "/")
works fine.
Once you get past the pain of *getting* to it, the
article is actually an interesting discussion on
writing Lisp using Vim 6.x. (Never thought of "set
foldmethod=indent shiftwidth=1" !!)
I'll attempt to correct the URL one more time:
http://www.lisp-p.org/i000/15-vim/
Tip #233 - Some tips for using Vim to write Lisp code : vim online
Thanks, y'all.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #234 - Vi(M) Command Line tips & tricks : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Hi VIMMERs
These tips save me wearing out my delicate little
fingers with unnecessary keystrokes.
They assume Unix, but I also use them on a Windows Unix
Shell (MKS) as well
# When I know the file i want to edit is the most recent
file in a directory
alias -x vew='vi `l\s -t * | head -1 `'
#When I know the file I want to edit contains a unique
keyword
#this is actually in a little shell script call ed vg
where the keyword is passed as parameter $1
#/bin/sh
#name vg
vi.exe $(grep -isl $1 *) &
# some variations
alias -x vp='vi `l\s -t *.@(pl|cgi)| head -1 `'
#execute the most recent script (I call this from within
VIM with a mapped button)
alias -x xew='`l\s -t *.pl | head -1 `'
Cheers zzapper
Life Changing
Helpful
Unfulfilling
rate
<<Some tips for using Vim to write Lisp code | Toggle highlight word under cursor, to find cursor. >>
Additional Notes
Tip #234 - Vi(M) Command Line tips & tricks : vim online
Tip #234 - Vi(M) Command Line tips & tricks : vim online
Tip #234 - Vi(M) Command Line tips & tricks : vim online
Tip #234 - Vi(M) Command Line tips & tricks : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #235 - Toggle highlight word under cursor, to find cursor. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Vi(M) Command Line tips & tricks | Menu for inserting special characters >>
Additional Notes
gsinclair@soyabean.com.au, April 12, 2002 20:44
Good trick. Another way to find the cursor is to hit
zz, which moves the current line to the center of the
screen.
Tip #235 - Toggle highlight word under cursor, to find cursor. : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
R>=nr2char(148)<CR><ESC>
20imenu Editieren.Sonderzeichen.fat\ dot\ \ <C-R>=nr2char(149)<CR>
20nmenu Editieren.Sonderzeichen.fat\ dot\ \ a<CR>=nr2char(149)<CR><ESC>
20imenu Editieren.Sonderzeichen.etc\ \ \ <C-R>=nr2char(133)<CR>
20nmenu Editieren.Sonderzeichen.etc\ \ \ a<C-R>=nr2char(133)<CR><ESC>
20imenu Editieren.Sonderzeichen.!underscore\ \ <C-R>=nr2char(175)<CR>
20nmenu Editieren.Sonderzeichen.!underscore\ \ a<CR>=nr2char(175)<CR><ESC>
20imenu Editieren.Sonderzeichen.copyright\ \ <C-R>=nr2char(169)<CR>
20nmenu Editieren.Sonderzeichen.copyright\ \ a<CR>=nr2char(169)<CR><ESC>
20imenu Editieren.Sonderzeichen.paragraph\ \ <C-R>=nr2char(167)<CR>
20nmenu Editieren.Sonderzeichen.paragraph\ \ a<CR>=nr2char(167)<CR><ESC>
20imenu Editieren.Sonderzeichen.noitamalcxe\ <C-R>=nr2char(161)<CR>
20nmenu Editieren.Sonderzeichen.noitamalcxe\ a<CR>=nr2char(161)<CR><ESC>
Life Changing
Helpful
Unfulfilling
rate
<<Toggle highlight word under cursor, to find cursor. | If you prefer vertical splits >>
Additional Notes
Thomas.Ramming@gmx.de, April 23, 2002 7:38
Thanks for rating.
Should I mention that you can insert lines (if you know the length)
e.g. by typing
'40'<select special char from menu>
in normal mode ?
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
split vsplit
hsplit split
sta vertical sta
help vertical help
new vnew
right botright
if (winnr () == old)
echo "Ouch"
return
endif
exec "wincmd " . back
quit
if (back == "j" || back == "k")
let orientation = "vsplit"
else
let orientation = "split"
endif
if (back == "j" || back == "l")
let dir = "below"
else
let dir = "above"
endif
exec dir . " " . orientation " " . currFname
endfunction
noremap ^W^] ^W^]:silent call ToggleSplit ("d")<CR>
; Optional.
set splitright
; In which case the above mapping becomes:
noremap ^W^] :set splitbelow<CR>^W^]:silent call
ToggleSplit ("u")<CR>:set nosplitbelow<CR>
; Or you could just
set splitbelow
; :-)
; Very elegant and almost perfect, but it screws up if
you want to run a command with ranges :-)
;noremap : :vertical<Space>
; EOF
rate this tip
Life Changing
Helpful
Unfulfilling
<<Menu for inserting special characters | Very basic session persistence >>
Additional Notes
Add Note
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<If you prefer vertical splits | Scroll using arrow keys like browser: map shift-up and shift-down >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #239 - Scroll using arrow keys like browser: map shift-up and shift-down : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #239: Scroll using arrow keys like browser: map shift-up and
shift-down
tip karma
complexity: basic
as of Vim: 5.7
<down> <c-e>
<up> <c-y>
<s-down> j
<s-up> k
Tip #239 - Scroll using arrow keys like browser: map shift-up and shift-down : vim online
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
quesadaj@psych.colorado.edu, August 13, 2003 11:56
This would be great, but doesn't work with my
combination of secure F SSH (windows) and TERM=xterm.
The arrows cannot be mapped as <up>, etc, nor the
<home> key. Any idea about why?
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Xemacs has a hide all function which can make all the
function in your C file a fold and close them. And here
is something small to achieve similiar under Vim.
func! HideAll()
syn region myFold start="{" end="}" transparent fold
syn sync fromstart
set foldnestmax=1
set foldmethod=syntax
endfunc
amenu Whatever.Hide\ all :call HideAll()<CR>
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Scroll using arrow keys like browser: map shift-up and shift-down | "Hide" Folding Markers >>
Additional Notes
zhichao_h@yahoo.com, May 2, 2002 13:06
It works fine in version 6.0. But in version 6.1, it
is really ugly.
Suppose, you have the following Java
public class Hello {
zhichao_h@yahoo.com, May 2, 2002 13:09
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
|
\ hi fmrkr term=NONE guibg=black
guifg=black
\
ctermbg=black
ctermfg=black
au BufRead,BufNewfile
contained
|
\ hi fmrkr term=NONE guibg=black
guifg=black
\
ctermbg=black
ctermfg=black
They both accomplish the same thing, but with different
methods, so
simply pick one and see those annoying (at least to me)
markers fade away.
I just tried it out with vim files, but you can easily
modify it for
any other filetypes.
Thanks to Colin's lead with ':help c-syntax'
for the
1st au.
Thanks to Benji's lead with ':help containedin' for the
2nd au.
Understanding most of the syntax.txt document file would
also be helpful.
http://www.vim.org/tips/tip.php?tip_id=241 (1 of 2) [18/02/2004 14:50:23]
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
kgergely@mcl_remove.hu, May 23, 2002 6:29
Instead of using black color, consider using the Ignore
highlighting group!
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Additional Notes
Hal Atherton, May 7, 2002 22:58
Unfulfilling
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
<<The power of "\_" in reg-ex | Ask vim where an option was set. >>
Additional Notes
benji@member.AMS.org, May 12, 2002 8:15
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #244 - Ask vim where an option was set. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
atheeban@yahoo.com, October 8, 2002 11:34
I was looking for this quite sometime. I have installed
RH7.1 on my pc and was wondering how the default
settings for vim were set. Good one!.
lk1@teamten.com, February 12, 2003 15:52
Is there a similar feature for mappings? RedHat ships
with a modified vim that sources their own set of maps,
and it took me forever to track them down and disable
them. This feature for maps would have saved me a lot
of trouble.
zzapper@ntlworld.com, August 28, 2003 3:23
Tip #244 - Ask vim where an option was set. : vim online
:scriptnames
location
:map
:functions
:ab
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Here are the main options you will want to set if you want
to work with Unicode files in (g)vim (see at bottom what
help tags to look for)
if has("multi_byte")
set encoding=utf-8
" how vim
shall represent characters internally
setglobal fileencoding=utf-8
" empty is also
OK (defaults to same as 'encoding'). Or you may want to set
one of the ucs encodings (which
"
may use less disk space if you use only "alphabetic"
scripts such as Latin, Greek, Cyrillic, Hebrew or Arabic,
and
"
not "ideographic" scripts like Chinese, Japanese or Korean.
With the ucs encodings it is usually better
set bomb
" to
also set 'bomb' on ('byte-order-mark" option, irrelevant
for utf-8 but not for ucs)
set termencoding=iso-8859-15
" or whatever is
appropriate to your locale (iso-8859-15 is Latin1 + Euro
currency sign)
set fileencodings=ucs-bom,iso-8859-15,iso-8859-3,utf-8
" or whatever is appropriate to the kinds of files
you want to edit
" 'fileencodings' defines the heuristic to set
'fillencoding' (local to buffer) when reading an existing
file. The first one that matches will be used.
" ucs-bom is "ucs with byte-order-mark"; it must
not come after ucs-8 if you want it to be used
else
echoerr "Sorry, this version of (g)vim was not
compiled with +multi_byte"
endif
In "replace" mode, one utf character (one or more data
bytes) replaces one utf character (which need not use the
same number of bytes)
utf8
'enc'
'fenc'
'fencs'
'tenc'
'bomb'
'guifont'
ga
g8
i_Ctrl-V_digit
Happy Vimming !
Tony.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Ask vim where an option was set. | Working with Unicode (the same, rewritten for legibility) >>
Additional Notes
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #246 - Working with Unicode (the same, rewritten for legibility) : vim online
Home
Search
Tip #246: Working with Unicode (the same, rewritten for legibility)
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Tip #246 - Working with Unicode (the same, rewritten for legibility) : vim online
Life Changing
Helpful
Unfulfilling
rate
Tip #246 - Working with Unicode (the same, rewritten for legibility) : vim online
<<Working with Unicode (platform-independent) | Preexisting code indentation >>
Additional Notes
Anonymous, July 7, 2002 17:03
This doesn't work in gvim on MS-Windows.
Apparently you need to use CTRL-Q instead of CTRL-V,
eg, CTRL-Q u00f1.
antoine.mechelynck@belgacom.net, July 25, 2002 17:53
I use gvim on W32 but I avoid sourcing $VIMRUNTIME/mswin.vim so
Ctrl-V works for me. But you are right, I ought to have mentioned
that if Ctrl-V has been mapped to do a paste, then one should use
Ctrl-Q instead.
-- The Author.
antoine.mechelynck@belgacom.net, July 26, 2002 12:46
About the byte-order mark:
The Unicode standard defines a byte-order mark for optional use at
the start of all Unicode files (ucs-8 as well as little-endian or
big-endian utf-16 and utf-32); it is the character "zero-width nonbreaking space", codepoint U+0xFEFF and comes out as follows:
utf-8:
utf-16
utf-16
utf-32
utf-32
le:
be:
le:
be:
EF BB BF
FF FE
FE FF
FF FE 00 00
00 00 FE FF
Tip #246 - Working with Unicode (the same, rewritten for legibility) : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Working with Unicode (the same, rewritten for legibility) | Auto-save the current buffer periodically.
>>
Additional Notes
parlorinventor@hotmail.com, May 17, 2002 6:08
/\t/g
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
I have no idea if this was implemented in vim 5.3 or not, but you can
definitely do the following kludge in 6.x by using CursorHold and
localtime:
- When you
time:
to the current
enough time
has elapsed
you're certain
The thing to note is that the CursorHold will only fire after
'updatetime' milliseconds of inactivity have elapsed. So, if you type
rapidly for one and a half minutes non-stop, it won't actually save
anything until you STOP activity long enough. This may be what you want
anyway because it won't interrupt your activity with a forced save.
The actual save-delay can be changed from '60' to another number (in
seconds) or a variable or anything like that. This entire functionality
can be easily wrapped inside a nice script which enables/disables this
on a per-buffer basis (maybe with maps etc.). If desired, I can provide
that also.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
vim at tritarget.com, May 20, 2002 23:08
This is cool. However I personaly like how swap files do this for me.
By default a swap file is writen to after either 200 characters are
typed or 4 seconds of inactivity has elapsed. Since a swap file writes
faster and updates sooner a recovery is quite simple and sometimes
more reliable if something goes wrong.
This is just my personal preference. Some may like the physical auto
saving as opposed to swap file recovery. Word for example uses both
methods by default. (Yes, I know bad example! Please no flames. ^_^)
salmanhalim@hotmail.com, May 22, 2002 5:55
Actually, it wasn't my intention to provide this as a mechanism
without knowing about the swap file -- am fully aware of how that
works. However, someone had asked about this on the Vim email list
and since I posted a longish answer there, I decided to make a tip out
of it also.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #249 - C/C++: Quickly insert #if 0 - #endif around block of code : vim online
Home
Search
Tip #249: C/C++: Quickly insert #if 0 - #endif around block of code
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
Additional Notes
nospam@nospam.org, May 23, 2002 3:05
Clever~ :-)
pottsdl@netzero.net, May 23, 2002 4:59
rate
Tip #249 - C/C++: Quickly insert #if 0 - #endif around block of code : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<C/C++: Quickly insert #if 0 - #endif around block of code | c/c++: align #endif with corresponding
#if/#ifdef >>
Additional Notes
Anonymous, May 23, 2002 7:47
When I say type, I mean put it into your .vimrc of
course
Anonymous, May 23, 2002 19:37
Should the 'hidden' option be set for this to work?
Sitar@procaut.sk, May 27, 2002 6:07
Consider using :bwipeout instead of :bd
see :help bd
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #251 - c/c++: align #endif with corresponding #if/#ifdef : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Kartik, October 24, 2002 23:34
This tip is currently at -1/1 - I'm not sure why, since
I use it a lot. In any case, here's an updated version
that handles nested #if blocks.
inoremap #en #endif<Esc>bbd0%y0<C-o>0PA
I've stopped positioning the cursor on the next line
because I found myself doing <Esc>dd too often.
In a perfect world, we wouldn't have to deal with code
with such a high density of preprocessor directives as
to make indenting them, and therefore this tip, useful.
Add Note
Tip #251 - c/c++: align #endif with corresponding #if/#ifdef : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<c/c++: align #endif with corresponding #if/#ifdef | The power of | (v75|r- actually...) >>
Additional Notes
jmcpherson@softhome.net, May 28, 2002 12:56
This is a neat idea (and I do like Python), but why not
use vimscript #176? It has more features and is native
vim so you don't have the overhead of the Python
interpreter.
demian 0311 at yah00 d0t c0m, June 2, 2002 13:46
script?
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
" * <cursor>
" * ------------------------------------------------------------------- */
elseif wrd == "/*"
exe "norm! a -[AuthorId:\<CR>=strftime('%j/%y@%H:%M')\<CR>]\<esc>$lv75|r$a\<cr>\<cr>\<esc>2lv72|r-$a */\<esc>k$a "
Have to love VIM!
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<python script to align statements | Using \%[] to easily match parts of a word. >>
Additional Notes
Anonymous, May 26, 2002 17:03
Very nice feature.
Additional question:
How can I move the "bar" in
foo bar
to column 30?
O.K., I can think of several ways to do that, but I'd
like to do that without thinking about how many spaces
or shiftwidths I might need. I'd love to know a command
"move everything after the cursor to column [count]".
RobertKellyIV <feral@firetop.com>, May 26, 2002 20:18
That is also quite easy to do as it turns out. "move
everything after the cursor to column [count]". equates
to:
d$30|p
*breakdown*
d$ to del to end of line (into unnamed register)
30| to place cursor on column 30
p to paste unnamed register.
I.e.
http://www.vim.org/tips/tip.php?tip_id=253 (2 of 5) [18/02/2004 14:50:50]
Before:
int foo = bar;
<place cursor where desired (on b of bar)>
d$30|p
Becomes:
int foo =
bar;
VIM is neat :)
Anonymous, May 26, 2002 21:33
This tip made no sense to me until I ":set
virtualedit=all", so if it's not working for you, try
that.
Anonymous, May 27, 2002 1:02
Thanks Robert, it works great.
Anonymous, May 27, 2002 2:37
for some reason | wont go beyond the newline character
and is completely meaningless on an empty line.
so I just do "75i-<esc>"
RobertKellyIV <feral@firetop.com>, May 27, 2002 10:47
That should be because (as Anonymous, May 26, 2002
21:33) mentioned,
:set virtualedit=all
Is needed (opoligies for forgetting to mention that..)
The `problem` with just 75i-<esc> is that it will inset
75 chars(or strings as case may be) regardless of what
column you are in. So, to trim the line at column 75
you would need to add 75|D (goto column 75 and delete
to end of line).
There is an advantage to doing things that way however,
one it works regardless of how you have virtualedit set
(I have a hard time fathoming it being anything but all
personally ;) ) but you can also specify a string to
repeate, thus "=-=-=-=-=-=-=-=-=-=-=-" or some such is
possible (75i=-<esc>75|D)
The same idea holds true for positioning the rest of a
line at a specific column:
//place cursor on start of word you want at column
30i <esc>30|dw
http://www.vim.org/tips/tip.php?tip_id=253 (3 of 5) [18/02/2004 14:50:50]
typeinfo
0weldw20i <esc>20|dw
on each line will result in:
varname
varname
varname
typeinfo
typeinfo
typeinfo
*breakdown*
0 = start of line, column 0
wel = place cursor one char past first word (var name)
dw = delete spaces to next word (type definition)
20i <esc> = instert 20 spaces.
20|dw = goto column 20 and delete the spaces from here
to next word (type definition)
RobertKellyIV <feral@firetop.com>, May 30, 2002 2:40
typeinfo
typeinfo
typeinfo
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #254 - Using \%[] to easily match parts of a word. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
Site Help
Tip #254 - Using \%[] to easily match parts of a word. : vim online
" vs
elseif wrd == "re" || wrd == "ret" || wrd == "retu" || wrd
== "retur"
exe "norm! bdWireturn\<Esc>"
Just another one of those VIM things that made me smile :)
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<The power of | (v75|r- actually...) | arbitrary tags for file names >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Using \%[] to easily match parts of a word. | Opening current Vim file in your Windows browser >>
Additional Notes
Mark Hillebrand, June 4, 2002 23:10
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #256 - Opening current Vim file in your Windows browser : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
Hi Vimmers
open current file in browser
map ,f
:update<CR>:silent !start
c:\progra~1\intern~1\iexplore.exe file://%:p<CR>
open http link under cursor in your browser
Site Help
map ,i
:update<CR>: !start
c:\progra~1\intern~1\iexplore.exe <cWORD><CR>
Note use of cWORD (not cword) meaning OUTER Word
Works for me in XP & 98
(Original came from a posting by Ralf Arens)
zzapper
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Anonymous, June 6, 2002 13:42
If your windows browser is set up correctly, you will
probably be able to get away with these instead.
map ,f
map ,i
Tip #256 - Opening current Vim file in your Windows browser : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<Opening current Vim file in your Windows browser | how long is the current word? >>
Additional Notes
Anonymous, June 14, 2002 9:41
Pressing any number 'n' followed by any command will
repeat the command 'n' times. This is pretty clearly
covered in the tutorial . . .
marius@ee.utt.ro, June 17, 2002 9:22
i read it after i wrote the tip :)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
complexity: intermediate
as of Vim: 6.0
this can be
Scripts
Tips
My Account
wordlen ='
Site Help
and it will tell you the word under the cursor, and how
long it is.
and for things that arent words, this addition to your
.vimrc works on sections of a line that have been
hightligted in visual mode
vmap <C-_> "-y:echo 'word' @- '
)<CR>
Life Changing
Helpful
Unfulfilling
<<fast page up/down. | removing the toolbar (icons) from gvim >>
Additional Notes
SBrueggemann@gmx.net, June 11, 2002 1:51
rate
colin
Anonymous, June 11, 2002 4:23
trying this, i have just remembered why i never
discovered this. running vim 6 in a terminal emulator,
showcmd slows down screen redraws considerably. so
normally i have ruler, status bar, etc all turned off,
to increase scrolling and redraw speed.
Colin
jc_cann@yahoo.com, April 21, 2003 6:26
I tried this nmap command in vim 5.3 and it
works. Thanks for the tip, it's been useful for me.
Jeff
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #259 - removing the toolbar (icons) from gvim : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Tip #259 - removing the toolbar (icons) from gvim : vim online
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
salmanhalim@hotmail.com, June 12, 2002 19:13
So how about just doing the following:
:set guioptions-=T
This causes the toolbar to not show.
have it.)
(This is how I
Tip #259 - removing the toolbar (icons) from gvim : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<removing the toolbar (icons) from gvim | Close windows from Gvim poup menu >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #261 - Close windows from Gvim poup menu : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
<<Close windows from Gvim poup menu | color active line >>
Additional Notes
Anonymous, June 14, 2002 2:02
Not available for Windows.
Anonymous, June 26, 2002 18:28
http://www.vim.org/tips/tip.php?tip_id=262 (1 of 2) [18/02/2004 14:51:10]
Unfulfilling
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
This tip shows how to color the active line, the line in
which the cursor is, for better reading.
You should try possibility 2 before 1, IMHO it is mostly
usable.
possibility 1:
:au! CursorHold * let @/ = '\%' . line('.') . 'l.*'
:set ut=500
explanation:
After 500 ms of waiting for you to hit a key, vim
sets the search register to a pattern that matches the
current line.
problem:
Register / holds the search pattern, so you cannot
have color the active line and search.
Therefore another solution:
possibility 2:
:highlight CurrentLine guibg=darkgrey
guifg=white
(or whatever colors you want)
:au! Cursorhold * exe 'match CurrentLine /\%' .
line('.') . 'l.*/'
:set ut=100
explanation:
This solution uses 'match' to highlight a string,
it does not interface with the current search pattern.
addition:
Turning the highlighning off:
:au! Cursorhold
:match none
The order of these commands are important. If
:match none is executed first, the autocommand would
almost immediately execute another match command.
references
:help
:help
:help
:help
:help
to vim help:
Cursorhold
'ut'
/\%l
"/
\%
Life Changing
Helpful
Unfulfilling
rate
<<Bored of ur arrow shapped mouseptr? | F5 Compile and Run, F8 Compile (ala Visual Studio) >>
Additional Notes
digitect (at) mindspring com, June 18, 2002 7:38
It should be noted that the CursorHold event is not
updated within insert mode. :(
richardsugg@yahoo.com, June 19, 2002 5:10
now this is cool. I really appreciated this tip. Can
anyone tell me how to make this work in insert mode as
well? Then I'll be giddy with the joy that only vim
can give me.
jonestor1976@yahoo.com, June 21, 2002 10:05
I wrote a script to do this that will work in insert
mode. By the way, it has problems if there is a
delimiter on the line that you are trying to highlight.
Press F2 to highlight a line.
Press F3 to unhighlight the line
The current version is below.
"
"
"
"
"
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #264 - F5 Compile and Run, F8 Compile (ala Visual Studio) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Tip #264 - F5 Compile and Run, F8 Compile (ala Visual Studio) : vim online
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
matt@mh.dropbear.id.au, June 23, 2002 23:33
You might like to take a look at vim's quickfix mode.
:help quickfix
Also, on unix systems one setup I used for a while (and
still have, though I'm more often than not using gvim
now) involves running vim from within screen, then you
simply have to double-tap ctrl-a to get a shell window.
$ xterm -name VIM -geometry 132x60 -e screen vim
I especially like this method for editing HTML/XML/TeX
etc where the post-edit operation isn't a compile, but
something like moving files around, rsync, or whatever.
mathew_spamcan@yahoo.com.au, January 28, 2003 1:48
You can also use the :make command.
ou can set the variable makeprg variable if required,
eg I use
set makeprg=gmake\ -j
Parallel build with gnu make.
:make will accept the target name as an option.
The limits are that it does not do a save. I would
MUCH prefer
is ran make in the background somehow too.
libberspam@atlaswebmail.com, February 8, 2003 11:12
hi, under unix this is what i got to compile and run my
program. i would imagine make would be a much better
solution for big projects but for small single file
projects this works great
Tip #264 - F5 Compile and Run, F8 Compile (ala Visual Studio) : vim online
endfunc
olbyun@hotmail.com, March 20, 2003 3:27
You might want to compile your file when you're in
insert mode.
lmap makes your mapping available in every situation in
vi.
For detailed information, please refer to
:help map.txt
olbyun@hotmail.com, March 20, 2003 3:32
Some reason lmap doesn't work as expected in my
vim/xf86/cygwin/w2k
map! should work.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<F5 Compile and Run, F8 Compile (ala Visual Studio) | use -S command line switch >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Hi Vimmers,
abbreviations have always been one of the most useful parts
of vi(m), trouble is when you've got too many you forgot
what you called them.
You can of course list the whole lot with
:ab<cr>
But did you know that you can type the first few letters of
your abbreviations and get a list of just thos abs eg
:ab php<cr>
gives me all my php abs
&
:ab perl<cr>
gives me all my perls
also try control-D instrad of <cr>
zzapper
Life Changing
Helpful
Unfulfilling
rate
<<use -S command line switch | Get cursor position as byte percentage instead of line percentage >>
Additional Notes
david@tvis.co.uk, June 28, 2002 4:45
:%s#<script\_.*/script>#<script>^M</script>#g
,v
:e $VIM/_vimrc
,s
:source $VIM/_vimrc
,r
:redir! > c:/aaa/xxx
,i
:update<CR>: !start
c:\progra~1\intern~1\iexplore.exe <cWORD><C
R>
,f
:update<CR>:silent !start
c:\progra~1\intern~1\iexplore.exe fil
e://%:p<CR>
,c
c/["'<;)]<CR>
v ,h
"zda<h1><C-R>z</h1> <Esc>2F>
Anonymous, July 20, 2002 11:32
You can use Tab- and Ctrl-D-completion on the vim
commandline for just about everything. Play around.
Commands, filenames, maps, abbreviations, buffernames and
whatnot. It's context sensitive, so it completes the right
thing at the right place. Extraordinarily useful and an
extreme speed boost.
-Regards,
A.P.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #268 - Get cursor position as byte percentage instead of line percentage : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<selectively displaying abbreviations | Syntax highlighting is "out of sync", seems to correct itself with
refresh ?? >>
Additional Notes
Tip #268 - Get cursor position as byte percentage instead of line percentage : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #269 - Syntax highlighting is "out of sync", seems to correct itself with refresh ?? : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
This one has come across the 'vim' users mailing list
many times, and probably
comp.editors as well...
Summary:
see :help :syn-sync
and search for 'sync' in your favorite syntax file in
$VIMRUNTIME/syntax
Long Version:
The syntax highlight code utilizes a certain
synchronization method to efficiently
figure out syntax highlighting, specifically if you
aren't at the very beginning or
end of a file. The specific setting is 'syntax
sync'. For various file types the
method is set by default in this is setup in the syntax
file and one can vary
the degree of trouble which VIM goes to to try and
figure this out. As an example
for C, from $VIMRUNTIME/syntax/c.vim:
if exists("c_minlines")
let b:c_minlines = c_minlines
else
if !exists("c_no_if0")
let b:c_minlines = 50 " #if 0 constructs can be long
else
let b:c_minlines = 15 " mostly for () constructs
endif
endif
exec "syn sync ccomment cComment minlines=" .
b:c_minlines
Where c_minlines is the minimum number of lines that VIM
goes backward
to try to find the start of a comment for syntax
Tip #269 - Syntax highlighting is "out of sync", seems to correct itself with refresh ?? : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Get cursor position as byte percentage instead of line percentage | Insert a single character >>
Additional Notes
Robert (MetaCosm), April 14, 2003 8:51
If you are not worried about the speed tradeoff -- and
you just want the problem solved (and a brief
explanation of why you syntax highlighting was broken
in the first place) -- check out:
http://www.vim.org/tips/tip.php?tip_id=454
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Syntax highlighting is "out of sync", seems to correct itself with refresh ?? | easy (un)commenting
out of source code >>
Additional Notes
manfred.strubegger@irm.at, July 23, 2002 2:59
Very good tip, but I prefer <C-I> as a {lhs}. It is
unused and fits better to the insert logic of VIM,
although it saves less key strokes.
reiss_david AT yahoo DOT com, July 29, 2002 10:30
I use
:map gt i$<esc>r
:map gb a$<esc>r
These macros were derived from one I found in a Vi FAQ.
Anonymous, May 20, 2003 10:44
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
,(
,<
,d
Standard ML
html
clears any of the wrapping comments
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Anonymous, July 1, 2002 6:28
After executing this tip, the content of "/ is highlighted
in my gvim; which is rather annoying.
In e.g. MapBasic which I'm trying to figure out right now,
I use:
map ,' :s/^/'/<CR> :let @/=""<CR>
Leo
alinets<at>yahoo.com, July 1, 2002 13:26
I am having the same problem,
I have hlsearch option on (highlight search) and when I use
one of the mappings to add comment it leaves me with a lot
of hihjlighting that is not required/intended. Is there a
way to turn off highlight search for these command only ?
alinets<at>yahoo.com, July 1, 2002 14:40
OK, figured it out.
Just add :nohlsearch <CR> at the end of the mapping and it
would remove the highlight.
Highlighting would be reenabled when you do the next
search. I checked it out it works
" lhs comments
map ,# :s/^/#/<CR> <Esc>:nohlsearch <CR>
map ,/ :s/^/\/\//<CR> <Esc>:nohlsearch <CR>
map ,> :s/^/> /<CR> <Esc>:nohlsearch<CR>
map ," :s/^/\"/<CR> <Esc>:nohlsearch<CR>
map ,% :s/^/%/<CR> <Esc>:nohlsearch<CR>
map ,! :s/^/!/<CR> <Esc>:nohlsearch<CR>
map ,; :s/^/;/<CR> <Esc>:nohlsearch<CR>
map ,- :s/^/--/<CR> <Esc>:nohlsearch<CR>
map ,c :s/^\/\/\\|^--\\|^> \\|^[#"%!;]//<CR>
<Esc>:nohlsearch<CR>
" wrapping comments
map ,* :s/^\(.*\)$/\/\* \1 \*\//<CR> <Esc>:nohlsearch<CR>
map ,( :s/^\(.*\)$/\(\* \1 \*\)/<CR><Esc>:nohlsearch <CR>
map ,< :s/^\(.*\)$/<!-- \1 -->/<CR> <Esc>:nohlsearch<CR>
hi all!!
those are great, but i don't like the highlighted search
and also i like my // allways at the very begining of the
line, so i've wrote this function (very newbie and
unoptimized, but it works XD )
it comments and uncomments the current line:
"""""""""""""""""""""""""""""""""""""""""""""""""
function! MyComm()
let linenum= line('.')
let line = getline('.')
let commpos= match(line, "//")
let n = 0
while n< commpos
if line[n]!= " " && line[n]!= "\t"
break
endif
let n= n+1
endwhile
if n== commpos && commpos!= -1
let line= strpart(line, 0, commpos).strpart(line,
commpos+2)
else
let line= "//".line
endif
let err= setline(linenum, line)
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"and use this keybindings:
map <M-c> :call MyComm()<CR>
imap <M-c> <esc>:call MyComm()<CR>i
" for the /* */ pair, i use visual mode, an then alt-v:
vmap <M-v> v`<I<CR><esc>k0i/*<ESC>`>I<CR><esc>k0i*/<ESC>
hope u find useful :)
stonnedsnake@yahoo.com, October 25, 2002 3:04
Using visual block selection at the start of the lines you
want to comment, along with 'I' (CAPS-EYE), and the
comment character is also very handy. Decommenting would be
(ofcourse!) to select the comments in a visual
block and delete them.
mits_rox@hotmail.com, February 8, 2003 13:37
the '--' comments are also for ADA95 if anyone has has the
pleasure of coding in it.
call
call
call
call
call
PoundComment()
PoundComment()
PoundComment()
PoundComment()
SlashComment()
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Happy VIMing
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<easy (un)commenting out of source code | Fast fixing of email quotations (too long lines) >>
Additional Notes
Feral of firetop.com, October 19, 2002 6:23
See also ]p
Help says, "Like "p", but adjust the indent to the
current line."
Also note [p
{not in Vi}, but then neither is `]
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #273 - Fast fixing of email quotations (too long lines) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
<<automaticaly formating pasted text (p=`]) | Some useful mappings for TeX >>
Additional Notes
Anonymous, July 20, 2002 11:39
rate
Tip #273 - Fast fixing of email quotations (too long lines) : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
inoremap
inoremap
inoremap
inoremap
inoremap
<buffer>
<buffer>
<buffer>
<buffer>
<buffer>
[ [] i
^ ^{} i
_ _{} i
\( \(\) hi
\[ \[\] hi
Life Changing
Helpful
Unfulfilling
rate
<<Fast fixing of email quotations (too long lines) | Some useful mappings for TeX >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
inoremap
inoremap
inoremap
inoremap
inoremap
<buffer>
<buffer>
<buffer>
<buffer>
<buffer>
[ [] i
^ ^{} i
_ _{} i
\( \(\) hi
\[ \[\] hi
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Georgi Slavchev goyko@gbg.bg, July 8, 2002 21:22
I want to correct myself.
For i_<C-L> mapping, there would be more than just one
option, i.e. env:op1:op2,op3.op4
\begin[op1,op2,op3,op4]{env}
\end{env}
For CleverSpace, the cursor position is __after__ and
not before, as I said.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
realblades@yahoo.com, August 16, 2002 3:39
If it's installed neatly and has a manual page, you can
search it by hitting K while on the word (function,
command, filename... anything with a manpage).
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Have you ever tried to call a function which parameters you have
forgotten?
Especially those long named and with long parameter list GTK+ functions
like gtk_menu_item_image_from_stock_new(..........) !!!
By accident I saw a function in Vim help. It's name was PreviewWord and
it allowed
one to jump in the preview window to the tag for the word cursor is on.
I _slightly_ modified this function not to need tags file, but to search
included files instead.
I wrote another function, which uses the above said one, which triggers
PreviewWord
when you open the parenthesis after a function name.
Here it is:
" Note:
" This is literally stolen from Vim help. The only changes are:
" (1) if w != ""
becomes
if w =~ "\k"
" (2) exe "silent! ptag " . w becomes
exe "silent! psearch " . w
" * The first change prevents PreviewWord of searching while cursor is on
some
"
non-keyword characters, e.g. braces, asterisks, etc.
function! PreviewWord()
if &previewwindow " don't do this in the preview window
return
endif
let w = expand("<cword>") " get the word under cursor
if w =~ "\k" " if there is one ":ptag" to it
" Delete any existing highlight before showing another tag
silent! wincmd P " jump to preview window
if &previewwindow " if we really get there...
match none " delete existing highlight
wincmd p " back to old window
endif
" Try displaying a matching tag for the word under the cursor
let v:errmsg = ""
exe "silent! psearch " . w
if v:errmsg =~ "tag not found"
return
endif
silent! wincmd P " jump to preview window
if &previewwindow " if we really get there...
if has("folding")
silent! .foldopen " don't want a closed fold
endif
call search("$", "b") " to end of previous line
let w = substitute(w, '\', '\\\', "")
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
goyko@gbg.bg, September 19, 2002 0:21
There is an error in PreviewWord function. You have to replace line 12
with this:
if w =~ "\i" " if there is one ":psearch" to it
You may also have to convert the fileformat from "dos" to "unix" if you
have downloaded the source under a windoze browser:
:set fileformat=unix
If you want to search in certain dirs, you have to specify them in the
.vim file, like this:
setlocal path+=/usr/include/gtk-1.2/**
setlocal path+=/usr/include/gnome-1.0/**
Thanks to Balaji V T for the bug-report.
kcwu@kcwu.homeip.net, December 26, 2002 4:46
" Note:
" When you open a parenthesis after a function name, and at the
" line end, that function's definition is previewed through
PreviewWord().
" This is inspired from Delphi's CodeInsight technology.
" Something similar (PreviewClassMembers) could be written for
" the C++ users, for previewing the class members when you type
" a dot after an object name.
" If somebody decides to write it, please, mail it to me.
function! PreviewFunctionSignature()
let CharOnCursor = strpart( getline('.'), col('.')-2, 1)
if col(".") == col("$")-1
normal h
call PreviewWord()
normal l
endif
endfunction
function Register(...)
let index=1
while index <= a:0
execute 'let ext=a:'.index
execute 'au! CursorHold '.ext.' nested call PreviewWord()'
execute 'au BufNewFile,BufRead '.ext.' nested inoremap <buffer> (
<Esc>:call PreviewFunctionSignature()<CR>a('
let index=index+1
endwhile
endf
call Register('*.[ch]', '*.cc', '*.cpp')
call Register('*.[ch]0','*.cc0','*.cpp0')
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
to it by '[a-z,A-Z0-9]
n
N
*
#
g*
g#
Life Changing
Helpful
Unfulfilling
rate
<<Function signature previewer | On Windows, make GVim the default action for double-click with
"unknown file types" >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #279 - On Windows, make GVim the default action for double-click with "unknown file types" : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #279: On Windows, make GVim the default action for doubleclick with "unknown file types"
tip karma
complexity: intermediate
as of Vim: 5.7
Tip #279 - On Windows, make GVim the default action for double-click with "unknown file types" : vim online
------ vimalways.reg
-REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\Open with
&GVim]
@="Open with &GVim"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\*\shell\Open with
&GVim\command]
@="\"C:\\vim\\vim61\\gvim.exe\" \"%1\""
----end of file---- cut here----- snip---snip---Note 1. This can't be de-installed automatically, and
if you want to remove it, you'll have to edit the
registry by hand (annoying, but easy).
Note 2. Keep this file around, so when you upgrade your
GVim, all you have to do is modify the pathname (to say,
for example, vim62) and then install it again.
Life Changing
Helpful
Unfulfilling
<<all the right moves | Integration with PyUnit testing framework >>
Additional Notes
jcline at ieee.org, November 27, 2002 2:08
rate
Tip #279 - On Windows, make GVim the default action for double-click with "unknown file types" : vim online
Compatibility note:
MS Windows
MS Windows
MS Windows
please add
95 - works OK
98 - works OK
NT - not sure; if anyone can confirm this
a note.
MS Windows 2000 - inserts registry entry OK (rightclick the vim.reg file and select "Merge"), but doubleclick on an unknown-type file does not open file in
GVim, so the tip does not work as above. If anyone has
corrections for Windows 2000 please add a note.
MS Windows XP - have not tested. If anyone has tested
this and/or has it working please add a note.
Tip #279 - On Windows, make GVim the default action for double-click with "unknown file types" : vim online
[HKEY_CLASSES_ROOT\Unknown\shell]
@="vim"
[HKEY_CLASSES_ROOT\Unknown\shell\vim]
[HKEY_CLASSES_ROOT\Unknown\shell\vim\command]
@="\"C:\\Vim\\vim61\\gvim.exe\" \"%1\""
----end of file---- cut here----- snip---snip---Note 1. This can't be de-installed automatically, and
if you want to remove it, you'll have to edit the
registry by hand (annoying, but easy).
Note 2. Keep this file around, so when you upgrade
your GVim, all you have to do is modify the pathname
(to say, for example, vim62) and then install it again.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
def suite():
alltests = unittest.TestSuite()
for module in map(__import__, modules_to_test):
alltests.addTest(unittest.findTestCases(module))
return alltests
if __name__ == '__main__':
unittest.main(defaultTest='suite')
============== end of the alltests.py file
========================
While talking about it, I'd also suggest to add a couple
of mappings.
In the end, my vim/files/ftplugin/python.vim looks like
this:
setlocal makeprg=./alltests.py\ -q
setlocal efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\
%l%.%#,%Z%[%^\ ]%\\@=%m
iabbr <buffer> sae self.assertEquals
iabbr <buffer> sar self.assertRaises
:help
Life Changing
Helpful
Unfulfilling
rate
<<On Windows, make GVim the default action for double-click with "unknown file types" | Stateful zz
>>
Additional Notes
Max Ischenko, May 8, 2003 6:10
pyunit compiler will be included in Vim 6.2 release.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Integration with PyUnit testing framework | Folding with Regular Expression >>
Additional Notes
feline, July 12, 2002 2:46
try
:help scrolloff
with this you can always have some context when
scrolling through files.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Additional Notes
hari_vim at yahoo.com, July 17, 2002 15:38
Unfulfilling
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<Folding with Regular Expression | Mapping to print syntax highlighted buffer in B&W >>
Additional Notes
benji@member.AMS.org, July 12, 2002 10:44
Note that this is only an issue for vim in a
Terminal window, not for the
GUI version, and that it will only work if support for
beos-ansi is compiled in.
For pre-compiled versions for Mac OS X, see
http://vim.sourceforge.net/download.php#mac
There are some further OS X FAQ's on my page,
http://homepage.mac.com/fisherbb/index.html
--Benji Fisher
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #284 - Mapping to print syntax highlighted buffer in B&W : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Turn on syntax coloring in Mac OS X | Don't use the escape key! >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
Vim (any vi really) is a dream for touch typists... Until you want to switch from insert
mode to normal mode. Then you've got to reach way up to whack the escape key.
Or at least that's what I was doing until I realized that (drum roll please)
Esc is exactly equivalent to control-[
the left square bracket key)
Site Help
That little bit of knowledge, plus mapping my caps lock to another control key, was what
turned my fascination with Vim into true love. You never have to lose track of the home
row again!
For Xfree86 users - you can make the capslock key another control key by adding
Option "XkbOptions" "ctrl:nocaps"
to the InputDevice section of your XF86Config file.
For Windows NT/2000 users
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Mapping to print syntax highlighted buffer in B&W | Recover after doing something... ugly. >>
Additional Notes
mark@summersault.com, July 24, 2002 12:25
I was also frustrated by location of ESC and CONTROL when using vim. My solution was to
buy two Happy Hacking keyboards:
http://www.pfuca.com/products/hhkb/hhkblite2.html
Not only does it have ESC and CONTROL where I want them, but it makes it easier to
switch between my Mac computer
at work and my FreeBSD box at home.
saiyaga1881@earthlink.net, July 25, 2002 12:01
I've used Ctrl-[ for a long time-- I guess at some point over the years it ceased being
obvious.
As for the ctrl/caps lock under NT, I use:
00 00 00 00 00 00 00 00 03 00 00 00 1d 00 3a 00 3a 00 1d 00 00 00 00 00
which swaps the caps lock and ctrl keys. Format is 2 dwords of 0, 1 dword length
(#mappings + 1), dword mappings (input scan code 16-bit, output scan code 16-bit),
final dword of 0. Can remap any keys this way, even the Esc and ~ key to make your
keyboard work like a happy hacking one.
Sanjay
Anonymous, July 25, 2002 14:01
What could I put in my XFree86 config file to turn Caps Lock into Ctrl-[ instead of
just making it a control modifier key?
In other words, I want CapsLock keystroke to generate "Ctrl-[" key symbol.
Thanks.
jf_____ /at/ fastmail (.) fm, July 26, 2002 1:17
hey neat! I must say that I hadnt realized that about Ctrl-]. Nice to see that somebody
was thinking along (well, sorta) the same lines as me. I was in fact just a few minutes
ago working for an alternative solution to the problematic "<esc>" key, when something
struck me.
I've always had situations where I had to "make a quick insert" - go into insert mode,
insert a quick word, then come out into normal mode, and navigate elsewhere. To make a
long story short, this is the solution that I came up with :map! <S-space> <esc>
or even
:map! <S-space><S-space> <esc>
if you find the first mapping getting in the may of your typing
With this quick combo ("Shift", + <space>), one can easily (and might I add,
intuitively) go into and come out of insert mode. I guess I always thought the <space>
would be a good way to do this sort of thing, since it is after all, so intuitive in
the typing process. So why not make it such that it can "escape" you out into normal
mode as well? Just type 'i', to go into insert mode, type in your stuff, and once
you're done, hit Shift-space!
(note: I havent automated 'i' into the whole process yet, but does anybody think that
it would be possible? I would certainly like to hear about it if you do work out
something)
dubu AT gmx.net, July 26, 2002 17:35
I changed my CapsLock key to Escape under XFree86 with the following lines in my
~/.Xmodmap:
! Esc on caps lock :-))
remove Lock = Caps_Lock
keysym Caps_Lock = Escape
In my ~/.xinitrc, xmodmap is called to set the mapping:
if [ -f ~/.Xmodmap ]; then
xmodmap ~/.Xmodmap
fi
Finally, my typing speed in vim is the same as with the original HP 9000 ITF HIL
keyboards, which MUST have been designed by vi hackers (Esc key on the outer left,
next to the shift key). :-)
http://www.vim.org/tips/tip.php?tip_id=285 (3 of 9) [18/02/2004 14:52:08]
Since on the french canadian keyboard the key combination CRTR-[ is perform with
CTRL+AltCar+"the cedilla key" it's not very convinient.
But the TIP of using CTRL-C key combination work well on any keyboard mapping. It
doesn't required you to modify any keymap, so it will work on any vanilla installation.
From my point of view (switching from PC with English_US and Frech_CA keyboard layout)
using CTRL-C instead of the hard to reach ESC key is the real TIP here.
Anonymous, January 14, 2003 22:22
I cannot get 'map! <S-space> <esc>' to work for me. I am running Vim throught a
terminal client(putty), would this effect this mapping to not work.
I would like to
use Shift-Space as ESC, any suggestions?
erik@arbat.com, January 22, 2003 3:24
If you just want the caps lock key to be a second escape key then see my comment on
http://www.vim.org/tip_view.php?tip_id=166
Goggs, February 21, 2003 20:58
Is there any way to remap Shift+CapsLock to ESC (or S+CL to plain CL)? I use the caps
key every now and then (not much I admit)
jallen@cashsystemsinc.com, April 30, 2003 9:59
I have tried mapping "qq" and "jf" to <Esc> but I'm going to try to shift-space.
Incidentally, I mapped the space bar to i. So I will press <Space> to get into insert
mode and <S-space> to get out.
Piet Delport <pjd@303.za.net>, May 4, 2003 12:15
The above-mentioned "Scancode Map" registry key for Win2K/XP is documented here:
http://www.microsoft.com/hwdev/tech/input/w2kscan-map.asp
You can find a full listing of keyboard scancodes here:
http://panda.cs.ndsu.nodak.edu/~achapwes/PICmicro/keyboard/scancodes1.html
Quick list of pertinent scancodes:
0x01
0x1D
0x38
0x3A
Esc
Ctrl
Alt
Caps Lock
I'm a touch typist myself and one of the reasons I use Vim is BECAUSE of the Esc.
key! I can't stand all that <Meta>, <Alt>, <Ctrl>, <whatever> nonsense in, for
example, Emacs -- the Esc. key is incredibly easy to locate (just keep going until your
finger can't find any more keys...) and much faster to use. As for losing the home
row, well you know those little bumps on the 'F' and 'J' keys?.....
Anonymous, May 12, 2003 15:48
:map <S-space> i
:imap <S-space> <esc>
From command mode <S-space> takes you to insert mode, from insert mode <S-space> takes
you to command mode.
Anonymous, May 19, 2003 7:57
I am trying to get the <S-space> thing happening in Mac OS X 10.2+ with no luck.
I was able to assign a normal char (e.g. 'a') to the <esc> key as an experiment but not
the <S-space>
Does anyone have any ideas?
David
jvc@nwcs.com, June 5, 2003 7:57
You can also remap the Caps Lock key to Control in Win9x using Microsoft's Windows 95
Kernel Toys (find them at
http://www.microsoft.com/windows95/downloads/contents/WUToys/W95KernelToy/Default.asp);
one of them ("keyboard remap") will let you do this. Despite their saying they're Win95
only, I've used this utility under Win98 and Win98SE without problems.
Anonymous, June 18, 2003 22:00
"I cannot get 'map! <S-space> <esc>' to work for me. I am running Vim throught a
terminal client(putty)"
Since you are in INSERT mode when you want to press escape...it should be:
imap <S-space> <esc>
gcruscoe@yahoo.com, June 24, 2003 9:23
Can anybody help me remap the Ctrl-Space key? I have an autocomplete function (for
tab) and I want to make it use Ctrl-Space instead. I cannot get any mapping for the
space key to work (including all of the examples above). What would keep vim from
mapping the space key?
Zitty, July 1, 2003 18:37
On Mac OS X:
I, too, am having problems getting the imap <S-space> <esc> scheme to work. I've
noticed some really funky stuff. First, it doesn't work at all using App Terminal
version of vim, nor does it work using the GUI version for Jaguar either. Where the
story gets strange is that it DOES work using the X-Windows version of gvim (via Apple
X11) but not the xterm version.
To sum up, it ONLY works on gvim via Apple's X11.
Hopefully someone can help us figure out what's going on here.
andreis@stud.cs.uit.no, July 11, 2003 10:05
Well, "map! <S-space> <esc>" doesn't work for me either on xterm, eterm or whatever.
For
those with a 'normal' pc keyboard, you probably have the 'windows' key on the bottom
row. Just
use it. Type the following on the commandline or put it in your .bash_profile or
.xinitrc :
"xmodmap -e "keysym Super_L = Escape"
Zitty, July 13, 2003 0:41
Okay a solution. Get the shareware utility "Keyboard Maestro". It allows you to remap
keystrokes for all sorts of tasks. You can add a general remap for the Esc key to what
ever you like, S-Space, or Ctrl-space, etc. Not exactly elegant via vim, but it works.
ulatif@hotmail.com, August 7, 2003 21:59
Try:
map! <S-Enter> <Esc>
instead of <S-Space>
works a lot better and won't get pressed accidentally.
Anonymous, August 14, 2003 16:13
If you're having trouble getting <C-space> to map in vim, it may be that <C-space> is
being mapped to another keystoke. My keyboard was using <Nul> for <C-space>. So, you
could put in your vimrc:
" Map <C-space> to <Esc>.
map <Nul> <Esc>
To get the <> value for a particular keystroke, try pressing CTRL-K before the
keystroke, while in insert mode.
laskava@yahoo.com, September 19, 2003 11:04
imap <Nul> <C-p>
This is really works.
But what is <Nul>? Is it keyboard or X11 defines it?
evan.clark@psl.nmsu.ed, October 3, 2003 10:04
For Win2k and WinXP users, KeyTweak is probably your best bet, since it automates the
registry access. I just downloaded it to swap my escape and capslock keys and it works
great.
http://webpages.charter.net/krumsick/
mtwebb at cs.princeton.edu, October 15, 2003 21:44
more on the os X front:
no dice with shift space, but the enter key adjacent to the right apple key also seems
to serve as an esc key.
Any ideas why this is?
using 10.2.8 and gvim
Anonymous, December 19, 2003 3:07
And for those of us who prefer the console...
Alt-[key] is usually actually sent as <Esc>[key], and generally if you're coming out of
insert mode it's because you want to execute a normal mode command, so...
Instead of <Esc>: to start an Ex command from insert mode, just press Alt-:. Sim. for
everything else.
Anonymous, February 7, 2004 10:39
It's a good idea to use <ctrl-c> to get back to normal mode. these shift-space-things
aren't easier to use and are user defined.. so if you use another vim installation, you
have to define these two mappings first. so why not using <ctrl-c> instead? however,
the only difference between <ctrl-c> and ESC is that incomplete abbreviations won't be
expanded.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Don't use the escape key! | Cool trick to change numbers >>
Additional Notes
nitya, July 25, 2002 9:55
This command works only if you have swap file. But in
case you don't have swap file, u'll not be able to
recover ur file
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Recover after doing something... ugly. | A keymapping to generate Java setters and getters
automatically >>
Additional Notes
Robbie S., July 25, 2002 12:36
You can also press Ctrl+A in normal mode to increment
numbers!
Anonymous, July 26, 2002 4:00
You don't even need to be on the number itself. Vim
search automaticaly for the next number before
incrementing / decrementing
salmanhalim@hotmail.com, July 26, 2002 7:30
It should be noted that the 'nrformats' option dictates
whether letters, octal and hexadecimal numbers are
recognized and modified accordingly.
me@me.com, August 4, 2002 10:46
this
nonone@none.com, October 30, 2003 15:10
great tip! how do find things like this in the help
file? I tried :help increment
jaldripublic at comcast.net, November 16, 2003 0:02
:helpgrep subtract
http://www.vim.org/tips/tip.php?tip_id=287 (1 of 2) [18/02/2004 14:52:13]
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #288 - A keymapping to generate Java setters and getters automatically : vim online
Home
Search
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: intermediate
as of Vim: 5.7
This mapping makes it much simpler to write new java classes by simplifying
some of the dull repetative coding (ie setters and getters).
To use, first write a basic class with the following format:
public class MyClass
{
Site Help
Tip #288 - A keymapping to generate Java setters and getters automatically : vim online
(the above should be one long line with no spaces between the end of the lines
above).
To use this to generate a class go to the variable that should have a
setter/getter and place the curser at the beginning of the 'private':
private <type> <variable> = <initvalue>'
^
Then type:
jgs
this will create the first getter/setter and then move up to the next
variable. You can just keep typing jgs until all the getters/setters have
been generated.
This should mapping isn't perfect and someone could probably make it a little
cleaner. It could also relatively easily be adapted to C++. Please feel free
to send me any feedback/enhancements as I am trying to compile a list of these.
Life Changing
Helpful
Unfulfilling
rate
<<Cool trick to change numbers | Alternative <escape> that allows you to do a "quick and dirty insert" and get out into normal mode >>
Additional Notes
sheerpub@yahoo.com, July 26, 2002 0:23
This is just an update on the above -- I had my original email removed for
SPAM reasons. If you want to email me regarding this tip please send to
sheerpub _at_ yahoo dot com.
Thanks,
Sheer
http://www.vim.org/tips/tip.php?tip_id=288 (2 of 3) [18/02/2004 14:52:15]
Tip #288 - A keymapping to generate Java setters and getters automatically : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #289 - Alternative <escape> that allows you to do a "quick and dirty insert" and get out into normal mode : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Tip #289 - Alternative <escape> that allows you to do a "quick and dirty insert" and get out into normal mode : vim online
can "escape" you out into normal mode as well? Just type
'i', to go into insert mode, type in your stuff, and
once you're done, hit Shift-space!
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<A keymapping to generate Java setters and getters automatically | Text Processing With Integrated
Spell Checking >>
Additional Notes
Anonymous, July 26, 2002 8:22
Also check out vimtip #270.
Anonymous, July 26, 2002 9:45
Ctrl+[ is a builtin equivalent to Esc in insert mode...
antoine.mechelynck@belgacom.net, July 26, 2002 12:07
Ctrl-[ is equivalent to <Esc> indeed; but if you use <SSpace>, beware of using the space bar as "independent
of shift" as on a typewriter!
jmcpherson@softhome.net, July 29, 2002 12:50
Not a bad idea... and more egronomic (although also
less universally available) than the ^[ idea in vimtip
#285.
Incidentally, are you the same Jeffery Lim that wrote
Impulse Tracker?
jf_____@fastmail.fm, July 29, 2002 23:32
erm, nope. Different. For one thing, the "Jeffery" is
spelt differently. Thanks for the compliments for the
tip though.
alex_nanou@yahoo.com, August 14, 2002 16:32
here is another one in relation to the subject: vimtip
#314
Thanks...
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #290 - Text Processing With Integrated Spell Checking : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Alternative <escape> that allows you to do a "quick and dirty insert" and get out into normal mode |
^P & auto filling of variables and text >>
Additional Notes
david@tvis.co.uk, July 27, 2002 4:21
Hi Y'All
I used above successfully
If you happen to use Aspell on a Unix "shell" eg MKS on
Win32 you may want
:set shellslash
Tip #290 - Text Processing With Integrated Spell Checking : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #291 - ^P & auto filling of variables and text : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: intermediate
as of Vim: 6.0
Do you know you can auto fill the variable and names as
you type your code ? This will help most of the
programmers, who always try hard to remember the
variable names and browse through all the files to find
out the variable name.
Use Ctrl+P and Ctrl+N to autofill the variables names
etc. Just practice, you will feel the ease of using vim
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<Text Processing With Integrated Spell Checking | vim + cscope + cygwin >>
Additional Notes
Anonymous, July 30, 2002 11:03
Also check out vimscript#182 and vimscript #73
Robert KellyIV (Feral at FireTop . com), July 30, 2002 11:04
Completion such as this is also why it is a good idea
to have descriptive variable names, so you can easily
tell if you have the completion you were after.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
I've found that vim + cscope + cygwin does not work. The
problem seems to be that in
sprintf(cmd, "exec %s -dl -f %s", prog,
csinfo[i].fname);
vim execs cscope with the "-dl" options, causing it to
fail. It is probably a cscope bug, but a simple
workaround is top build vim without thad "d":
sprintf(cmd, "exec %s -l -f %s", prog, csinfo[i].fname);
seems to work for me!
Life Changing
Helpful
Unfulfilling
rate
<<^P & auto filling of variables and text | remember where you had ended reading help >>
Additional Notes
vsampath@hotmail.com, October 4, 2002 9:59
This (keyword #292) doesn't seem to be true, at least
not anymore. I am using cscope 15.4 and vim 6.1. With a
few hacks, I was able to get cscope to work with vim
under cygwin for Windows 2000. I did not need to change
the sprintf line. The hacks included
1. Copying if_cscope.? to the src directory and the
if_cscope.pro to the src/proto directory. These files
do not come standard with the Windows source
distribution of vim. (I think it should - anybody in
charge of distribution listening?)
2. Edit if_cscope.c to make the following changes:
http://www.vim.org/tips/tip.php?tip_id=292 (1 of 2) [18/02/2004 14:52:25]
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #293 - remember where you had ended reading help : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
You could jump to the last place you had been while
reading Vim help files if you add this to your
.vimrc file:
au BufLeave * if &ft == "help" | mark H | endif
Then use 'H to go to the mark H.
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<vim + cscope + cygwin | Use Ctrl-S to save current or new files. >>
Additional Notes
salmanhalim@hotmail.com, July 30, 2002 11:56
Perhaps a modification to allow 'H to open another
window if a help window doesn't already exist might be
useful here. Basically, the problem I had with this
was that if i I hit 'H while editing a buffer, it
replaced the buffer with the help file (though it DID
take me to the right location, as you suggested it
would) instead of opening a new window.
Max Ischenko, July 30, 2002 23:17
What about
nmap <F1> <C-W>s'H
Add Note
Tip #293 - remember where you had ended reading help : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #294 - Use Ctrl-S to save current or new files. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<remember where you had ended reading help | Line/word/file/whatever completion >>
Additional Notes
salmanhalim@hotmail.com, July 30, 2002 20:14
Tip #294 - Use Ctrl-S to save current or new files. : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Use Ctrl-S to save current or new files. | Attach the currently open file to email >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #296 - Attach the currently open file to email : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Line/word/file/whatever completion | Start in insert mode without loosing your escape key >>
Additional Notes
Anonymous, August 3, 2002 20:26
Very nice tip. Thanks
Add Note
Tip #296 - Attach the currently open file to email : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #297 - Start in insert mode without loosing your escape key : vim online
Home
Search
Tip #297: Start in insert mode without loosing your escape key
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Attach the currently open file to email | Changing case with regular expressions >>
Additional Notes
syndicate@agitated.net, August 3, 2002 20:24
Its spelled 'lose' not 'loose'
Tip #297 - Start in insert mode without loosing your escape key : vim online
So I
Tip #297 - Start in insert mode without loosing your escape key : vim online
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
I stumbled across this factoid on a website about vi. I haven't been able to
locate it in the Vim documentation, but it works in Vim, and it's very handy.
There are times that you might like to go through a file and change the case
of characters that match some arbitrary criteria. If you understand regular
expressions well, you can actually do this fairly easily.
It's as simple as placing \U or \L in front of any backreferences in your
regular expressions. Vim will make the text in the backreference uppercase or
lowercase (respectively).
(A "backreference" is a part of a regular expression that refers to a
previous part of a regular expression. The most common backrefernces are &,
\1, \2, \3, ... , \9).
Some examples that demonstrate the power of this technique:
Lowercase the entire file :%s/.*/\L&/g
(& is a handy backreference that refers to the complete text of the match.)
Uppercase all words that are preceded by a < (i.e. opening HTML tag names):
:%s/<\(\w*\)/<\U\1/g
Please add a note if you know where this is in the documentation. I have done
Ctrl-D searches on upper, lower, \U, and \L with no luck.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Start in insert mode without loosing your escape key | Open file under cursor. >>
Additional Notes
salmanhalim@hotmail.com, August 5, 2002 12:42
:help sub-replace-special
Got there quite simply by starting with :help :s.
pagaltzis () gmx _ net, August 8, 2002 12:58
Note also the gu<motion> and gU<motion> commands.
F.ex, ggguG will lowercase the entire file.
(gg = go to top, gu = lowercase, G = go to EOF).
shawn@deleurme.com, November 26, 2002 15:30
By using the \0 general backref instead of the name ones (\1, \2 etc) you
can save some typing for on replace stanza of the regex.
This regex upper cases an explicit set of words to uppercase in a file.
:%s/\(select\)\|\(order)\|\(by\)\|\(from\)\|\(where\)/\U\0/g
Not rocket science, but otherwise you'd have to do this:
:%s/\(select\)\|\(order)\|\(by\)\|\(from\)\|\(where\)/\U\1\U\2\U\3\U\4\U\5/g
2003@karpfenteich.net, February 22, 2003 5:39
convert HTML-Tags to uppercase
:%s/<\/\=\(\w\+\)\>/\U&/g
or to lowercase
:%s/<\/\=\(\w\+\)\>/\L&/g
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Changing case with regular expressions | Making a tags file for IDL (Interactive Data Language) >>
Additional Notes
hps@softhome.net, August 6, 2002 4:47
Did you ever try gf? ;-)
salmanhalim@hotmail.com, August 6, 2002 5:53
Not to mention ctrl-w f (for another window).
littledragon@altern.org, August 6, 2002 7:33
Hrm... Never tried gf or C-w f before :)
Cool :)
tborgmann@hh-berlin.de, September 2, 2002 23:42
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #300 - Making a tags file for IDL (Interactive Data Language) : vim online
Home
Search
Tip #300: Making a tags file for IDL (Interactive Data Language)
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Shawn, August 7, 2002 10:37
JD Smith has updated his web page to make idltags a separate
download to make it available specifically for vi users. The
new link is at
http://idlwave.org/download/idltags
mperrin@astro.berkeley.edu, December 10, 2002 15:20
Tip #300 - Making a tags file for IDL (Interactive Data Language) : vim online
It's actually quite easy to add support for IDL into ctags.
With Exuberant CTags, all you
need is to put the following in your .ctags file:
--langdef=IDL
--langmap=IDL:.pro
--regex-IDL=/^pro[ \t]+([a-zA-Z0-9_:]+)/\1/p,procedure/i
--regex-IDL=/^function[ \t]+([a-zA-Z0-9_:]+)/\1/f,function/i
and that's enough to get IDL procedures and functions into
your tags files.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
You can write a little shell function that will let you
easily edit any file that is in the path, or which's
location can be retrieved with the whereis tool. This is
something similar to what I have in /etc/profile:
function vvim() { vim `whereis $1|cut -d: -f2` }
function ggvim() { gvim `whereis $1|cut -d: -f2` }
Then just type, for example, "vvim ls", and you'll start
vim with /bin/ls and /usr/share/man/ls.1.gz loaded :)
(it's not very useful to edit /bin/ls, but you get the
ideea ;)
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Making a tags file for IDL (Interactive Data Language) | Use gvim in kmail >>
Additional Notes
littledragon@altern.org, August 7, 2002 3:34
A more useful example: vvim profile
weisbier@aol.com, August 8, 2002 19:12
I liked the idea, great for editing scripts, but it
didn't work for the shells
I use. Here's how I got it to work for the 2 shells I
use:
For 'bash':
vvim () { command vim `whereis "$@" | cut -d: -f2` ; }
For 'tcsh' in .tcshrc:
alias vvim 'vim `whereis \!* | cut -d: -f2` '
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Edit files in path, or related. | Statusline Tab Level Function Ruler TVIM >>
Additional Notes
nlm@valtech.se, August 8, 2002 16:02
See also http://freehackers.org/kvim/ - integrating Vim
in KDE. It looks really nice! (I'm not sure of exactly
what is needed to get it running i KMail though - but
look at those nice screenshots..)
zoran@spacemail.com, August 9, 2002 6:51
This tip is basically true for every mua that allows
integration of external editors, e.g. mutt
Anonymous, October 7, 2002 16:46
Thank you, thank you, thank you! I've been trying to
get this working for months! It takes just one
switch. Amazing.
drini@br.crashed.net, January 3, 2003 16:03
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #303 - Statusline Tab Level Function Ruler TVIM : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Tip #303 - Statusline Tab Level Function Ruler TVIM : vim online
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
salmanhalim@hotmail.com, August 8, 2002 7:32
Looks like the tab level is basically set to ( col( '.'
) - 1 ) / 4. The 4 is probably the value of &ts
instead. Of course, this always returns a value even
if you're in the middle of a tab (not actually ON a
tabstop), so something like this:
let TabLevel = ( col( '.' ) - 1 ) / &ts
if ( ( TabLevel * &ts + 1 ) != col( '.' ) )
let TabLevel = '*'
endif
Works for all levels of tabs. . . The proof and
verification thereof is left to the reader as an
exercise(TM).
sputnik, May 20, 2003 14:14
Tip #303 - Statusline Tab Level Function Ruler TVIM : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Statusline Tab Level Function Ruler TVIM | Best of VIM Tips (VIM's best Features) >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #305 - Best of VIM Tips (VIM's best Features) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Tip #305 - Best of VIM Tips (VIM's best Features) : vim online
-----------------# Exploring
:Ex
: file explorer note
capital Ex
\be
: builtin buffer explorer
:ls
: list of buffers(eg
following)
:cd ..
: move to parent directory
----------------------------------------------------------------------------# Great
guu
: lowercase line
gUU
: uppercase line
gf
: open file name under
cursor (SUPER)
ga
: display hex,ascii value
of character under cursor
ggVGg?
: rot13 whole file
CTRL-A,CTRL-X
: increment,decerement
number under cursor
win32 users must remap
CNTRL-A
CTRL-R=5*5
: insert 25 into text
----------------------------------------------------------------------------# Makes all other tips superfluous
:h 42
:h holy-grail
:help!
----------------------------------------------------------------------------# Markers & moving about
'.
: jump to last modification line (SUPER)
`.
: jump to exact spot in last modification
line
<C-O>
: retrace your movements in file (old)
<C-I>
: retrace your movements in file (new)
:ju(mps)
:help jump-motions
:history
: list of all your commands
----------------------------------------------------------------------------# Abbreviations & maps
:map
<f7>
:'a,'bw! c:/aaa/x
:map
<f8>
:r c:/aaa/x
:map
<f9>
:w<CR>:!c:/php/php.exe %<CR>
:map
<f11> :.w! c:/aaa/xr<CR>
:map
<f12> :r c:/aaa/xr<CR>
:ab php
: list of abbreviations beginning php
:map ,
: list of maps beginning ,
# For use in Maps
http://www.vim.org/tips/tip.php?tip_id=305 (2 of 9) [18/02/2004 14:53:12]
Tip #305 - Best of VIM Tips (VIM's best Features) : vim online
<CR>
: carriage Return for maps
<ESC>
: Escape
<LEADER>
: normally \
<BAR>
: | pipe
----------------------------------------------------------------------------# List your Registers
:reg
: display contents of all registers
"1p....
: retrieve numeric buffers
----------------------------------------------------------------------------# Useful trick
"ayy@a
: execute "Vim command" in a text file
yy@"
: same thing using unnamed register
----------------------------------------------------------------------------# Get output from other commands
:r!ls.exe
: reads in output of ls
!!date
: same thing
:%!sort -u
: use an external program to filter
content
----------------------------------------------------------------------------# Multiple Files Management
:wn
: write file and move to next (SUPER)
:bd
: remove file from buffer list (SUPER)
:sav php.html
: Save current file as php.html and "move"
to php.html
:sp fred.txt
: open fred.txt into a split
:e!
: return to unmodified file
:w c:/aaa/%
: save file elsewhere
:e #
: edit alternative file
:e %
:rew
: rewwind to first file in ARGS
:bn
: next file
:bp
: next file
:brew
----------------------------------------------------------------------------# Recording (BEST TIP of ALL)
qq # record to q
your commands
q
@q to execute
@@ to Repeat
# editing a register/recording
"ap
<you can now see register contents, edit as required>
"add
@a
-----------------------------------------------------------http://www.vim.org/tips/tip.php?tip_id=305 (3 of 9) [18/02/2004 14:53:12]
Tip #305 - Best of VIM Tips (VIM's best Features) : vim online
Tip #305 - Best of VIM Tips (VIM's best Features) : vim online
:%s/\r//g
: Delete DOS returns ^M
:'a,'bg/fred/s/dick/joe/gc : VERY USEFUL
:s/\(.*\):\(.*\)/\2 : \1/ : reverse fields separated by :
:%s/^.\{-}pdf/new.pdf/ non greedy matching (ie to first
pdf)
:s/fred/<c-r>a/g substitute "fred" with contents of
register "a"
:%s/^\(.*\)\n\1/\1$/ delete duplicate lines
# non-greedy matching \{-}
:%s/^.\{-}pdf/new.pdf/
:help /\{-}
:s/fred/<c-r>a/g substitute "fred" with contents of
register "a"
# multiple commands
:%s/\f\+\.gif\>/\r&\r/g | v/\.gif$/d | %s/gif/jpg/
:%s/suck\|buck/loopy/gc : ORing
:s/__date__/\=strftime("%c")/ : insert datestring
----------------------------------------------------------------------------# global command
:g/^\s*$/d
:delete all blank lines
:g!/^dd/d
: delete lines not containing string
:v/^dd/d
: delete lines not containing string
:g/fred/,/joe/d : not line based
:v/./.,/./-1join : compress empty lines
:'a,'b g/^Error/ . w >> errors.txt
:g/cmap\|form/p : ORing
----------------------------------------------------------------------------# Paste register *
:redir @*
: redirect commands to paste
:redir END
"*yy
: yank to paste
"*p
: insert paste buffer
----------------------------------------------------------------------------# Formatting text
gq<CR>
gqap (a is motion p paragraph (visual mode))
----------------------------------------------------------------------------# Operate command over multiple files
:argdo %s/foo/bar/
:bufdo %s/foo/bar/
:windo %s/foo/bar/
----------------------------------------------------------------------------# Command line tricks
gvim -h
ls | gvim : edit a PIPE!!
# vg.ksh (shell script)
http://www.vim.org/tips/tip.php?tip_id=305 (5 of 9) [18/02/2004 14:53:12]
Tip #305 - Best of VIM Tips (VIM's best Features) : vim online
Life Changing
Helpful
Unfulfilling
rate
<<fold braces and javadoc | Open a web-browser with the URL in the current line >>
Additional Notes
y_ellzs@tsmc.com.tw, August 11, 2002 7:36
test
david@tvis.co.uk, August 14, 2002 13:35
Just a reminder that this is just my
selection,but there's plenty of other good tips
in the vim tip collection
# Vim traps
In regular expressions you must backslash + (match 1 or
more)
/fred\+/
: matches fred/freddy but not free
---------------------------------------# \v or very magic (usually) reduces backslashing
/codes\(\n\|\s\)*where : normal regexp
/\vcodes(\n|\s)*where
: very magic
---------------------------------------# pulling objects onto command/search line (SUPER)
CTRL-R CTRL-W Pull word under the cursor into a command
line or search
CTRL-R : pull small register
CTRL-R [0-9a-z]
: pull named registers
CTRL-R %
: pull file name (also #)
---------------------------------------# manipulating registers
map
<f11> "qyy:let @q=@q."zzz"
---------------------------------------# help
:h visual<C-D><tab>
: obtain list of all visual help
topics
: Then use tab to step thru them
---------------------------------------# where was an option set
:verbose set history
: reveals value of history and
where set
Tip #305 - Best of VIM Tips (VIM's best Features) : vim online
Tip #305 - Best of VIM Tips (VIM's best Features) : vim online
This is an extension to
# pulling objects onto command/search line
If you use
/CTRL-R CTRL-A
it brings the whole word under the cursor including any
special characters.
For Ex:
If you are in a HTML page and the cursor is under a
keyword <table>
/CTRL-R CTRL-A brings /<table>
/CTRL-R CTRL-W brings /table (depending on what the
letter under your cursor is ... table or < or >
-Kdr
zzapper@ntlworld.com, December 23, 2002 11:42
The Buffer Explorer scripts mentioned above (\be \bs)
rely on the 2nd most popular VIM script bufexplorer.vim
available at
http://www.vim.org/script.php?script_id=42
Nov-2002
updated 05-
- great functionality
Tip #305 - Best of VIM Tips (VIM's best Features) : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #306 - Open a web-browser with the URL in the current line : vim online
Home
Search
Tip #306: Open a web-browser with the URL in the current line
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: intermediate
as of Vim: 5.7
function! Browser ()
let line = getline (".")
let line = matchstr (line, "http[^ ]*")
exec "!netscape ".line
endfunction
map <Leader>w :call Browser ()<CR>
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<Best of VIM Tips (VIM's best Features) | annoying "Hit any key to close this window..." >>
Additional Notes
littledragon@altern.org, August 12, 2002 2:48
http[^ ]* could be replaced with \%(http\|www\.).\{-}\>
littledragon@altern.org, August 12, 2002 2:53
Hrm... The above wouldn't work. Better try:
\%(http://\|www\.\)[^ ,;\t]*
ksteen@users.sourceforge.net, August 12, 2002 11:19
I use a similar script when editing html files to view
changes made to the file.
if exists("loaded_mozilla")
finish
endif
let loaded_mozilla=1
"Setup commands to run mozilla.
":Mozilla - open current file in mozilla.
if !exists(':Mozilla')
command Mozilla :call s:StartMozilla()
http://www.vim.org/tips/tip.php?tip_id=306 (1 of 3) [18/02/2004 14:53:14]
Tip #306 - Open a web-browser with the URL in the current line : vim online
endif
function! s:StartMozilla()
" let s:myfile = getcwd() . "/" . bufname("%")
let s:myfile = expand("%:p")
let s:a = "mozilla -remote 'openurl(file://"; . s:myfile
. ")'"
let s:r =system(s:a)
"Mozilla is not running so start it."
if s:r =~"No running window found."
unlet s:a
let s:a = "mozilla " . s:myfile . "&"
let s:r =system(s:a)
endif
endfunction
Both Netscape and Mozilla accept the remote argument which
reloads an open browser with the supplied url.
David Fishburn, June 25, 2003 8:08
Here is a more generic way to execute a URL (windows only):
vnoremap <silent> <C-F5> :<C-U>let
old_reg=@"<cr>gvy:silent!!cmd /cstart <C-R><CR>"<CR><CR>:let @"=old_reg<cr>
If you visually highlight something, then hit CTRL-F5, it
will tell windows to start the default associated
application.
http://vim.sourceforge.net/tips/add_tip_note.php?tip_id=306
- On my machine this will launch Mozilla (since that is my
default browser).
dave.txt
- On my machine this will launch gvim, on default windows
machines this would launch notepad.exe.
Benyang Tang, January 22, 2004 20:42
This is my modification. It works for http:, ftp: and file:
===============
function! Browser ()
let line0 = getline (".")
let line = matchstr (line0, "http[^ ]*")
:if line==""
let line = matchstr (line0, "ftp[^ ]*")
:endif
:if line==""
let line = matchstr (line0, "file[^ ]*")
:endif
"
echo line
Tip #306 - Open a web-browser with the URL in the current line : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #307 - annoying "Hit any key to close this window..." : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Open a web-browser with the URL in the current line | Move through wrapped lines. >>
Additional Notes
Tip #307 - annoying "Hit any key to close this window..." : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
If you don't like the fact that when you press Up and
Down on a wrapped line, you get to the next phisical
line instead of the next line on the screen, you can do
something like this:
imap <silent> <Down> <C-o>gj
imap <silent> <Up> <C-o>gk
nmap <silent> <Down> gj
nmap <silent> <Up> gk
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<annoying "Hit any key to close this window..." | close vim you left open remotely >>
Additional Notes
Anonymous, March 9, 2003 16:55
just make sure that you don't do something odd like I
did and copy the spaces at the end of the code :S.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #309 - close vim you left open remotely : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Tip #309 - close vim you left open remotely : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Move through wrapped lines. | showing ascii value of the current character in decimal, hex, and
octal >>
Additional Notes
rahul.agrawal@mapleoptical.com, August 13, 2002 11:09
Yeah. Its pretty cool, and provides an edge over other
editors.
Anonymous, September 28, 2002 10:54
To get better feedback you can use the :redir command
to redirect messages to a file, like this:
vim --servername GVIM --remote-send ':redir >>
outputfile<cr>'
You can also evaluate remote expressions, ie:
vim --servername GVIM --remote-expr 'mode()'
this will tell you what mode vim is currently in and
vim --servername GVIM --remote-expr 'getcwd()'
will tell you what directory vim is working in
Anonymous, January 23, 2004 9:17
I never have to worry about leaving a file open,
unsaved. I used to do that a lot, and have developed a
nervous habbit of saving a LOT.
If you are like me, and don't have to worry about that,
then you can simply type "killall vim", and all open
vim's will close themselfs. If you just want to kill
one type "ps -ef | grep vim" to find the pid. You can
then type "kill 1234" where 1234 is the pid.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #310 - showing ascii value of the current character in decimal, hex, and octal : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
dont know if you guys know this or not, but i was trying
to make the word "hello" to upper case by trying "gaUw"
(=
which didnt work but it showed the decimal, hex, and
octal of the char under the cursor... ncie to know.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<close vim you left open remotely | Open the folder containing the currently open file >>
Additional Notes
calvin wong, August 13, 2002 12:11
DOH.... i forgot.
its "ga" or ":as" or ":ascii"
Anonymous, August 18, 2002 10:03
vimtip #67
oxcrete@yahoo.com, August 26, 2002 10:53
Don't kow if you already knew this but, the "~" "tilde"
character changes the case of the caharacter under the
cursor and "[count]~" changes the case of "count"
number of characters as in "5~" changes the case of 5
characters. the count is a VIm feature but ~ is an old
vi feature.
keramida@ceid.upatras.gr, October 6, 2002 20:25
Actually, the [count]~ feature is also there in quite
old vi
implementations too. Even Solaris has it in old
versions...
http://www.vim.org/tips/tip.php?tip_id=310 (1 of 2) [18/02/2004 14:53:24]
Tip #310 - showing ascii value of the current character in decimal, hex, and octal : vim online
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #311 - Open the folder containing the currently open file : vim online
Home
Search
Tip #311: Open the folder containing the currently open file
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<showing ascii value of the current character in decimal, hex, and octal | Copy, Cut, and Paste >>
Additional Notes
Anonymous, August 14, 2002 7:46
Why have it inside a gui_running block?
a difference?)
Alan.S.Budden@virgin.net, August 21, 2002 2:28
(Does it make
Tip #311 - Open the folder containing the currently open file : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim:
5.7
PS: copy, cut, and paste are the words from (usually)
gui editor.
Ever try to cut (or copy) some lines and paste to
another place?
If you need to count the lines first, then try these to
eliminate counting task.
Cut and Paste:
1. Place the cursor at the beginning of the block you
want to CUT.
2. Mark it with md
3. Go to the end of the block.
4. Cut it with d'd
5. Go to the new location that you want to PASTE those
text.
6. Press P.
Copy and Paste:
1. Place the cursor at the beginning of the block you
want to COPY.
2. Mark it with my
3. Go to the end of the block.
4. Cut it with y'y
5. Go to the new location that you want to PASTE those
text.
6. Press P.
The name of the mark used is related to the operation
(d:delete or y:yank).
I found that those mark names requires minimal movement
of my finger. ;)
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Open the folder containing the currently open file | printing using kprinter (unix + kde) >>
Additional Notes
anis_wn@cbn.net.id, August 13, 2002 23:24
Sorry, step 4 for Copying supposed to be 'Copy...' :(
marcin@amiga.pl, August 13, 2002 23:31
2. Press v to select block
4. Cut it with "dd
4. Copy it with "yd
6. Press P (if you want to paste before) or p (if you
want to paste after).
6. If you want to paste it later press "dp (or "yp for
copy) to insert it after.
rainbrot@snark.com, August 18, 2002 3:12
Cut and paste:
1. Position the cursor where you want to begin cutting.
2. Press v (or upper case V if you want to cut whole
lines).
3. Move the cursor to the end of what you want to cut.
4. Press d.
5. Move to where you would like to paste.
6. Press p to paste after the cursor, or P to paste
before.
Copy and paste can be performed with the same steps,
only pressing y instead of d in step 4.
If you want to copy and paste between editor buffers
(but not between instances of vim), or if you want to
maintain multiple "clipboards" (copy buffers), you can
name your buffer by pressing "x (that's a double quote
followed by x, where x is the single letter name you
choose for your buffer) before the d in step 4, and
again before the p in step 6.
If you happen to be using gvim for Windows and want to
copy or cut into the Windows clipboard, press
Ctrl+Insert in step 4 (to copy) or Shift+Delete to
cut. To paste from the Windows clipboard, press
Shift+Insert.
dedekind@mail.ru, November 16, 2003 1:23
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
just add
set printexpr=system('kprinter'\ .\ '\ '\ .\
v:fname_in)\ .\ delete(v:fname_in)\ +\ v:shell_error
to your ~/.vimrc; further on all your printing will be
piped through the nice and consistent print-dialog of
kde.
lg,
tomte
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Additional Notes
viking@vi.king.net, August 16, 2002 7:54
Unfulfilling
rate
Hi !
I got used to work with the US keyboard layout (much
better for programming : easy access to ;:/.?\"]}[{<>)
instead of the swiss-french one. I found the idea of jj
great, but decided to use jk (faster, two muscles
driven, fun).
impa jk <Esc>
ps : more over, jk makes joke if you try to say it, and
that's very cool.
dev@gaspardbuma.org, June 10, 2003 0:43
sorry for the misstyping :
imap jk <Esc>
fatboyco93@hotmail.com, February 6, 2004 2:18
Hey,
I seemed to type the imap thing just as you said but it
doesn't seem to work.
I typed
imap jj <Esc>
in my .vimrc file but when i'm insert mode it just
gives me a bunch of jj's. Is it just me?
Chad
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: advanced
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Anonymous, August 15, 2002 1:16
What's the point of this tip?
This tip does have a point -- it's helpful for those who are
transitioning from their favorite IDEs to Vim. I use 0 and ^ because I
have them memorized, but others might not...
For those who spend a lot of time in their text editors, it's worth a
few hours of learning up-front -- certainly, the time spent learning
shortcuts like "*" and "t" pays for itself many times over. For others,
who might spend only a little while with their editor, it might not.
For them, it's useful to know that a few lines of code can make Vim
behave like what they already know. And if you happen be such a person,
you may wish to check out Cream, which makes Vim much easier to use for
beginners:
http://cream.sourceforge.net/
And, while I'm being unorthodox, I may as well add a question to my
note:
In some IDEs, the behavior of Home varies depending on how many times
you press it. The first time, it goes to the beginning of the line; the
second, to the top of the screen; and the third, to the top of the
file. This is trivial to accomplish in Vim -- something like
map <HOME> ^
map <HOME><HOME> H
map <HOME><HOME><HOME> gg
But Vim will hesitate after the first Home press to see if you are
going to press Home again (and likewise for the second Home). This
interval can be adjusted with the (t)timeoutlen option, but it is
difficult to select a value that makes <HOME> near-instantaneous and
still make the whole sequence easy to enter without hand spasms.
Is there any way to
be fairly simple to
could check and see
line (or at the top
I don't own a keyboard where the home key is any near my fingers, so I
prefer to use '^' and the like. Considering the time it takes to go
into normal mode, do my thing and then return to insert mode rather
than using home, this function is useless; to me, anyway.
lailoken@freeshell.org, August 26, 2002 9:17
Unless I'm confused, why not just use the function like so:
fun! s:SmartHome()
if col('.') == 1
norm ^
else
norm 0
endif
endfun
Please send me email in this regard...
Alex A. Naanou <alex_nanou@yahoo.com>, August 28, 2002 16:23
Thanks for the remark!!!
The function mentioned above is OK, but the thing I wanted is to do
'^' if we are not on the first non-whitespace else do '0'. the proposed
above function does the opposite (first '0' then '^')
// And I must admit that my original else clause is overcomplicated!! (using norm 0 is sufficient) :)
and here we have the new and improved version:
---cut--fun! s:SmartHome()
" this line checks if we are not on the first whitespace.
if col('.') != match(getline('.'), '\S')+1
norm ^
else
norm 0
endif
endfun
inoremap <silent><home> <C-O>:call <SID>SmartHome()<CR>
nnoremap <silent><home> :call <SID>SmartHome()<CR>
vnoremap <silent><home> :call <SID>SmartHome()<CR>
---uncut--Thanks again!
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
It can be entered
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
If you use VIM you like the h, j, k, and l movement keys. I found myself
annoyed at not having these movement keys available when browsing web
pages. Moving to the arrow keys on a laptop is annoying to just scroll the
page.
Locate your mozilla/res/builtin directory (varies by platform). You could
search for htmlBindings.xml to find it. (ie. locate htmlBindings.xml.
On Mac OS X it's inside the Mozilla application
bundle. /Applications/Mozilla/Mozilla.app/Contents/MacOS/res/builtin.
Create a new XML file called userHTMLBindings.xml, making it executable for
all users and making sure the CRLF format is the same as
htmlBindings.xml. i.e. on Mac OS X most files use \r but Vim writes \n
instead. You can either save the file with Vim as a Mac formatted file or
use tr '\n' '\r' < input.xml > output.xml to convert the file.
Place the following XML into the userHTMLBindings.xml file.
<?xml version="1.0"?>
<bindings id="htmlBindings"
xmlns="http://www.mozilla.org/xbl";
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">;
<binding id="browserUser">
<handlers>
<handler event="keypress"
<handler event="keypress"
<handler event="keypress"
<handler event="keypress"
</handlers>
</binding>
</bindings>
key="h"
key="j"
key="k"
key="l"
command="cmd_scrollLeft"/>
command="cmd_scrollLineDown"/>
command="cmd_scrollLineUp"/>
command="cmd_scrollRight"/>
There are many more bindings one could configure to get Vim like
keybindings. You can read
http://www.mozilla.org/unix/customizing.html#keys for more information.
PS. I love the keymaster/gatekeeper xul reference in the xul URL
above. It's from the original GhostBusters movie. ;-)
Life Changing
Helpful
Unfulfilling
rate
<<Using /pattern/ search in a script | Extended Bracket and Parenthesis + extras for perl >>
Additional Notes
Anonymous, September 7, 2002 19:53
I found this didn't work in userHTMLBindings.xml, but adding relevant
lines in htmlBindings.xml works great - thank you, this is one of those
things I've always wanted!
Mohit Kalra, September 8, 2002 1:35
This comment is not exactly related to vim.
http://labs.google.com/keys/index.html
Google for the keyboard aficionados.
-mohit
Anyways, checkout
Probably not, at least not without hacking the Mozilla source. Most of
what you listed would include a corded keypress. i.e. ALT+Key,
CTRL+Key. All the Mozilla docs state for legal commands would be mostly
navigation keystrokes like pageup/down, etc. Also some editing and
clipboard stuff. See the link in the Tip for the Mozilla.org
documentation. Of course the modifier keys (CTRL+ALT, etc.) are
customizable as it is done for each platform. i.e. Mac's have a CMD key
(Apple Key) that is used instead of CTRL. A Mac has CTRL, Option(ALT),
and Command(apple logo). Sun has a CTRL, ALT, and a Meta key. It may
still be somewhat possible, you would have to replace the modifier key
cording with a single key press. However, this may produce undesirable
effects that could impact normal Mozilla operation, etc.
Netscape 7 is really Mozilla under the hood. Netscape took Mozilla as
the base and added some stuff that isn't open source. i.e. AIM client
and some other things. I find Netscape 7 to be bloated and full of
useless fluff, but that's my opinion.
Gecko is the rendering engine under the Mozilla hood. XUL is a way to
create a browser interface and can be heavily skinned. XUL is literally
rendered by Gecko. So your widgets are all drawn by the render
engine. Neat concept but it can get a bit bloated (it's gotten much
better with the 1.x releases). There are many projects that take Gecko
and wrap it up in a particular widget kit so it doesn't use XUL for the
interface. This eliminates the skinning but it makes for a lighter
smaller non-cross platform browser, which apparently many people want
badly. Gnome, KDE, Win32, Cocoa/Aqua, etc., etc., etc. They seem to
want a native widget kit that matches their platform better.
Ultimately, I would want a lightweight browser that is really fast and
good at one thing, rendering pages and loading plugins. I could care
less about email, chat, etc. I have other programs for that stuff.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #318 - Extended Bracket and Parenthesis + extras for perl : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
"########################################
" File - matchMe.vim
" Date - Wednesday, August 21, 2002
"########################################
" This code fixes my problem with
http://www.vim.org/tips/tip.php?tip_id=318 (1 of 10) [18/02/2004 14:53:43]
Tip #318 - Extended Bracket and Parenthesis + extras for perl : vim online
" does the one format for perl and still keeps hashes
function! InsertBrackets()
let fileType = &ft
if fileType == 'perl'
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k' && getline('.')[col - 1] !~ '\$' &&
getline('.')[col - 1] !~ '@' && getline('.')[col - 1] !~ '%' && getline('.')[col - 1] !~
'#'
return "{\<cr>\<bs>}\<esc>ko"
else
return "{}\<esc>i\<c-o>:echo \<cr>"
endif
else
return "{\<cr>\<bs>}\<esc>ko"
endif
endfunction
" This code jumps out of the brackets
function! JumpNext(normChar)
let ret = "\<space>\<esc>ma\<left>/\\".a:normChar."\<cr>mb`ai\<del>\<esc>`bi\<right>"
return ret
endfunction
" mappings
inoremap " ""<esc>i<c-o>:echo <cr>
inoremap ' ''<esc>i<c-o>:echo <cr>
inoremap < <><esc>i<c-o>:echo <cr>
inoremap ( ()<esc>i<c-o>:echo <cr>
inoremap [ []<esc>i<c-o>:echo <cr>
inoremap { <c-r>=InsertBrackets ()<cr>
inoremap > <c-r>=JumpNext(">")<cr>
inoremap ) <c-r>=JumpNext(")")<cr>
inoremap ] <c-r>=JumpNext("]")<cr>
inoremap } <c-r>=JumpNext("}")<cr>
inoremap <m-[> [
inoremap <m-]> ]
inoremap <m-/> "
inoremap <m--> {
inoremap <m-=> }
inoremap <m-,> <
inoremap <m-.> >
inoremap <m-'> '
Tip #318 - Extended Bracket and Parenthesis + extras for perl : vim online
"########################################
" End Of File
"########################################
If you have any other suggestions, drop a note...
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
atkinssc@engr.orst.edu, August 22, 2002 9:15
Found a bug or two...
Here's the Fix:
"########################################
" File - matchMe.vim
" Date - Wednesday, August 21, 2002
"########################################
" This code fixes my problem with
" does the one format for perl and acts correctly with
" hashes
function! InsertBrackets()
let fileType = &ft
if fileType == 'perl'
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k' && getline('.')[col - 1] !~ '\$' &&
getline('.')[col - 1] !~ '@' && getline('.')[col - 1] !~ '%' && getline('.')[col - 1]
!~ '#'
return "{\<cr>\<bs>}\<esc>ko"
else
return "{}\<esc>i\<c-o>:echo \<cr>"
endif
else
return "{\<cr>\<bs>}\<esc>ko"
endif
endfunction
" This code jumps out of the brackets
http://www.vim.org/tips/tip.php?tip_id=318 (3 of 10) [18/02/2004 14:53:43]
Tip #318 - Extended Bracket and Parenthesis + extras for perl : vim online
Tip #318 - Extended Bracket and Parenthesis + extras for perl : vim online
inoremap
inoremap
inoremap
inoremap
inoremap
inoremap
""" """
"" ""<esc>i
<> <><esc>i
[] []<esc>i
() ()<esc>i
{} {}<esc>i
Tip #318 - Extended Bracket and Parenthesis + extras for perl : vim online
thanks!!
atkinssc@engr.orst.edu, August 23, 2002 12:58
One more update...
I found this quite useful, as sometimes I delete the ending char, to insert it around a
block, and then when I type it again, I just get a flash...
" This code jumps out of the brackets
function! JumpNext(startChar, endChar,oneItem)
let ret1 = "\<esc>:if
\"0\"==searchpair('".a:startChar."','','".a:endChar."','W','synIDattr(synID(line(\".\"),
col(\".\"), 0), \"name\") =~? \"string\"')\<cr>exec(\"normal
i".a:oneItem."\")\<cr>endif\<cr>i\<right>"
return ret1
endfunction
" mappings
inoremap >
inoremap )
inoremap ]
inoremap }
<c-r>=JumpNext("<",">","\<m-.>")<cr>
<c-r>=JumpNext("(",")","\<m-0>")<cr>
<c-r>=JumpNext("[","]","\<m-=>")<cr>
<c-r>=JumpNext("{","}","\<m-]>")<cr>
Tip #318 - Extended Bracket and Parenthesis + extras for perl : vim online
Here's an update, with toggle, and the toggle should let your escape work again:
"########################################
" File - matchMe.vim
" Date - Wednesday, August 21, 2002
" E-Mail - atkinss@onid.orst.edu
"########################################
" This code fixes my problem with
" does the one format for perl, and acts
" correctly with hashes.
function! InsertBrackets()
let fileType = &ft
if fileType == 'perl'
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k' && getline('.')[col - 1] !~ '\$' &&
getline('.')[col - 1] !~ '@' && getline('.')[col - 1] !~ '%' && getline('.')[col - 1]
!~ '#'
return "{\<cr>\<bs>}\<esc>ko"
else
return "{}\<esc>i\<c-o>:echo \<cr>"
endif
else
return "{\<cr>\<bs>}\<esc>ko"
endif
endfunction
" This code jumps out of the brackets
function! JumpNext(startChar, endChar,oneItem)
let ret1 = "\<esc>:if
\"0\"==searchpair('".a:startChar."','','".a:endChar."','W','synIDattr(synID(line(\".\"),
col(\".\"), 0), \"name\") =~? \"string\"')\<cr>exec(\"normal
i".a:oneItem."\")\<cr>endif\<cr>i\<right>"
return ret1
endfunction
" Added toggle.
" Date: Thursday, August 29, 2002 @ 07:57 AM
" Thanks to: Alex A. Naanou <alex_nanou@yahoo.com>
fun! s:Toggle_Edit2()
if exists('b:edithelpers_on') && b:edithelpers_on == 1
http://www.vim.org/tips/tip.php?tip_id=318 (7 of 10) [18/02/2004 14:53:43]
Tip #318 - Extended Bracket and Parenthesis + extras for perl : vim online
if (!exists('b:edithelpers2_on') || b:edithelpers2_on == 0)
let b:edithelpers2_on=1
" mappings
inoremap > <c-r>=JumpNext("<",">","\<m-.>")<cr>
inoremap ) <c-r>=JumpNext("(",")","\<m-0>")<cr>
inoremap ] <c-r>=JumpNext("[","]","\<m-=>")<cr>
inoremap } <c-r>=JumpNext("{","}","\<m-]>")<cr>
inoremap <m-=> ]
inoremap <m-]> }
inoremap <m-.> >
inoremap <m-0> )
else
let b:edithelpers2_on=0
iunmap >
iunmap )
iunmap ]
iunmap }
iunmap <m-=>
iunmap <m-]>
iunmap <m-.>
iunmap <m-0>
endif
endif
endfun
" Added toggle.
" Date: Thursday, August 29, 2002 @ 07:57 AM
" Thanks to: Alex A. Naanou <alex_nanou@yahoo.com>
fun! s:Toggle_Edit()
if !exists('b:edithelpers_on') || b:edithelpers_on == 0
let b:edithelpers_on=1
" mappings
inoremap " ""<esc>i<c-o>:echo <cr>
inoremap ' ''<esc>i<c-o>:echo <cr>
inoremap < <><esc>i<c-o>:echo <cr>
inoremap ( ()<esc>i<c-o>:echo <cr>
inoremap [ []<esc>i<c-o>:echo <cr>
inoremap { <c-r>=InsertBrackets ()<cr>
inoremap <m--> [
inoremap <m-/> "
inoremap <m-[> {
inoremap <m-,> <
inoremap <m-9> (
inoremap <m-'> '
http://www.vim.org/tips/tip.php?tip_id=318 (8 of 10) [18/02/2004 14:53:43]
Tip #318 - Extended Bracket and Parenthesis + extras for perl : vim online
if !exists('b:edithelpers2_on') || b:edithelpers2_on == 0
call <SID>Toggle_Edit2()
endif
else
iunmap "
iunmap '
iunmap <
iunmap (
iunmap [
iunmap {
iunmap <m-->
iunmap <m-/>
iunmap <m-[>
iunmap <m-,>
iunmap <m-9>
iunmap <m-'>
if exists('b:edithelpers2_on') && b:edithelpers2_on == 1
call <SID>Toggle_Edit2()
endif
let b:edithelpers_on=0
endif
endfun
nnoremap <silent><F9> :call <SID>Toggle_Edit()<CR>
inoremap <silent><F9> <C-O>:call <SID>Toggle_Edit()<CR>
call <SID>Toggle_Edit()
nnoremap <silent><F8> :call <SID>Toggle_Edit2()<CR>
inoremap <silent><F8> <C-O>:call <SID>Toggle_Edit2()<CR>
" F-8 toggles the jump
" F-9 toggles the bracketing feature and overrides F-8
quesadaj@psych.colorado.edu, August 15, 2003 23:37
For me, trying to use F9 (Toggle) sends a whole list of error E31 "No such mapping"....
Other than that, it works as expected. Tried both unix and windows, same results
I would love to have the Toggle...
Thanks in advance!
quesadaj@psych.colorado.edu, August 16, 2003 0:22
Tip #318 - Extended Bracket and Parenthesis + extras for perl : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
=1;
=2;
=1;
=2;
Life Changing
Helpful
Unfulfilling
rate
<<Extended Bracket and Parenthesis + extras for perl | Borland pageup/down behavier >>
Additional Notes
= 0;
= "moo";
=1;
=2;
=1;
=2;
= 0;
= "moo";
http://www.ophinity.com/code/wrangling/index.html#lineUp
pro:
humans can understand python
con:
you need to have a python interpreter on your box
it's not as sophisticated as dr. chips script
jahagirdar_vs@yahoo.Ihatespam.com, August 24, 2002 3:51
I know about the drawback alex mentioned( having a
variable name more than 20
characters long) this was just a sample example the
number of space inserted and the column at which
alignment has to be done can be changed as per
requirement.
Anonymous, August 25, 2002 17:53
You can save a couple keystrokes without visual mode.
0f=20i<space><esc>020ldt=
And a couple more by using the goto-column movement (
:help bar )
0f=20i<space><esc>d20|
And finally, you can fire off something like
:11,32norm 0f=20i<space><ctrl-v><esc>d20|
to do this for a bunch of lines.
agentwho@hotmail.com, August 26, 2002 8:00
0f=gelcw<TAB><ESC>
works well of you have softtabs set to use spaces. (Or
using :retab)
This will align based on next tab collumns. Neat enough
for me.
Marius.
jmcpherson@bigfoot.com, August 28, 2002 15:07
Metatip: Edit your tips with Vim itself (or Notepad, or
another editor that edits raw text in a monospaced
font). Then paste them into the textbox when you are
posting your tip.
That way, the odds of things lining up are much better,
since the tips display in a monospaced font.
Anonymous, August 30, 2002 13:06
agentwho@hotmail.com:
0f=gelcw<TAB><ESC>
will fail if there's no space between the previous word
and the equals sign.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<text formatting (lining up ='s,('s etc)) | Centura swap with upper/lower line behavier >>
Additional Notes
Anonymous, August 27, 2002 2:34
For maintaining the same x coordinate, help startofline
Anonymous, August 27, 2002 4:21
And CTRL-U (up), CTRL-D (down) may also be useful for
what you want (half page scrolls)
vdvo@seznam.cz, February 2, 2003 12:43
A solution that I use (easier, I would say, but has a
small side-effect) is this:
map <PageDown> :set scroll=0<CR>:set scroll^=2<CR>:set
scroll-=1<CR><C-D>:set scroll=0<CR>
map <PageUp> :set scroll=0<CR>:set scroll^=2<CR>:set
scroll-=1<CR><C-U>:set scroll=0<CR>
I found Vim's normal PgUp/PgDn behaviour weird - I
think it's different from every other editor I've used
and I was unable to get used to it. The above two lines
are godsent! :-)
Andrew Pimlott <andrew@pimlott.net>, February 3, 2003 14:32
I just entered a refinement of vimtip #105 as vimtim
#417. You might find it useful to incorporate the
improvements into this tip.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #321 - Centura swap with upper/lower line behavier : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
salmanhalim@hotmail.com, August 27, 2002 19:53
Instead of "ddkkp", how about simply "ddkP"? One less
keystroke! :) (Saving keystrokes is one of the
biggest reasons why people use vi-like editors in the
first place.)
Tip #321 - Centura swap with upper/lower line behavier : vim online
Tip #321 - Centura swap with upper/lower line behavier : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
}
and so forth.
The choice of %%% proved to be almost universal, it even
works in MATLAB or LaTeX where % is the comment
character.
Even if you forget to replace one %%%, that's not a
problem as the compiler flags is as a syntax error
(except MATLAB and LaTeX, of course).
It made my life easier, maybe it works for you.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Centura swap with upper/lower line behavier | using folders with latex >>
Additional Notes
hermitte at free.fr, August 29, 2002 8:31
Mu-Template proposes a support for placeholders when
inserting template files :
http://vim.sourceforge.net/script.php?script_id=222
Actually, it is based on Stephen Riehm's bracketing
system.
Moreover, regarding C or C++, I propose several files
that define abbreviations that support placeholders :
http://vim.sourceforge.net/script.php?script_id=336
It is based on a collection of scripts of mine :
http://vim.sourceforge.net/script.php?script_id=50
and also it is strongly inspired by Stephen Riehm's
bracketing system.
On my web site, I provide similar script for LaTeX or
HTML coding.
Unfortunately, the definition of the templates is quite
complex as it is possible to change (through a pair of
variables) the markers used (to signal the
placeholders) -- the "jumping" (to the next marker)
functions are also customisable thanks to variables.
Otherwise,I also remember several alternatives (that
focused of the definition of the template) to the same
problem. They are here on SF.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
set foldmarker=\\begin,\\end
set foldmethod=marker
this is useful with big latex document
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Site Help
<<text template with placeholders | Search and replace in files named NAME >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #324 - Search and replace in files named NAME : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Tip #324 - Search and replace in files named NAME : vim online
6 #
7 # usage:
8 #
find_replace.sh file "string" "replace"
9 #
10 if [ $1 -a $2 -a $3 ]; then
11
for i in `find . -name "$1" -type f | xargs
grep -l $2`; do
12
# how do search and replace
13
# the screen might flicker... vim
opening and closing...
14
vim -c ":%s/$2/$3/g" -c ":wq" $i
15
done
16
exit 0
17 fi
18 # I should never reach here
19 echo -e "USAGE: find_replace.sh file 'string'
'replace' \n\n"
20 exit 1
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
salmanhalim@hotmail.com, September 8, 2002 8:19
If you have a shell script environment available to
you, you must also have sed. Why not just pipe the
output of the find to xargs sed -e "%s/<from>/<to>/g"?
(Nothing against Vim; just trying to use the right tool
for the job.)
Anonymous, September 15, 2002 11:48
Not an option on a default install of Windows ;o)
Anonymous, October 11, 2002 7:40
What would make this feature more interesting is to be
able to run from inside VIM, ie I'm editing several
files from a tree inside VIM, I want the text replaced
both inside the file I'm currently editing (and the VIM
buffers updated) and all the others from that tree.
Add Note
Tip #324 - Search and replace in files named NAME : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: advanced
as of Vim: 6.0
6 sections:
your build script
makeprg
shell options
path formatting options
your errorformat
key mappings
May/000192.html to get
the -u option for sed (this avoids waiting for the build
output to get to
the screen)
testerrors.sed:
# This assumes that all your junit test cases are in a
com.* package
/^Running com\./ {
# duplicate the line
s!\(.*\)!\1\
\1!
P
# turn the test package into a directory path for %D
errorformat
s!.*\(com\..*\)\.[A-Za-z_][A-Za-z0-9_]*!\1!
s!\.!/!g
s!.*!Entering: /work/src/&!
# print the line and go on
p
n
}
# just pass any unmatched lines through
p
Set up makeprg
-------------Add the following lines to your vimrc:
autocmd BufNewFile,BufRead /work/*.java set
makeprg=mymake
autocmd BufNewFile,BufRead ?:/work/*.java set
makeprg=mymake
Set up shell options
-------------------Add the following lines to your vimrc:
" in order to have bash as the shell for win32 vi.exe
and gvim.exe, you have
" to set these options, and also build vimrun.exe in
the cygwin environment
" so that the system() call is executed via bash, not
cmd.exe -- the command
" to build vimrun.exe is "make -f Make_cyg.mak
vimrun.exe"
set shell=bash.exe
set shellcmdflag=-c
set shellslash
exception lines
\%-Z%^\ %#%$,
" any line can intervene between the start of an
exception printout
" and the line where it ends (last in list so that
it is matched if
" none of the other exception trace patterns
match)
\%-C%.%#,
" all other lines are not errors
\%-G%.%#
Set up key mappings
------------------Add the following lines to your vimrc:
nmap <F10> :clist<CR>
nmap <F11> :cprev<CR>
nmap <F12> :cnext<CR>
This allows for quick error navigation.
NOTES
----Vim treats the "Entering: /work/src/..." messages in a
weird way. If there
are any actual errors, then these error lines are
ignored by the :cnext and
:cprev commands, but if there are no real errors, then
:cnext and :cprev
roll through these "Entering:" messages as if they were
errors, but since
they don't include any line numbers, the cursor position
is never moved.
I thought that this was strange, but even stranger, it
is programmed
directly into the vim error handling code to function
exactly this way.
There were no comments, and nobody responded on the vim
mailing list, so I
just decided to live with it.
The upshot of it all is that if you see an error like
"Entering:", chances
are that your build succeeded and all the tests ran
without a problem.
Life Changing
Helpful
Unfulfilling
rate
<<Search and replace in files named NAME | Help for VIM Help (VIM QuickRef) >>
Additional Notes
John Sumsion, October 14, 2003 7:27
Um, the URL to the sed -u patch changed. I can't
figure out how to edit this tip, but here is the new
URL: http://mail.gnu.org/archive/html/bug-gnuutils/2002-05/msg00051.html
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #326 - Help for VIM Help (VIM QuickRef) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Type
:help quickref
or
:h quic
And get a VIM Command Quick Reference Page brilliant for
beginners & oldtimers alike
type
:h help to learn how to use help
Other Help Tips
# help for help
:h visual<C-D><tab>
help topics
: obtain
:
:
:
:
:
:
:h ctrl<C-D>
:h :r
:h CTRL-R
:h \r
:h i_CTRL-R
mode
:h c_CTRL-R
mode
:h v_CTRL-V
:h tutor
Life Changing
Helpful
Additional Notes
Unfulfilling
rate
Tip #326 - Help for VIM Help (VIM QuickRef) : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
I use my left thumb for the alt key and right for the space.
Using this combo, you can get
some useful key maps for which you don't have to move your hands.
I find I have to turn
my hand a little to press the left ctrl key.
These are some maps i use for C programming.
map ' `
map <C-f> :w<C-m>:!make<C-m>
map <M-]> <C-]>
map <M-[> <C-t>
map <M-u> :!ctags -R *<Cm>
map <M-c>
I/*<Esc>A*/<Esc>
current line
map <M-d> ^xx$xx
comment for a single line
map <M-l> [{zf%
upto the enclosing brace level
map <M-o> zo
map <M-i> zc
map <M-.> :cn<C-m>
next error in list
map <M-,> :cp<Cm>
list
imap <Tab> <Cp>
inoremap <S-Tab>
<Tab>
inoremap {
<CR>{<CR>
and line
inoremap }
<CR>}
line. saves one enter stroke
imap <M-j>
Tags
Tags
Build Tags
Comment
Delete
Fold
open fold
close fold
Go to
previous error in
Complete word
Tab
Brace
brace and
<Esc>
Don't want to move my hand to esc key.
imap <M-k> <Cy>
from above.
imap <M-q>
/* */<Esc>hhi
selected lines
Escape.
Copy line
Comment
Commented
No hilight
Bye,
Nithin.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Help for VIM Help (VIM QuickRef) | Vim in Microsoft Visual Foxpro >>
Additional Notes
young@intnet.mu, September 20, 2002 1:57
Hello Nithin,
I was baffled to read that you are attempting to reduce your
hand movements to the minimum [with these key mappings] while
you are typing. Surely you know that this makes you a very good
candidate for RSI (Repetitive Strain Injury). Experts recommend
that the hands "float" over the keyboard, with the fingers as
straight as possible -- instead of curled -- and using full arm
movements --instead of finger and wrist contortions. This
supposedly helps your arms and hands maintain a natural
orientation.
As a professional, I am very concerned with these issues and I
try to follow preventive measures against RSI as much as
possible. I recommend others to do the same. Nevertheless, your
tip was a good start for me to learn about key mappings.
Regards,
Eddy Young
rumcho at yahoo dot com, June 25, 2003 14:36
Why are you baffled about? Vim is about fast and efficient
writing, if you move your hands around in order to reach keys
that's slowing you down. I don't deny the possiblity of
developing some health condition but that's something the user
has to make special "accomodations" about and it is not the
goal of vim.
zvezdan@cs.wm.edu, December 10, 2003 16:59
Why remap so many keys just because you have to turn your hand
for Ctrl?
Remap Ctrl key instead. I do that on every system I use.
On any modern UNIX that uses X do:
setxkbmap -option ctrl:swapcaps
and your CapsLock key will become Ctrl, while Ctrl will become
CapsLock,
just like on good old Sun keyboards. That position is right
next to the pinky finger, and feels really
naturally. Considering that Bill Joy wrote vi and founded Sun,
it's not a surprise that Sun keyboards were so ideally suited
to vi. :-)
On older UNIX systems store this in a file:
!
! Swap Caps_Lock and Control_L
!
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L
and execute that file with
xmodmap filename
Probably the best thing is to put one of these commands in
.xsession or equivalent file.
Red Hat Linux and Fedora will execute by default .Xkbmap and
.Xmodmap. In such a case it is enough to put xmodmap commands
in .Xmodmap file, and only -option ctrl:swapcaps in .Xkbmap.
Of course you need only one of these two files.
In fact, I doubt that you'll do it, since you are already used
to your mappings.
But I do not recommend your tip to anybody else. I have put
this detailed description here for
other people who are frustrated with the position of Ctrl key,
yet do not know how to change it.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Additional Notes
Helpful
Unfulfilling
rate
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
xph
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
cec@NgrOyphSon.gPsfAc.nMasa.gov, September 20, 2002 11:08
Thought I'd mention some of the reasoning behind the gw-map
above. Sequences such as dawelp suffer from one or more problems:
* fencepost problems: they don't work correctly either at the beginning
of a line
or at the end of a line
* single-character-word problems: mappings using b, e, or variants don't
handle
single-character words properly.
jean upfrontsystems co za, October 5, 2002 11:03
Looks like this doesn't swap "this" and "that" when line 2 starts with
"that", and line 1 ends on "this";
that is a problem for another day :)
Just possibly Vim's newline-matching regexps will be able to cope with
this .. but it's probably going
too far.
cec@NgrOyphSon.gPsfAc.nMasa.gov, December 2, 2002 7:42
"_yiw:s/\(\%#\w\+\)\(\_W\+\)\(\w\+\)/\3\2\1/<cr><c-
{dap}p{
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
Additional Notes
maxiangjiang@homail.com, September 20, 2002 22:50
:h pt
even better
jlroyalty@yahoo.com, September 22, 2002 11:21
rate
BufEnter
BufEnter
BufEnter
BufEnter
To rando:
':set no ai' will not work when filetype (or the new indent
feature) exists. that's all this tip about.
findjaylogan@mailcity.com, January 17, 2003 8:00
Is there a way to make it insert spaces instead of tabs
when it auto-indents?
findjaylogan@mailcity.com, January 17, 2003 8:02
never mind...
the answer to my question was
set expandtabs
anonymous, March 1, 2003 19:39
There's no s on that:
:set expandtab
Also, I tried a few of the options above to turn off the
indenting but none seemed to work
so I renamed the html.vim file in the indent directory to
html_vim.
Syntax highlighting still works but the indenting is
disabled for now until I have time to figure
it out.
vim (at) leonini.net, March 30, 2003 23:57
add in your .vimrc:
" Paste Mode On/Off
map <F11> :call Paste_on_off()<CR>
set pastetoggle=<F11>
let paste_mode = 0 " 0 = normal, 1 = paste
func! Paste_on_off()
if g:paste_mode == 0
set paste
let g:paste_mode = 1
else
set nopaste
let g:paste_mode = 0
endif
return
endfunc
Keith@dontmailme.com, April 11, 2003 15:45
Enjoy!
Best Regards,
Carlo
-----Carlo Florendo
Astra Philippines Inc.
www.hq.astra.ph
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Additional Notes
http://www.vim.org/tips/tip.php?tip_id=331 (1 of 2) [18/02/2004 14:54:15]
Unfulfilling
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
I found at
http://groups.google.com/groups?q=vim+changing+shell+to+zsh&hl=en&lr=&ie=UTF8&selm=S_Rh9.716%24a5.124150%40news.uchicago.edu&rnum=4
a macro to insert footnotes in vim, but it doesn't work as of vim6.0.
so i wrote my own; this macro requires two differents shortcuts, one for
entering the first footnote, the other one for all subsequent footnotes.
when you hit "K0" (first footnote) or "KK" (all other footnotes) in normal
mode, your cursor is positionned at the end of the document, in the footnote
& in insert mode. The "a" bookmark is set to the place where you entered the
footnote in the text. so a "`a" will bring you back to the location of the
footnote in the text.
" for now requires entering K0 for the first footnote and then
KK
nmap K0 i[0]<esc>maG$i<end><enter>[0]
nmap KK maG$?\[[0-9]*\]<enter>yt]G$i<end><enter><esc>p<C-a>i<end>]<esc>`aP<Ca><right>i]<esc>maG$i<end><end>
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
emmanuel.touzery@wanadoo.fr, September 23, 2002 5:21
for information i just added a worthwhile special case:
we do not add the footnotes at the end of the document, but on the line
before a "--".
this is useful if you have a signature at the end of your mails, eg, do:
hello[0]!
[0] footnote
-sig
and not:
hello[0]!
-sig
[0] footnote
here is the updated code:
nmap K0 i[0]<esc>maG?--<enter><up>$i<end><enter>[0]
nmap KK maG$?\[[0-9]*\]<enter>yt]G?--<enter><up>$i<end><enter><esc>p<Ca>i<end>]<esc>`aP<C-a><right>i]<esc>maG?--<enter><up>$i<end><end>
(i'll take any suggestion to remove code duplication, but i don't know the
language well enough for now)
emmanuel.touzery@wanadoo.fr, September 24, 2002 6:36
ok, learned some more vim. now it's not anymore a macro, but a function.
you don't have to enter the text of the footnote separately, you are
prompted for it, so it's faster to use. also, there is no more separation
for the first footnote case: you all the time enter KK.
it also supports the case when there is a sig or not.
here is the whole code:
nmap KK :call InsertFootNote()<LF>
function! InsertFootNote()
.
" mark the position of the cursor
.
execute "normal ma"
.
" ask for footnote text
.
let footNoteText = input("enter text for footnote: ")
.
" was there already a footnote?
.
if search("\[[0-9]*]", "w")
.
.
" yes => get the number, copy it, increase
.
.
" it, put it at the footnote position, put
.
.
" the footnote text and position the cursor back.
.
.
execute "normal G$?\[[0-9]*\]\<enter>yt]:call
GotoFootNoteLocation()\<LF>$i\<end>\<enter>\<esc>p\<C-a>i\<end>] " .
footNoteText . "\<esc>`aP\<C-a>\<right>i]\<esc>"
.
else
.
.
" no => put [0], add at the end [0] + footnote text
.
.
" and position cursor back
.
.
execute "normal i[0]\<esc>:call
GotoFootNoteLocation()\<LF>$i\<end>
\<enter>\<enter>[0] " . footNoteText . "\<esc>`a"
.
endif
endfunction
" if there is a signature, the footnote
" should be positionned ontop of it, eg
" mail text
" [0] footnote 0
" -" sig
" and not:
" mail text
" -" sig
" [0] footnote 0
" otherwise it's at the end of the text.
function! GotoFootNoteLocation()
.
" the signature is found by the "--"
.
" pattern.
.
" i don't search from the end because
.
" a fwd will also match this and i don't want
.
" that footnotes are too far off, say after 5-6
.
" old forwarded emails.
.
if search("^--", "w")
.
.
" ok, there's a sig.
.
.
" just go on top of it.
.
.
execute "normal \<up>"
.
else
.
.
" no sig: we go at the end of the
.
.
" document.
http://www.vim.org/tips/tip.php?tip_id=332 (2 of 6) [18/02/2004 14:54:19]
.
.
.
endif
endfunction
footnote again, the number is incremented once too much. i guess it's
impossible to catch undo events for vim functions? :O(
btw, can you give me a pointer to a good vim programming website?
mikmach, September 25, 2002 2:07
1. Input field doesn't give possibility to format text
2. The best programming vim page is user manual and vim-mail list
emmanuel.touzery@wanadoo.fr, September 25, 2002 2:28
thanks, point one is a killer :O)
i didn't think about it. i guess at the end i'll take a mix of our scripts
(for the undo thing).
thanks! your code is a good example.
mikmach, September 25, 2002 10:33
And here is another example how nice (although sophisticated) map can
become terrible beast :)
Split of the window is a good compromise between input field and going down
Play with b:vimfootnotetype :) Alpha, alpha, arabic - roman for footnotes
is rare
inoremap ,f <C-O>:call VimFootnotes()<CR>
inoremap ,r <C-O>:q<CR><Right>
let b:vimfootnotetype = "alpha"
function! VimFootnoteType(footnumber)
if !exists("b:vimfootnotetype")
let b:vimfootnotetype = "arabic"
endif
if (b:vimfootnotetype =~ "^alpha\\|^Alpha")
if (b:vimfootnotetype =~ "^alpha")
let upper = "0"
else
let upper = "-32"
endif
if (a:footnumber <= 26)
let ftnumber = nr2char(a:footnumber+96+upper)
elseif (a:footnumber <= 52)
let ftnumber =
nr2char(a:footnumber+70+upper).nr2char(a:footnumber+70+upper)
else
let b:vimfootnotenumber = 1
let ftnumber = nr2char(97+upper)
endif
else
let ftnumber = a:footnumber
endif
return ftnumber
endfunction
function! VimFootnotes()
if exists("b:vimfootnotenumber")
let b:vimfootnotenumber = b:vimfootnotenumber + 1
let b:vimfootnotemark = VimFootnoteType(b:vimfootnotenumber)
let cr = ""
else
let b:vimfootnotenumber = 1
let b:vimfootnotemark = VimFootnoteType(b:vimfootnotenumber)
let cr = "\<cr>"
endif
"let b:pos = line('.').' | normal! '.virtcol('.').'|'.'4l'
exe "normal a[".b:vimfootnotemark."]\<esc>"
let splitposition = &splitbelow
set splitbelow
:5 split
let &splitbelow = splitposition
normal G
if search("^-- $", "bW")
exe "normal O".cr."[".b:vimfootnotemark."] "
else
exe "normal o".cr."[".b:vimfootnotemark."] "
endif
startinsert!
endfunction
Anonymous, September 25, 2002 19:28
Instead of hard-coding numbers like 97, suggest doing something like
char2nr( 'a' ) -- hard-coded numbers frighten me.
hermitte at free.fr, September 26, 2002 0:36
I do also vote for the window-splitting approach. I think it is one of the
best and cleanest choice we can have.
Otherwise, some minor other improvments can be done like "pluginizing" the
script :
It would start with something like :
" ---if exists("g:loaded_footnote_vim") | finish | endif
let g:loaded_footnote_vim = 1
let s:first_footnote = exists('g:first_footnote') : g:first_footnote ? 1
" Because I don't like to start the footnotes with [0]
if !hasmapto('<Plug>AddVimFootnote', 'i')
imap <C-X>f <Plug>AddVimFootnote
endif
if !hasmapto('<Plug>AddVimFootnote', 'n')
nmap <leader>af <Plug>AddVimFootnote
endif
nnoremap <Plug>AddVimFootnote :call <sid>VimFootnotes('a')<cr>
inoremap <Plug>AddVimFootnote <c-o>:call <sid>VimFootnotes('i')<cr>
"Note: be sure there is *NO* space after the '<cr>' when you copy-paste.
" The previous paragraph enables anyone to remap the functions calls
" to anything else that the developper's default bindings. To do so, add
into
" your .vimrc something like :
" nmap ,f <Plug>AddVimFootNote
function! s:VimFootnotes(appendcmd)
....
:below 3sp
" note that you don't need change the value of 'splitbelow'
exe "normal ".a:appendcmd."[".b:vimfootnotenumber."]\<esc>G"
...
Anon, September 26, 2002 6:01
You could technically parse the line just above the place where the next
footnote is going to be placed: something like substitute( getline( '.' 1 ), '^\[\(\w\+\)\]', '\1', '' ) should give you the footnote
number/letter. Then, either increment it as a number or do a char2nr on it
(depending on the footnote style) for the processing. That way, you don't
have to worry about not being able to handle decrementing the footnote
value upon an undo operation.
emmanuel.touzery@wanadoo.fr, October 30, 2002 2:23
there is now a script improving on this tip.
you probably want it instead: http://www.vim.org/script.php?script_id=431
emmanuel
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
Additional Notes
feral@firetop.spammersdie.com, September 24, 2002 5:47
rate
Hi,
The tip in the comment is great. As is the whole concept of easy
folding.
I popped this into my .vimrc:
map <silent> <F12> :OUTLINE<CR>
This makes F12 switch in and out of outline (folded) mode.
You could probably use autocommand to make the folding happen when
you open something you want to fold.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Syntax-based folding for c/c++/java | Copy C++ function declaration into implementation file >>
Additional Notes
salmanhalim@hotmail.com, September 30, 2002 17:15
http://www.vim.org/tips/tip.php?tip_id=334 (1 of 2) [18/02/2004 14:54:23]
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #335 - Copy C++ function declaration into implementation file : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
There's a handy plug in for MS Visual Studio called CodeWiz that has a nifty ability to copy a function
declaration and deposit it into the implementation file on command. I actually missed while using vim,
so I wrote an approximation of that capability. This isn't foolproof, but it works alright.
" Copy Function Declaration from a header file into the implementation file.
nmap <F5> "lYml[[kw"cye'l
nmap <F6> ma:let
@n=@/<cr>"lp==:s/\<virtual\>/\/\*&\*\//e<cr>:s/\<static\>/\/\*&\*\//e<cr>:s/\s*=\s*0\s*//e<cr>:s/(.\{}\zs=\s*[^,)]\{-1,}\>\ze\(\*\/\)\@!.*)/\/\*&\*\//e<cr>:s/(.\{-}\zs=\s*[^,)]\{1,}\>\ze\(\*\/\)\@!.*)/\/\*&\*\//e<cr>:s/(.\{-}\zs=\s*[^,)]\{1,}\>\ze\(\*\/\)\@!.*)/\/\*&\*\//e<cr>:let @/=@n<cr>'ajf(b"cPa::<esc>f;s<cr>{<cr>}<cr><esc>kk
To use this, source it into vim, for example by placing it in your vimrc, press F5 in normal mode with
the cursor on the line in the header file that declares the function you wish to copy. Then go to your
implementation file and hit F6 in normal mode with the cursor where you want the function
implementation inserted.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Loading scripts in .vimrc safely | type the line number and press enter to get there >>
Additional Notes
feral@firetop.dontspamme.com, October 1, 2002 21:16
Tip #335 - Copy C++ function declaration into implementation file : vim online
I liked the idea behind Leif?s TIP and I thought ~a~ command you could call in the header ~or~ source
file would be good(one less thing for me to remember) an besides I knew just how I wanted to do it!
Along the way I?ve made a slight improvement or two (no longer clobbers registers/marks for instance).
This is formatted to stuff into a file and drop into your plugin directory.
So it seems to work in most cases (single line Member functions all(?) seem to work, anything else
well, doesn?t) (trips on the same things Leif?s implementation does of course because it IS Leif?s
implementation! I just moved some lines around ;) )
Happy VIMing!
copycppdectoimp.vim>>>
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
From VIM-Tip #335: Copy C++ function declaration into implementation file
by Leif Wickland
as of Vim:
5.7
See: http://vim.sourceforge.net/tip_view.php?tip_id=335
\author
Leif Wickland
\author
(Mangled by) Robert KellyIV <Feral@FireTop.Com>
\note
This file and work is based totally on Leif Wickland's VIM-TIP#335
\date
Tue, 01 Oct 2002 21:03 Pacific Daylight Time
\version
$Id$
Version:
0.2
History: {{{
[Feral:274/02@20:42] 0.2
Improvments: from Leif's Tip (#335):
* can handle any number of default prams (as long as they are all
on the same line!)
* Options on how to format default params, virtual and static.
(see below) TextLink:||@|Prototype:|
* placed commands into a function (at least I think it's an
improvement ;) )
* Improved clarity of the code, at least I hope.
* Preserves registers/marks. (rather does not use marks), Should
not dirty anything.
* All normal operations do not use mappings i.e. :normal!
(I have Y mapped to y$ so Leif's mappings could fail.)
Limitations:
* fails on multi line declorations. All prams must be on the same
line.
* fails for non member functions. (though not horibly, just have
to remove the IncorectClass:: text...
0.1
Leif's original VIM-Tip #335
Tip #335 - Copy C++ function declaration into implementation file : vim online
" }}}
if exists("loaded_copycppdectoimp")
finish
endif
let loaded_copycppdectoimp = 1
"{{{ [basic] Tip #335: Copy C++ function declaration into implementation file
" tip karma
Rating 5/2, Viewed by 49
"
"created:
October 1, 2002 6:47
complexity:
basic
"author:
Leif Wickland
as of Vim:
5.7
"
"There's a handy plug in for MS Visual Studio called CodeWiz that has a nifty ability to copy a
function declaration and deposit it into the implementation file on command. I actually missed while
using vim, so I wrote an approximation of that capability. This isn't foolproof, but it works
alright.
"
"" Copy Function Declaration from a header file into the implementation file.
"nmap <F5> "lYml[[kw"cye'l
"nmap <F6> ma:let
@n=@/<cr>"lp==:s/\<virtual\>/\/\*&\*\//e<cr>:s/\<static\>/\/\*&\*\//e<cr>:s/\s*=\s*0\s*//e<cr>:s/(.\{}\zs=\s*[^,)]\{-1,}\>\ze\(\*\/\)\@!.*)/\/\*&\*\//e<cr>:s/(.\{-}\zs=\s*[^,)]\{1,}\>\ze\(\*\/\)\@!.*)/\/\*&\*\//e<cr>:s/(.\{-}\zs=\s*[^,)]\{1,}\>\ze\(\*\/\)\@!.*)/\/\*&\*\//e<cr>:let @/=@n<cr>'ajf(b"cPa::<esc>f;s<cr>{<cr>}<cr><esc>kk
"
"To use this, source it into vim, for example by placing it in your vimrc, press F5 in normal mode
with the cursor on the line in the header file that declares the function you wish to copy. Then go
to your implementation file and hit F6 in normal mode with the cursor where you want the function
implementation inserted.
" }}}
function! <SID>GrabFromHeaderPasteInSource(howtoshowVirtual, howtoshowStatic, howtoshowDefaultParams)
"{{{
"
echo confirm(expand("%:e"))
if expand("%:e") ==? "h"
"nmap <F5> "lYml[[kw"cye'l
"
execute ":normal! ml"
let SaveL = line(".")
let SaveC = virtcol(".")
"
"
Tip #335 - Copy C++ function declaration into implementation file : vim online
"
echo confirm(s:ClassName)
else
"
"
echo confirm(s:ClassName)
let SaveL = line(".")
let SaveC = virtcol(".")
:execute ':normal! ma'
:let Was_Reg_n = @n
:let @n=@/
:execute ':normal! O'.s:LineWithDecloration
:execute ':normal! =='
" XXX if you want virtual commented in the implimentation:
if a:howtoshowVirtual == 1
:s/\<virtual\>/\/\*&\*\//e
else
" XXX else, remove virtual and any spaces/tabs after it.
:s/\<virtual\>\s*//e
endif
" XXX if you want static commented in the implimentation:
if a:howtoshowStatic == 1
:s/\<static\>/\/\*&\*\//e
else
" XXX else, remove static and any spaces/tabs after it.
:s/\<static\>\s*//e
endif
" wipe out a pure virtual thingie-ma-bob. (technical term? (= )
:s/\s*=\s*0\s*//e
" Handle default params, if any.
if a:howtoshowDefaultParams == 1
" Remove the default param assignments.
:s/\s\{-}=\s\{-}[^,)]\{1,}//ge
else
Tip #335 - Copy C++ function declaration into implementation file : vim online
".SaveL."G"
".SaveC."|"
f(b'
i'.s:ClassName.'::'
" find the ending ; and replace it with a brace structure on the next line.
:execute ":normal! f;s\<cr>{\<cr>}\<cr>\<esc>kk"
endif
endfunc
"}}}
"*****************************************************************
"* Commands
"*****************************************************************
" given:
"
virtual void Test_Member_Function_B3(int _iSomeNum2 = 5, char * _cpStr = "Yea buddy!");
" Prototype:
"GrabFromHeaderPasteInSource(VirtualFlag, StaticFlag, DefaultParamsFlag)
" VirtualFlag:
" 1:
if you want virtual commented in the implimentation:
"
/*virtual*/ void Test_Member_Function_B3(int _iSomeNum2 = 5, char * _cpStr = "Yea buddy!");
" else:
remove virtual and any spaces/tabs after it.
"
void Test_Member_Function_B3(int _iSomeNum2 = 5, char * _cpStr = "Yea buddy!");
" StaticFlag:
" 1:
if you want static commented in the implimentation:
"
Same as virtual, save deal with static
" else:
remove static and any spaces/tabs after it.
"
Same as virtual, save deal with static
"
"
"
"
"
"
DefaultParamsFlag:
1:
If you want to remove default param reminders, i.e.
Test_Member_Function_B3(int _iSomeNum2, char * _cpStr);
2:
If you want to comment default param assignments, i.e.
Test_Member_Function_B3(int _iSomeNum2/*= 5*/, char * _cpStr/*= "Yea buddy!"*/);
3:
Like 2 but, If you do not want the = in the comment, i.e.
Tip #335 - Copy C++ function declaration into implementation file : vim online
"
Test_Member_Function_B3(int _iSomeNum2/*5*/, char * _cpStr/*"Yea buddy!"*/);
"
" Examples:
" smallest implimentation:
"
void Test_Member_Function_B3(int _iSomeNum2, char * _cpStr);
":command! -nargs=0 GHPH call <SID>GrabFromHeaderPasteInSource(0,0,1)
"
Verbose...:
"
/*virtual*/ void Test_Member_Function_B3(int _iSomeNum2/*5*/, char * _cpStr/*"Yea buddy!"*/);
":command! -nargs=0 GHPH call <SID>GrabFromHeaderPasteInSource(1,1,3)
"
What I like:
"
void Test_Member_Function_B3(int _iSomeNum2/*5*/, char * _cpStr/*"Yea buddy!"*/);
:command! -nargs=0 GHPH call <SID>GrabFromHeaderPasteInSource(0,0,3)
" Bit of trivia... GHPH.. get header, put header. ~shrug~ I needed a
" command name.... (Name it whatever you wish, of course!)
" eof
<<<copycppdectoimp.vim
hermitte at free.vim, October 7, 2002 15:36
Several things can still be improved :
* There is no need for using registers
* We can easily find the class name (if any) -- easy because I'd already done this for my set of C++
ftplugins
* We can accept prototypes written on several lines (this first version only supports parameters
written on several lines).
There are still some other things that can be done to improve this _ft_plugin, but here is a first
(third) shot.
<=== cut from here
if exists("b:loaded_copycppdectoimp")
let b:loaded_copycppdectoimp = 1
| finish | endif
Tip #335 - Copy C++ function declaration into implementation file : vim online
Tip #335 - Copy C++ function declaration into implementation file : vim online
Tip #335 - Copy C++ function declaration into implementation file : vim online
" }}}
let &cpo=s:cpo_save
"======================================================================
" vim60:fdm=marker
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #336 - type the line number and press enter to get there : vim online
Home
Search
Tip #336: type the line number and press enter to get there
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Copy C++ function declaration into implementation file | editing remote files via scp in vim >>
Additional Notes
steveaa@icgate.net, October 3, 2002 7:42
Tip #336 - type the line number and press enter to get there : vim online
A corollary:
Though
:132[Enter]
takes you to line 132 in the file,
132[Enter] takes you 132 lines down from your present
position.
It's a subtle difference that can make a big
difference.
Anonymous, October 14, 2002 10:48
if u want to go 123 lines down u can use either
123 <DOWN>
either
123j
so wy have three times the same thing???
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #337 - editing remote files via scp in vim : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<type the line number and press enter to get there | vim + cscope + cygwin >>
Additional Notes
nickm(at)mail.sochi.ru, October 14, 2002 13:41
Good tip!
ps RTFM ;-)
as_krishna@hotmail.com, December 24, 2002 0:25
Does the same work for FTP as well?.
When I try to do it using ftp am not able to open the
file(yes, it exists on the server!), but vim returns an error
saying 4 lines filtered and some information about not being
able to open a file in the tmp directory
TIA,
kris
tevfik, March 20, 2003 12:56
I need ftp too...
Tip #337 - editing remote files via scp in vim : vim online
http://www.erols.com/astronaut/vim/index.html#vimlinks_scripts
as "Network Oriented Reading and Writing"
has several improvements. Later Windows' ftp is handled, new
protocols
(rsync, cadaver, fetch), user fixup functions, etc.
gaita@uv.es, July 4, 2003 8:46
The tip is great. I have been looking for a way to work
remotely like this for months
(well, admittedly not looking very much, but really wanting
it!).
I just would need an extra feature which doesn't seem to work:
:E in the remote file is not able to navigate through the
remote folder.
Anyone knows if this should work?
Thanks!
tilman@ucsd.edu, July 5, 2003 11:45
I was wondering if anyone knew how to edit files remotely as
described above but manually specifying the port to be used by
scp.
I have an ssh server running on a different port and am not
sure if this is supported by vim.
Any advice?
thanks
seanahern@llnl.gov, September 2, 2003 17:44
Yes.
bit.
Tip #337 - editing remote files via scp in vim : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
JavaCoder, October 4, 2002 10:57
Does anyone know if there's a cscope for Windows? I'd
surely love to use it directly under Windows (not in
Cygwin).
perd, October 6, 2002 19:23
There is cscope for windows, but the problem doesn't
lie in cscope, it lies in vim's integration with
cscope. It uses a few apis that are only available w/
cygwin.
JavaCoder, October 9, 2002 7:42
Where can I find cscope for windows?
Brian K, October 15, 2002 14:33
Another alternative is to install the XFree86 packages
that are part of the Cygwin distribution
(http://xfree86.cygwin.com/). I installed that along
with the WindowMaker window manager. I then downloaded
the vim Unix source and edited the src/Makefile. I
uncommented:
CONF_OPT_CSCOPE = --enable-cscope
and
CONF_OPT_GUI = --enable-gui=motif
I rebuilt vim and installed it to /usr/bin/vim. I can
now use cscope on Windows by running gvim (vim -g) in
WindowMaker session.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Additional Notes
interfac@hotmail.com, October 9, 2002 0:59
Unfulfilling
rate
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
visual map
your choice
yank selected text
search delimiter
no magic, just text
expression
substitute "\n" for "\\\\n"
escape '/' (delimiter) and '' in yanked text
end expression
search
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Chris Butler, October 11, 2002 14:23
Sorry, something was lost when I pasted it (besides the
line format :)
The substitute string is '/' - that's forward slash +
backward slash.
One needs to escape any '' (backslash) to nulify any
specials.
Chris Butler, October 11, 2002 14:25
Let try that again ...
Sorry, something was lost when I pasted it (besides the
line format :)
The substitute string is '/\' - that's forward slash +
backward slash.
One needs to escape any '\' (backslash) to nulify any
specials.
David Fishburn, June 4, 2003 5:51
I have this in my vimrc file.
It will deal with correctly escaping the string you
have visually selected.
This was hashed out on the vim mailing list a few
months back, and this is the final version.
It also maintains the register we pull the text into.
" Courtesy of Michael Naumann, Jrgen Krmer
" Visually select text, then search for it, forwards or
backwards
vmap <silent> * :<C-U>let old_reg=@"<cr>
\gvy/<C-R><C-R>=substitute(
\escape(@", '\\/.*$^~[]'), "\n$", "",
"")<CR><CR>
\:let @"=old_reg<cr>
vmap <silent> # :<C-U>let old_reg=@"<cr>
\gvy?<C-R><C-R>=substitute(
\escape(@", '\\/.*$^~[]'), "\n$", "",
"")<CR><CR>
\:let @"=old_reg<cr>
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: intermediate
as of Vim: 6.0
Site Help
let SwitchSchemesFiles =
globpath("$VIMRUNTIME,$HOME/.vim","colors/*.vim")
let SwitchSchemesIndex = 0
function! SwitchSchemes()
let sep="\n"
if g:SwitchSchemesIndex == -1
let g:SwitchSchemesIndex=0
endif
exe "source " .
NextElement(g:SwitchSchemesFiles, sep,
g:SwitchSchemesIndex)
let g:SwitchSchemesIndex =
NextIndex(g:SwitchSchemesFiles, sep,
g:SwitchSchemesIndex + 1)
endfunction
In addition you need the
http://www.vim.org/script.php?script_id=109
Put it in the plugin directory.
If you use e.g. a map to F12, you can easily switch
between all
installed themes:
map <f12> :call SwitchSchemes()<CR>
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Anonymous, April 25, 2003 4:52
It might also be useful to output the name of the color
scheme after changing it, something like this:
nmap <C-F12> :call SwitchSchemes()<CR>:echo
g:colors_name<CR>
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Anonymous, October 12, 2002 11:58
I have remapped Caps Lock to Esc. Who use Caps Lock any
way?
Anonymous, October 12, 2002 15:00
I think users with german, slavic (and probably some
other) keyboards will have better things to do with the
windows key - because we need additional keys for
"umlauts" like etc. or other language-specific
letters, some of the important signs, namely {[]}\ are
the "third-function" of number keys 7 and above. You
have to type those with the right hand, while
simultaneously pressing "Alt Ctr" located right of the
spacebar which at least I never learned to do properly,
you can't do that without changing the position of the
hand, and I keep hitting the wrong key. I've been
raging about this stupid mapping for a long time
without it ever occurring to me that there's a free key
you could map to Alt Ctr and use it with your left
hand. So I guess not only the mapping is stupid.
Cheers
Horror Vacui
Anonymous, October 12, 2002 19:09
I don't understand the term "useless", if XFree86 is
configured correctly for a 104 key PC keyboard, the
penguin keys are mapped to Meta_L and Meta_R and the
Menu key is mapped to Menu. No need to use xmodmap.
Anonymous, October 13, 2002 8:11
Doh... useless for a vim user...
mrts, October 14, 2002 2:38
Horror Vacui:
why don't you map
* left winkey -> {
* shift+left winkey -> [
* right winkey -> <ESC>
* right winmenu -> }
* shift+right winmenu ]
Solves all my problems :)
mrts
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
"
undolevels=-1 (no undo possible)
let g:LargeFile = 1024 * 1024 * 10
augroup LargeFile
autocmd BufReadPre * let
f=expand("<afile>") | if getfsize(f) > g:LargeFile | set
eventignore+=FileType | setlocal noswapfile
bufhidden=unload buftype=nowrite undolevels=-1 | else |
set eventignore-=FileType | endif
augroup END
endif
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Remap <ESC> | Cut / Copy / Delete / Paste Lines without knowing the number of lines >>
Additional Notes
maxiangjiang@yahoo.com, October 13, 2002 18:50
Can we just set scratch buffer for such purpose?
help special-buffers
Yakov, July 22, 2003 6:15
File will load faster if you open it read-only: vim -R
HugeFile.txt
BigUser, December 15, 2003 17:24
Try to open a 2 Gig text file. It takes to long and
uses all my systems memory.
Looking for a solution.....
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #344 - Cut / Copy / Delete / Paste Lines without knowing the number of lines : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #344: Cut / Copy / Delete / Paste Lines without knowing the
number of lines
tip karma
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Faster loading of large files | Visual Studio + vim Quickfix mode + cygwin + XFree86 >>
Additional Notes
tunacat@yahoo.com, October 15, 2002 18:13
Be sure to check out visual mode. V will allow to
select a range of lines, which you can then "ay, etc.
This is one of the coolest features of vim.
Tip #344 - Cut / Copy / Delete / Paste Lines without knowing the number of lines : vim online
Tip #344 - Cut / Copy / Delete / Paste Lines without knowing the number of lines : vim online
An easier-to-remember way:
Forget about registers.
Go to desired start line,
hit
ma ("mark this line as 'a'"), then go to desired
end line, and hit
y'a or d'a ("yank or delete to
the line marked 'a'"). Paste using p.
A character-level way: (not line-level)
Go to desired start character, hit
ma (same as
above), then go to desired end character (can be in a
different line), and hit
y`a or d`a (notice that
it's the "tick", not the "apostrophe"). Paste using p.
lylez@kc.rr.com, January 21, 2003 21:31
If you need to select a series of consecutive lines,
type V}
Lyle
Anonymous, January 20, 2004 6:50
I don't get it. Why would I use this incredibly
convoluted method instead of just using visual mode?
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #345 - Visual Studio + vim Quickfix mode + cygwin + XFree86 : vim online
Home
Search
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
- perl
- cygutils
- bash
2. Set up Visual Studio to support command line
compiles.
Basically this involves adding paths to the
PATH, INCLUDE, and LIB environment variables. See
vcvars32.bat in the Visual Studio VC98/bin directory for
guidelines.
3. Export a makefile for your dsp project file via the
Visual Studio "Project|Export Makefile..."
4. Create the cygwin shell script defined below.
the script in '/bin/dovcmake'
---begin cut----#!/bin/bash
# This script takes output from
# Visual Studio's nmake and reformats
# it so that it can be parsed by
# cygwin's vim default errorformat
# setting
nmake /F $1 2>&1 | perl -n -e \
' chomp;
Put
Tip #345 - Visual Studio + vim Quickfix mode + cygwin + XFree86 : vim online
if(/^([a-z]:[^(]+)\((\d+)\)(.+)$/i) {
$f = $1; $l = $2; $m = $3;
$f =~ s/\\/\//g;
$cyp = `cygpath -au $f`; \
chomp $cyp;
print qq{"$cyp",$l:$m\n};}
elsif(/error/i) {
print qq{$_\n};
}'
---end cut ----5.
set makeprg=/bin/dovcmake
map <f7> :make <c-r>%<cr>
6. Fire up cygwin vim and open the makefile from step
3. If you hit F7, you'll automatically start a Visual
Studio build and you'll be able to step through compiler
errors via the :cp and :cn commands.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Cut / Copy / Delete / Paste Lines without knowing the number of lines | Wrap text in HTML/XML
tags after prompting for the tag name >>
Additional Notes
Anonymous, October 16, 2002 1:09
You should look at the errorformat variable. This may
solve your problem without perl.
Brian K, October 16, 2002 13:47
I needed to use perl because I needed to convert
windows paths from nmake's output to cygwin
paths. Otherwise I would have used errorformat
Anonymous, December 2, 2002 6:54
You could use Cygwin's cygpath to translate between
Cygwin (posix) and windows paths instead of Perl.
Brian K, December 3, 2002 11:21
Tip #345 - Visual Studio + vim Quickfix mode + cygwin + XFree86 : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #346 - Wrap text in HTML/XML tags after prompting for the tag name : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #346: Wrap text in HTML/XML tags after prompting for the tag
name
tip karma
complexity: basic
as of Vim: 6.0
Tip #346 - Wrap text in HTML/XML tags after prompting for the tag name : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Visual Studio + vim Quickfix mode + cygwin + XFree86 | Format paragraph without changing the
cursor position >>
Additional Notes
wl1012@excite.com, February 18, 2003 9:50
With XML namespace that contains a ":", the first
substitute doesn't really work as desired. It may be
changed to the following (note using the \S instead of
a \w):
function! TagSelection()
let l:tag = input("Tag name?")
" exec "normal `>a</" . l:tag . ">\e"
" Strip off all but the first work in the tag for the
end tag
exec "normal `>a</" .
\ substitute( l:tag, '[
\t"]*\(\<\S*\>\).*', '\1>\e', "" )
exec "normal `<i"
\ substitute( l:tag, '[ \t"]*\(\<.*\)',
'<\1>\e', "" )
endfunction
Add Note
Tip #346 - Wrap text in HTML/XML tags after prompting for the tag name : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #347 - Format paragraph without changing the cursor position : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Wrap text in HTML/XML tags after prompting for the tag name | Quickly insert a single word >>
Additional Notes
Anonymous, October 23, 2002 1:20
Why not simply use <C-O> after gq command?
Kartik, October 23, 2002 17:52
Hmm... let me try to describe a case. Let's say you
open a text file and start inserting text somewhere in
between without ever adding to the jump list (just
arrow keys, '{}'). Now typing <Esc> gqap <C-o> doesn't
restore cursor position. At least for me.
Anonymous, October 24, 2002 6:33
Ok, mea culpa - I always used gq}, and it worked. The
gqap is different.
ds26@gte.com (Dorai Sitaram), March 13, 2003 11:47
Tip #347 - Format paragraph without changing the cursor position : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Format paragraph without changing the cursor position | Format your xml document using xmllint >>
Additional Notes
mark@summersault.com, October 23, 2002 8:33
Unless I missed something, this doesn't save any
keystrokes. Without, I would use two keystrokes "i" to
enter insert mode and ESC to exit. Here I still would
still need two keystokes "," and "w".
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #349 - Format your xml document using xmllint : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Quickly insert a single word | when 'formatoptions' has o easily enter a non commented line: go/gO mappings >>
Additional Notes
Anonymous, October 24, 2002 14:11
will this work in win2k version of gvim?
maxiangjiang@homail.com, October 29, 2002 16:59
How can make it as a filter?
I tried sth like
let&l:equalprg='xmllint --format --recover'
but it didn't work since xmllint doesn't take STDIN?
any idea?
dean at mndsolutions dot de, November 8, 2002 9:47
http://www.vim.org/tips/tip.php?tip_id=349 (1 of 4) [18/02/2004 14:55:02]
Tip #349 - Format your xml document using xmllint : vim online
Tip #349 - Format your xml document using xmllint : vim online
Tip #349 - Format your xml document using xmllint : vim online
http://www.pinkjuice.com/howto/vimxml/tasks.xml#validation
Tobi
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #350 - when 'formatoptions' has o easily enter a non commented line: go/gO mappings : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
<<Format your xml document using xmllint | Using quickfix in a different way >>
Additional Notes
Feral <Sreny@SverGbc.Pbz> (Rot13ed), June 1, 2003 3:35
rate
Tip #350 - when 'formatoptions' has o easily enter a non commented line: go/gO mappings : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<when 'formatoptions' has o easily enter a non commented line: go/gO mappings | disabling cabbrev
>>
Additional Notes
Anonymous, November 6, 2002 7:21
In your vimrc file add:
ia prtf fprintf(fdebug, "%0s:%0d\n", __FILE__,
__LINE__) ;
to make this macro part of vim aliases in "insert"
mode.
Anonymous, November 6, 2002 7:33
One disadvantage of having fprints scattered all over
the code is, after debugging, you got to remove them.
If you have defined a macro instead, you can easily
(re)define it to null..
Btw, if you want to debug shell
scripts/perl/tcl/whatever, consider getting yourself a
generic preprocessor. I found filepp
(http://www.cabaret.demon.co.uk/filepp/) pretty good.
No vim stuff.. anyways..
- Karthick
Anonymous, November 6, 2002 16:12
The advantage of the alias is that you can modify the
expanded alias to suite your need at point of
insertion.
ie.
fprintf(fdebug, "%0s:%0d\n >>> the variable i am
interested = %d<<<", __FILE__, __LINE__,
variable_in_question) ;
I work in embedded system and a lot of time our only
debugging tool for code is printf. Not all of us have
in circuit emulators available to us.
And like you said, this is debugging.
The code does not go live with debugging statements,
they are removed.
http://www.vim.org/tips/tip.php?tip_id=351 (2 of 3) [18/02/2004 14:55:07]
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Using quickfix in a different way | Swap caps-lock and control keys using MS Windows Registry >>
Additional Notes
Kartik, October 24, 2002 22:11
Does anybody have a better way to disable cabbrev's?
The vim docs (a little above help abbreviate-local) say
pressing <C-v> twice somewhere within the abbrev avoids
expanding it. Doesn't work for me, though. Pressing <Cv><Space> works in the ':' prompt, but not while
searching - what if I don't want to include a space in
the pattern?
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #353 - Swap caps-lock and control keys using MS Windows Registry : vim online
Home
Search
Tip #353: Swap caps-lock and control keys using MS Windows Registry
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
This will allow you to use the caps-lock key as a control key. Makes using vim in
win32 much nicer in my opinion.
Place the following text into a text file with the extension *.reg and update
your registry by double-clicking the file:
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
Life Changing
Helpful
Unfulfilling
rate
<<disabling cabbrev | Find in files - recursively (NOT :grep!). Only for unix clones. >>
Additional Notes
digitect (at) mindspring com, October 29, 2002 18:58
Tip #353 - Swap caps-lock and control keys using MS Windows Registry : vim online
I'd suggest, if the text above is copied into a file "caps2ctrl.reg", also
making a file "un-caps2ctrl.reg" in which you place the following:
---------------------------------------------------------------------REGEDIT4
[-HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
---------------------------------------------------------------------This gives you a way to reverse things if you don't like it. ;)
bhl at bigredswitch.com, November 1, 2002 12:04
This site has an explanation on what's going on here:
http://www.annoyances.org/exec/forum/winxp/t1004806455
This
j r p e t i t AT y @ h o o . c o m, November 27, 2002 11:45
Quick addendum to my tip. The registry entry above sets the caps to ctrl. The
following registry entry actually swaps the caps-lock and registry keys on your
keyboard. Useful if you like using caps-lock from time to time.
Remember, to undo this, just delete this entry and your system will revert to
the default behavior.
-- Jacques
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode
Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,1d,00,3a,00,3a,00,1d,00,00,00,00,00
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #354 - Find in files - recursively (NOT :grep!). Only for unix clones. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #354: Find in files - recursively (NOT :grep!). Only for unix
clones.
tip karma
complexity: basic
as of Vim: 5.7
Tip #354 - Find in files - recursively (NOT :grep!). Only for unix clones. : vim online
Tip #354 - Find in files - recursively (NOT :grep!). Only for unix clones. : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Swap caps-lock and control keys using MS Windows Registry | Comment Lines according to a
given filetype >>
Additional Notes
ctechols@mindspring.com, October 30, 2002 4:55
I don't know about grep on HP-UX, but GNU grep *can*
recurse into directories using either the "-d recurse",
or "--recursive" options.
stonnedsnake@yahoo.com, October 30, 2002 21:05
Mea culpa. Maxima culpa. The version of grep I have in
HP does *not* have the "-d recurse" feature, but yes,
the GNU grep has, and I have the GNU grep now. Thanks
for the information.
- Karthick.
PS: Is there a way to remove a tip from these archives?
Anonymous, November 16, 2002 18:02
You can even abbreviate that as -r for GNU grep. I
often do something like
grep -r 'some_func(' .
Really convenient.
shawn at deleurme dot calm., June 13, 2003 12:57
or, if you can't get GNU grep (which you should) you
can always use:
find . | xargs grep whatever
Tip #354 - Find in files - recursively (NOT :grep!). Only for unix clones. : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Find in files - recursively (NOT :grep!). Only for unix clones. | Quick yank and paste >>
Additional Notes
hermitte at free.fr, October 30, 2002 11:29
Why don't you use EnhancedCommentify or
ToggleCommentify ?
They do work fine, they are maintained, extensible,
etc.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
<C-Space> "ay
<C-Space> "aP
<C-Space> <C-o>"ap
<C-c> "ayiw
Niels
My vimrc if you're interested:
http://home.student.utwente.nl/n.h.m.aandebrugh/_vimrc
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Anonymous, November 16, 2002 18:04
You might want to post that to http://www.dotfiles.com
also. (And have a look around there of course.)
Breadman, July 31, 2003 20:15
<C-c>
<C-c>
<C-p>
<C-p>
<C-p>
"py
"pyiw
"pp
"pP
<Esc>"ppa
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: advanced
as of Vim: 6.0
mode
" with the partial command ":Gdb " typed out.
" The following line shows what doesn't work
" call input(":Gdb ")
endif
endfunction
"1.d) And while we are modifying gdbvim.vim, we could
also
"
add a text section to the definitions of the
signs:
"-------------------------------------------------------sign define breakpoint linehl=DebugBreak
text=bb
sign define current
linehl=DebugStop
text=cc
#2) The subroutine worker in the perl script gdbvim
needs to
#
be modified as indicated below. The key points to
note
#
are the two calls the vim-script function
Gdb_Console().
# this function processes the gdb output, prints it and
sends vim commands
sub worker # {{{
{
vim_call('Gdb_interf_init(\"'.$PIPE.'\",
\"'.$ENV{"PWD"}.'\")');
print GDB_WTR "set prompt (gdb)\\n\n";
while (<GDB_RDR>)
{
if (/^.*?gdb\)/)
{
print RL_WTR "READ\n";
chomp ;
print $_ . " ";
vim_call("Gdb_Console(\\\"$_\\\", 1)");
}
else
{
my $stuff = $_;
if(
s/Breakpoint ([0-9]+) at 0x.*: file
([^,]+), line ([0-9]+)./Gdb_Bpt($1,\\\"$2\\\",$3)/ ||
s/Breakpoint ([0-9]+), 0x.*at
([^,]+):([0-9]+)/Gdb_CurrFileLine(\\\"$2\\\",$3)/ ||
s/^\s*0x.*\s+at\s+(\S+):([09]+)/Gdb_CurrFileLine(\\\"$1\\\",$2)/ ||
s/\032\032([^:]*):([09]+).*/Gdb_CurrFileLine(\\\"$1\\\", $2)/ ||
s/^\s*0x\S+\s*([09]+)\s+.*/Gdb_CurrFileLine(0, $1)/
)
{
chomp;
vim_call($_);
}
print $stuff;
chomp($stuff);
# the next substitution is because I
couldn't figure out how to
# pass (from perl) double quotes inside
string arguments to
# vim-script functions
$stuff =~ s/"/'/g;
vim_call("Gdb_Console(\\\"$stuff\\\",
0)");
}
}
vim_call("Gdb_interf_close()");
close GDB_RDR; close GDB_WTR;
}; # }}}
That's all the modifications -- and now gdbvim will show
the output of gdb inside a vim. (Errors from gdb won't
show up in the console but still go to the terminal.)
Happy gdbVimming!
Acknowledgment:
I learnt about functions in vim-scripts by the
process of tracking
down an annoying behavior in cvscommand.vim vimscript
#90.
Also, the author of cvscommand.vim, Bob Hiestand,
graciously
improved my earlier versions of the functions
GdbFoucBuf and
GdbAppendBuf.
rate this tip
Life Changing
Helpful
Unfulfilling
<<Quick yank and paste | Get a random colorscheme on vim startup >>
Additional Notes
rate
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Adding a console to gdbvim | Download RedHat RPMS of the latest and greatest version of VIM. >>
Additional Notes
madokam@zag.att.ne.jp, November 4, 2002 3:44
Ah! A backward slash has disappeared on the script
line 5.
Please correct the line
let s:colors = substitute(s:colors, '', '/', 'g')
to:
let s:colors = substitute(s:colors, "\\", '/', 'g')
Sorry.
madokam@zag.att.ne.jp, October 14, 2003 3:53
I've made a slight improvement:
" Create the comma-separated list of colorscheme files
let s:colors = substitute(globpath(&runtimepath,
'colors/*.vim'), '\n', ',', 'g')
if strlen(s:colors)
" Count the number of color schemes
let s:num = strlen(substitute(s:colors, '[^,]\+', '',
'g')) + 1
if s:num > 1
let s:loop = localtime() % s:num
" Rotate the list s:loop times
while s:loop
let s:colors = substitute(s:colors,
'^\([^,]\+\),\(.*\)$', '\2,\1', '')
let s:loop = s:loop - 1
endwhile
http://www.vim.org/tips/tip.php?tip_id=358 (2 of 3) [18/02/2004 14:55:23]
endif
let s:color = matchstr(s:colors, '^[^,]\+')
unlet! g:colors_name
execute 'source' s:color
" Prevent the message from disappearing
redraw
echomsg 'Color applied: '.(exists('g:colors_name') ?
g:colors_name : '').' ('.s:color.')'
endif
unlet! s:colors s:color s:num s:loop
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #359 - Download RedHat RPMS of the latest and greatest version of VIM. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Tip #359: Download RedHat RPMS of the latest and greatest version
of VIM.
tip karma
complexity: basic
as of Vim: 6.0
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<Get a random colorscheme on vim startup | ':e <dir>' enter files and directories >>
Additional Notes
jeremy@nirvani.net, November 4, 2002 21:09
I am the maintainer of these RedHat VIM RPMS. My plan
is to keep them up to date with the latest and greatest
version of vim. Check back often, or whenever there is
a new version of VIM.
Download link to VIM RedHat RPMS:
http://nirvani.org/software/vim/
Jeremy Brand, B.S.
max@malva.ua, November 5, 2002 5:49
Would you mind to put .nosrc.rpm or a .spec-file as
well?
jeremy@nirvani.net, November 7, 2002 23:00
Tip #359 - Download RedHat RPMS of the latest and greatest version of VIM. : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #360 - ':e <dir>' enter files and directories : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
You can directly enter files with ':e filename', but did
you know you can 'enter' directories that way ?
e.g. ':e ..' opens a buffer window with the entries of
the parent directory.
If you then double click on an entry the directory is
opened in the same way (if it's a directory)
or the file is opened for editing (if it's a file).
(Don't ask me, if it's normal vim behaviour or the
effect of any script.)
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Download RedHat RPMS of the latest and greatest version of VIM. | Use xdvi (or kdvi) in
conjunction with gvim (or vim) and converse >>
Additional Notes
Anonymous, November 6, 2002 7:38
See also ":help :Explore" and ":help :Sexplore"
zzapper@ntlworld.com, November 6, 2002 9:48
Tip #360 - ':e <dir>' enter files and directories : vim online
:e ..
also
:Ex
:Sex
does the same in split Window (& not Thailand)
all part I presume of bufexplorer.vim (recently
updated)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #361 - Use xdvi (or kdvi) in conjunction with gvim (or vim) and converse : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #361: Use xdvi (or kdvi) in conjunction with gvim (or vim) and
converse
tip karma
complexity: intermediate
as of Vim: 6.0
Tip #361 - Use xdvi (or kdvi) in conjunction with gvim (or vim) and converse : vim online
Life Changing
Helpful
Unfulfilling
rate
<<':e <dir>' enter files and directories | matchit.vim and coldfusion (and perhaps others) >>
Additional Notes
Anonymous, November 19, 2002 23:04
Seems it doesn't work for multiple tex source files.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Tip #361 - Use xdvi (or kdvi) in conjunction with gvim (or vim) and converse : vim online
Logo
Tip #362 - matchit.vim and coldfusion (and perhaps others) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Hi VIMmites
I couldn't get any tags to match in Coldfusion files
*.cfm either HTML Javascript or ColdFusion tags
themselves <cfif ..> ... </cfif>
Much pain was gone thru before I realised that the
Syntax File for ColdFusion
(/syntax/cf.vim) was called cf and not cfm
Therefore in matchit.cfm I need to add CF in following
line and NOT CFM
au FileType html,jsp,php,cf if !exists("b:match_words")
|
zzapper
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Use xdvi (or kdvi) in conjunction with gvim (or vim) and converse | Starting up Vim very fast
expecially from a telnet session >>
Additional Notes
zzapper@ntlworld.com, November 7, 2002 6:18
I meant edit matchit.vim (not matchit.cfm)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #363 - Starting up Vim very fast expecially from a telnet session : vim online
Home
Search
Tip #363: Starting up Vim very fast expecially from a telnet session
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<matchit.vim and coldfusion (and perhaps others) | Automatic file type detection with fully qualified
ClearCase names >>
Additional Notes
hkraenz@mdli.com, November 19, 2002 3:34
Tip #363 - Starting up Vim very fast expecially from a telnet session : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #364 - Automatic file type detection with fully qualified ClearCase names : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #364: Automatic file type detection with fully qualified ClearCase
names
tip karma
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Starting up Vim very fast expecially from a telnet session | Vim Book Online >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Site Help
<<Automatic file type detection with fully qualified ClearCase names | really basic RCS interaction from
within vim >>
Additional Notes
chris@nominet.org.uk, November 12, 2002 2:29
It's a pity the sidebar with the contents doesn't
display properly in Opera. Even IE complains that
there is an error in the Javascript...
Anonymous, November 13, 2002 8:17
I found this under the Documentation Link on
vim.sourceforge.net
http://www.truth.sk/vim/vimbook-OPL.pdf
Anonymous, November 18, 2002 7:08
Or, ofcourse, http://www.vim.org/docs.php
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #366 - really basic RCS interaction from within vim : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
:write %<CR>:!ci -l
:!co -l %<CR>:edit!<CR>
New RCS files work just fine with the first mapping.
There would be some use to creating the RCS directory,
if it's not already there, but I don't see an "if exists
and is directory" function, right now.
There's a good menu-driven rcs client for graphical
vim, but I hate menus and graphical interfaces.
rate this tip
Life Changing
Helpful
Additional Notes
Unfulfilling
rate
Tip #366 - really basic RCS interaction from within vim : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
"macros/README.txt"
menu.vim :- Default Menus
mswin.vim :- sets options for Vim to behave like
Windows.
optwin.vim :- commands to create option window.
plugin :- Contains plugins. All .vim files in this
directory are automatically sourced.
scripts.vim :- helps detect filetype in Vim scripts.
syntax :- Contains Syntax defination files for various
programming languages.see ":help syntax"
tools :- Some useful tools. like blink to blink the
cursor in xterm.
tutor :- Contains tutor.vim. see ":help tutor"
vim32x32.xpm :- Vim Logo.
vimrc_example.vim :- again name says it all.
~
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<really basic RCS interaction from within vim | Use gvim in VS.Net >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
narayanpavgi@hotmail.com, January 22, 2003 4:46
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
tomte@subdimension.com, November 15, 2002 3:55
There are a few scripts here already, that will do the
same in a more general way, nevertheless I'd suggest
the following changes
let comment="// "
in Comment() for better readability
and
let cl2=substitute(cl, "^\s*// ", "", "")
in UnComment() to ensure the comment will only be
replaced at the beginning of a line.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Comment/UnComment visually selected text | Encrypting a file within vim session and not leaving
behind traces. >>
Additional Notes
Dubhead, November 15, 2002 1:05
Oops, please remove that semicolon at the end of the
'if' line. I'm sorry.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #371 - Encrypting a file within vim session and not leaving behind traces. : vim online
Tip #371: Encrypting a file within vim session and not leaving behind traces.
Home
Search
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<always cd to the current file's directory | Remove unwanted empty or blank lines for english and chinese >>
Additional Notes
sorry, no spam please, November 20, 2002 23:22
Tip #371 - Encrypting a file within vim session and not leaving behind traces. : vim online
There are a lot of other vim settings to make sure you leave no trace
behind like swapfiles, backupfiles, etc.
I once investigated these settings and set up a gvimrc file for editing
files containing
e. g. a collection of 'secret' information like passwords, ident
numbers, etc..
I copied this encrypted file, gvimrc, and the program files (gvim.exe)
on a 3.5" Floppy,
which makes you 'autarkic'.
I'm trying hard not to forget copying the settings to the VIM tips.
Does anybody know how 'safe' is gvim encryption ?
Thomas
vim_power, November 21, 2002 11:29
from VIM help files.
- The algorithm used is breakable. A 4 character key in about one hour,
a 6
character key in one day (on a Pentium 133 PC). This requires that
you know
some text that must appear in the file. An expert can break it for
any key.
When the text has been decrypted, this also means that the key can be
revealed, and other files encrypted with the same key can be
decrypted.
- Pkzip uses the same encryption, and US Govt has no objection to its
export.
Pkzip's public file APPNOTE.TXT describes this algorithm in detail.
- Vim originates from the Netherlands. That is where the sources come
from.
Thus the encryption code is not exported from the USA.
Anonymous, December 4, 2002 4:03
I am using these settings in a _gvimrc on a disc (containing gvim.exe
and vimrun.exe) for keeping secrets secret:
"/*===================================================================*/
" Eintrge fr Editieren von Pawortgeschtzten Dateien (':X'):
" keine Swap- oder temp files verwenden:
set noswapfile
set nobackup
set nowritebackup
" kein info file mit history eintraegen:
set viminfo=
"/*===================================================================*/
Of course the RAM and the swapfile of Windows still may be read in plain
ASCII / hex by spies.
Thomas
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #371 - Encrypting a file within vim session and not leaving behind traces. : vim online
Tip #372 - Remove unwanted empty or blank lines for english and chinese : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #372: Remove unwanted empty or blank lines for english and
chinese
tip karma
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Encrypting a file within vim session and not leaving behind traces. | Run find/replace/search on
multiple files and subdirectories >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #373 - Run find/replace/search on multiple files and subdirectories : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Tip #373 - Run find/replace/search on multiple files and subdirectories : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Remove unwanted empty or blank lines for english and chinese | VIM's Filtering Commands
Summary >>
Additional Notes
Anonymous, November 25, 2002 3:48
See :args and :argdo
Anonymous2, December 3, 2002 12:55
How to use :args to search recursive in subdirectories?
Anonymous, March 4, 2003 5:19
you can use something like this:
:args *.cpp */*.cpp */*/*.cpp
Not exactly *recursive*, but works well for reasonably
flat directory hierarchies.
raghuramvemuri@yahoo.com, June 18, 2003 10:26
Fantastic Tip. Saved me a lot of time.
I had put the [ ! ] after the bufdo command so it would
move on to the next buffer.
gvim --servername BEAD --remote-send "<ESC>:bufdo!
%%s/Tweety Bird/Road Runner/ge<CR>"
Thanks.
Add Note
Tip #373 - Run find/replace/search on multiple files and subdirectories : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
: redirect to a file
: end redirect
Life Changing
Helpful
Unfulfilling
rate
<<Run find/replace/search on multiple files and subdirectories | autocmd for skeleton html file
(BufFileNew) >>
Additional Notes
david@tvis.co.uk, November 24, 2002 14:59
Ahem I meant filtered from vimtip #305 of course
Anonymous, November 26, 2002 23:18
to sort the actual paragraph at cursorposition from
normal mode with external sort program (-u deletes
multiple lines):
!1} sort -u
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #375 - autocmd for skeleton html file (BufFileNew) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
How about starting your new html document with a nice shiny skeleton!
Add this in your autocmd section in your .vimrc file
" Start with an html skeleton docuement when opening a new *.html file
au BufNewFile *.html | execute "normal :set ai!\<kEnter>i<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transiti
onal//EN\">\<kEnter><html>\<kEnter> <head>\<kEnter>
<style>\<kEnter>
</style>\<kEnter>
<script>\<kEnte
r>
</script>\<kEnter> </head>\<kEnter> <body>\<kEnter> </body>\<kEnter></html>\<ESC>:set ai\<kEnter>gg"
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
bigredlinux at yahoo.com, November 25, 2002 12:26
The tip added endlines where they are not supposed to be...please remove all endlines so that the command list just a single line.
david@tvis.co.uk, November 26, 2002 2:36
Slight Variant (without tabs/spaces)
au BufNewFile *.html | execute "normal
:\<kEnter>i\<html>\<kEnter><head>\<kEnter><title>title</title>\<kEnter><script>\<kEnter></script>\<kEnter></head>\<kEnter><body>\<kEnter></body>\<kEnter></html>\<ESC>gg"
perry.tew cibavision.novartis.com, October 21, 2003 11:59
I added some spaces to make the indentation a little prettier:
au BufNewFile *.html | execute "normal :\<kEnter>i\<html>\<kEnter>
<head>\<kEnter>
<title></title>\<kEnter>
<script
language=\"javascript\">\<kEnter>
</script>\<kEnter>
</head>\<kEnter>
<body>\<kEnter>
</body>\<kEnter></html>\<ESC>gg"
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<autocmd for skeleton html file (BufFileNew) | Microsoft Natural Multimedia Keyboard Scancodes >>
Additional Notes
Anonymous, November 26, 2002 11:09
I'm not sure what the tip is here. I don't add that -compiled-by argument when I compile and I still see my
name in the Compiled by line from the version command.
Anonymous, November 28, 2002 2:00
Yes, you see compiled by user@host... But, with that
tip, you can override this by setting a custom
string...
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<A totally useless tip...or is it ? | Auto insert Java class template when editing a new Java file >>
Additional Notes
Anonymous, December 21, 2002 22:57
To actually 'use' the multimedia keys, its usefull to be able to map them
with nmap or something. The easiest/best way to do this is to find the
key's scancode via runing xev and pressing the key, looking at the
scancode output, then doing a
xmodmap -e "keycode 139 = F13"
for example, replacing the 139 with whatever your special multimedia key's
scancode was, and the F13 with whatever key you want, i used the F keys >
13 since my keyboard doesnt have anything above 12, and you can define
upto i think 35 F keys (so i just mapped all my 'multimedia' keys to F13F29 and then maped those F keys in vim to things i wanted to do, or to my
windowmanager to do other stuff)
So thats a method that should work on any keyboard, and doesnt rely on
special propriatary(sp) key layout stuff, but it does take a couple steps
to get your scancodes n such. Here is what my .xinitrc looks like so i
make sure and get all my keys mapped whenever i load X (i just put in the
last lines that do anything, your X file may have some funny startup stuff
it does)
Note the first two lines are me mapping my Caps Lock to the Escape key, so
i dont have to make that horrible reach to the escape key to get outa
whatever mode i am in. If you don want that, just dont have the top two
lines (i just thought a few people might find that of interest)
xmodmap
xmodmap
xmodmap
xmodmap
-e
-e
-e
-e
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
F15"
F16"
F17"
F18"
F19"
F20"
F21"
F22"
F23"
F24"
F25"
F26"
F27"
F28"
F29"
Hope that does someone some good. Again, to find out your scancode key,
run the program
xev
then start hitting keys, and watch as stuff scrolls by, look for the
keypress event as you hit a key, then look for the 'keycode' and thats the
number you want!
- Random contributor you dont care about
Anonymous, December 22, 2002 16:40
With regards to xmodmap, you might find it tidier to put all your mappings
into (e.g.) ~/.xmodmap and then call "xmodmap ~/.xmodmap" from
~/.xinitrc. Also, for those of you using xdm/kdm/gdm instead of
startx/xinit, use ~/.xsession instead of ~/.xinitrc.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #378 - Auto insert Java class template when editing a new Java file : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #378: Auto insert Java class template when editing a new Java
file
tip karma
complexity: basic
as of Vim: 6.0
If you are lazy like me, tend to use lengthy and verbose
Java class names, then this tip is for you. When
creating a new Java class file, the first thing that I
do after creating it is to add the following block of
text:
public class ClassName
{
}
Rather than have to type the ClassName twice (once when
you first opened the new file, and then again for this
block), you can use this autocmd to insert that text for
you automatically:
autocmd BufNewFile *.java
\ exe "normal Opublic class " .
"\n{\n}\<Esc>1G"
Life Changing
Helpful
expand('%:t:r') .
Unfulfilling
rate
<<Microsoft Natural Multimedia Keyboard Scancodes | 1,$ s/^M//g gets rid of control-Ms (windows
carriage returns) >>
Additional Notes
vipie @ ulyssis.org, November 27, 2002 17:25
This autocommand generated multiple 'public class..{}'
entries sometimes. I have no idea why...
stelliosk@optushome.com.au, November 27, 2002 19:51
Tip #378 - Auto insert Java class template when editing a new Java file : vim online
Tip #378 - Auto insert Java class template when editing a new Java file : vim online
dir
dir
dir
dir
=
=
=
=
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #379 - 1,$ s/^M//g gets rid of control-Ms (windows carriage returns) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Auto insert Java class template when editing a new Java file | Using gvim as frontend for dbx >>
Additional Notes
jigho@caramail.com, November 27, 2002 23:46
Tip #379 - 1,$ s/^M//g gets rid of control-Ms (windows carriage returns) : vim online
Tip #379 - 1,$ s/^M//g gets rid of control-Ms (windows carriage returns) : vim online
Tip #379 - 1,$ s/^M//g gets rid of control-Ms (windows carriage returns) : vim online
Explained:
CTL-V is mapped to the Windows PASTE function, so, you
can't invoke [ESC]escape sequence [CTL-V] like you do
in UNIX.
In WINDOWS, the [ESC] is actived by CTL-Q.
The above command will change all the UNIX style
<CR><LF> to the Windows normal behavior.
Hope this helps, it took me about 2 hours of trial and
error and on-line searching to find the answer.
YOU'RE WELCOME! ;-}
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<1,$ s/^M//g gets rid of control-Ms (windows carriage returns) | Running the win32-version of Vim
from cygwin >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #381 - Running the win32-version of Vim from cygwin : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
This tip does not only concern Vim, but any native win32
application (NWA) we may want to run from cygwin.
Note: I call a "native win32 application", any program
that has not been specifically compiled to run on
cygwin.
Typical examples are internet explorer, yap, acrobat
reader, ... and of course the win32 version of Vim
available on this site or on
http://cream.sourceforge.net.
The problem with running NWAs from cygwin comes from the
fact that paths in cygwin can be expressed in ways that
NWAs can't understand. Indeed from cygwin, we can also:
- express paths as *nix-like paths ; e.g. /etc/profile
- use paths that, as a matter of fact, are symbolic
links.
So, to come around this issue, here is a shell script
that can be used to define aliases:
http://hermitte.free.fr/cygwin/cyg-wrapper.sh
[More help available on:
http://hermitte.free.fr/cygwin#Win32]
All you have to do is to drop it into one directory from
your $PATH, and define into your .profile something
like:
alias gvim='cyg-wrapper.sh
"C:/Progra~1/Edition/vim/vim61/gvim.exe" -c'
Notes:
- under MsWindows 9x, I had to writte the path to
gvim.exe in the windows short form
- the '-c' is here to tell cyg-wrapper.sh that: when
calling VIM, the parameter following '-c' is not a path.
This enables to write:
gvim -c '/^$/' foo.xxx
Tip #381 - Running the win32-version of Vim from cygwin : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Using gvim as frontend for dbx | Search and replace in all open buffers >>
Additional Notes
hermitte {at} free {dot} fr, December 3, 2002 9:27
I made a small mistake, I help page is:
http://hermitte.free.fr/cygwin/#Win32
hermitte {at} free {dot} fr, December 4, 2002 8:41
I have just update cyg-wrapper.sh.
Now, you will be able to:
(*) Use absolute paths expressed in the windows
form
>
gvim c:/bar/foo.txt
(*) Use multiple-level of indirections through symbolic
links
>
ln -s foo1 somepath
>
ln -s foo2 foo1
>
...
>
gvim foon
(*) Use symbolic links pointing to absolute paths
expressed in the windows form
>
ln -s foo c:/bar/foo.txt
>
gvim foo
hermitte {at} free {dot} fr, December 5, 2002 10:32
Tip #381 - Running the win32-version of Vim from cygwin : vim online
Tip #381 - Running the win32-version of Vim from cygwin : vim online
> > Last point, the win32 version of Vim can not expand
paths expressed in the *nix > > way ; e.g. ':sp
/etc/pr<tab>' won't expand.
> :help 'shellslash'
'shellslash' has almost nothing to do with that
problem.
On Cygwin, "/etc/something" refers in fact to
"c:\Cygwin\etc\something" (assuming Cygwin has been
installed into "c:\Cygwin").
Vim is not able to translate *nix paths into plain
MsWindows paths -- a convertion layer needs to be
introduced if we want to use paths in such form.
Matthias.Morche@szm.de, October 22, 2003 6:00
I've detected a tiny flaw: if You want to use netrw
(eg. gvim scp://somehost/somefile) from the commandline
You loose. Here's the patch to recognise url syntax and
handle it properly:
--- /DownLoad/vim/cyg-wrapper.sh
2003-10-22
14:49:25.084774400 +0200
+++ /opt/bin/cyg-wrapper.sh
2003-10-22
14:55:04.392675200 +0200
@@ -254,6 +254,9 @@
else
ptransl="$1"
fi
+
elif [ `expr "$1" : "[a-z]*://.*"` -gt 0 ] ; then
+
# some netrw protocol like http://host or
ftp://host : leave as is
+
ptransl="$1"
else
# Convert pathname "$1" to absolute path (*nix
form) and resolve
# all the symbolic links
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #382 - Search and replace in all open buffers : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Running the win32-version of Vim from cygwin | a Map to jump to a subroutine/function from where
it is called >>
Additional Notes
pottsdl@netzero.net, December 5, 2002 7:41
Tip #382 - Search and replace in all open buffers : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #383 - a Map to jump to a subroutine/function from where it is called : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Hi
When writing/debugging code you often want to jump from
where a subroutine/function is called to where it
actually is . Hitting the "*" key is frustrating if the
sub/func is called many times. The following mapping
solves the problem. (Notice how it can be altered for
other lanaguages)
nmap gx yiw/^\(sub\<bar>function\)\s\+<C-R>"<CR>
Instructions: place cursor over called function (normal
mode) and type gx
How it works:
yiw : Yank inner work to un-named register
/^\(sub\<bar>function\)\s\+ : search for sub or
function followed by 1 or more spaces
<C-R>" : Retrieve un-named register
<CR> : Start Search
(also included in vimtip #305 )
Life Changing
Helpful
Unfulfilling
rate
<<Search and replace in all open buffers | Easily switch between source and header file >>
Additional Notes
Anonymous, December 6, 2002 9:02
Take a look at :help tags-and-searches
Anonymous, December 16, 2002 23:33
http://www.vim.org/tips/tip.php?tip_id=383 (1 of 2) [18/02/2004 14:56:31]
Tip #383 - a Map to jump to a subroutine/function from where it is called : vim online
g]
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #384 - Easily switch between source and header file : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Tip #384 - Easily switch between source and header file : vim online
Life Changing
Helpful
Unfulfilling
rate
<<a Map to jump to a subroutine/function from where it is called | some java & vim tips >>
Additional Notes
salmanhalim@hotmail.com, December 6, 2002 22:11
Two things:
1) The mappings should be made buffer-specific with a
<buffer> modifier.
2) If you use an if clause in your ftplugin/c.vim file
(that checks to see if the current file ends in a .h or
.c), you might be able to use the same mapping to go to
the .h file if you're editing the .c and vice
versa. You could easily map the sequence to a simple
function that does a variation of expand("%") (with a
modification flag) to extract the extension. . .
Anonymous, December 9, 2002 7:52
Since nobody mentioned it so far, I will do
it: vimscript #31 (a.vim) provides
exectly the functionality you mentioned and can be
configured for various
filetypes (not only C/Cpp).
bubbleboy, December 9, 2002 10:35
My my... do we have an urge to over-complicate things?
=D I think the <buffer> idea is a good one, but adding
a function to first inspect the suffix seems to be of
little benefit. The idea here is simplicity!
One reason this idea is better than vimscript #31
(IMHO) is because additional file types can be added
with very little effort and without modification to the
original script (a.vim). Also it's 10,000% shorter. ;-D
anonymous, December 10, 2002 6:03
Tip #384 - Easily switch between source and header file : vim online
A few notes :)
1) :find foo.c when foo.c does not exist can be a
rather long time consuming search, particularly when
foo.c does not exist. vimscript #31 does not have this
problem. And if foo.c does not exist the switch still
works...you do not get the E345 error message.
2) vimscript #31 works with multiple extensions, C,
C++, ada etc, can be configured for more without
editing the script. Read some of the comments in the
10000 line file :)
3) vimscript #31 works with different extension styles
.C .cxx .cpp .CPP .cc <--> .h .hpp .H .HPP all at the
same time. :A will switch between any of the source
extensions to any of the header extensions. Different
extension styles are sadly common in large projects.
4) 10000 lines?? less than 200 once comments are
stripped and utility functions could be moved to a
common.vim for reuse if size is an issue.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
i started to aggregate some java & vim tips (in part because i easily forget stuff). they're the
kind of tips that are a little elusive but deliver a big bang for their effort; like actually
getting quickfix to work with java, using ctags with java, etc....
http://www.ophinity.com/papers/jim/index.html
...on that note, i wonder if vim.org should start organizing tips and scripts into areas of
interest or perhaps cross-indexing? some things that come to mind are document generation (tex/
latex), oracle/ db integration, java development, c/ c++ coding, win32 issues, etc...
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Easily switch between source and header file | Cut/copy and paste using visual selection >>
Additional Notes
bubbleboy, December 9, 2002 11:45
You can avoid using
autocmd BufRead *.java ...
commands by using filetype plugins. See :help filetype. These files will be sourced only when
opening a source file of the corresponding file type.
maxiangjiang@hotmail.com, December 9, 2002 16:53
I found using jikes is 10x faster than javac!
rvijay2001@hotmail.com, December 12, 2002 18:12
Thank you! Thank you!
If only there was a way to debug java from within Vim.
http://www.vim.org/tips/tip.php?tip_id=385 (1 of 6) [18/02/2004 14:56:36]
Any
Thanks,
Tarun
jonbo372@student.liu.se, January 17, 2003 13:01
Hi all!
I have been reading all the tips about making quickfix work but there is something that I miss. I
use ant 1.5.1, vim 6.1 and javac (yes its slow i know)
i have the following line in my .vimrc file
set makeprg=ant\ -emacs\ -q\ -find\ build.xml\
I read somewhere that if you use the -emacs option you would not have to mess with the
errorformat. but guess what, it does not work. it will give me zero erros. however, if i have ant
dump the stuff to a file it clearly shows that there are errors in the file. the dump looks like
this:
C:\private\programmering\test of ant\src\HelloWorld.java:17: ';' expected
t.foo()
^
C:\private\programmering\test of ant\src\HelloWorld.java:19: cannot resolve symbol
symbol : variable f
location: class HelloWorld
f.doSomething();
^
2 errors
BUILD FAILED
file:C:/private/programmering/test of ant/build.xml:18: Compile failed; see the compiler error
output for details.
Total time: 2 seconds
so why doesnt these errors show up when i do clist???
i have also tried not using the -q and -emacs option with the following errorformat
set efm=%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#
when compiling it will report lots of errors but no real ones. it will falsely report the
following:
1: Searching for build.xml ...
2: Buildfile: c:\private\programmering\test of ant\build.xml
3:
http://www.vim.org/tips/tip.php?tip_id=385 (3 of 6) [18/02/2004 14:56:36]
4: init:
5:
6: compile:
7: [javac] Compiling 1 source file to c:\private\programmering\test of ant\build
and thats it... no mention about the real errors...
btw, im running xp but i have been trying it on win2k as well.
could someone please tell me what im doing wrong...
Thanks,
Jonas
peterderooij@yahoo.com, February 4, 2003 8:03
Hi,
on the problem of making the quickfix work on Win2000 (or XP):
I had the problem mentioned by Jonas, and setting
set shellpipe=>%s\ 2>&1
fixed it. (Note that this is the value for shellredirect.)
Cheers, Peter
clamey@infonow.com, October 30, 2003 14:04
Another useful Java setup I use is to build a tags file for the source code of the JDK and have
vim use it. The JDK source code can be downloaded from Sun.
Then I build two tag files, one for my project, one for the JDK:
pushd $HOME
ctags -f jdk_tags -R $JAVA_HOME/src
ctags -f proj_tags --exclude=CVS -R $PROJ_HOME/com $PROJ_HOME/webapps
popd
In .vimrc, I tell Vim to use the JDK tags first, then my Project:
set tags=$HOME/jdk_tags,$HOME/proj_tags
This is useful when using tags for completions, along with tagjumping for definitions (and see
how things are implemented by Sun).
Along with this, I use the dictionary keyword completion on a per-buffertype basis and the smart
tab completion metioned on the above webpage.
My completion is set like so:
set cpt=k,.,w,b,u,t,i
http://www.vim.org/tips/tip.php?tip_id=385 (4 of 6) [18/02/2004 14:56:36]
Which means that when I start to type something and hit <tab>, it will essentially first go
through the Java keywords, then the JDK source, then my project source.
These are also helpful Java settings:
" Highlight functions using Java style
let java_highlight_functions="style"
" Don't flag C++ keywords as errors
let java_allow_cpp_keywords=1
And this abbreviation is cool as well:
iab ff for (Iterator i =; i.hasNext())
{<LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT><LEFT>
clamey@infonow.com, October 30, 2003 15:37
At some point along the way, Vim included an ant.vim compiller script that does the set
makeprg/errorformat for ant and javac, respectively. It can be enabled like this:
:compiler ant
Unfortunately, this seems to not persist through buffers during the quick fix mode.
do this:
So you can
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #386 - Cut/copy and paste using visual selection : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<some java & vim tips | A way to quickly prefix a char(or chars) to a parameter list, via :s >>
Tip #386 - Cut/copy and paste using visual selection : vim online
Additional Notes
Anonymous, December 9, 2002 23:15
If you just want to copy (yank) the visually marked
text, you do not need to 'y'ank it. Marking it will
already copy it.
Using a mouse, you can insert it at another position by
clicking the middle mouse button.
This also works in across vim applications on Windows
systems (clipboard is inserted)
:-))
niklas, December 10, 2002 12:01
This is a really useful thing in Vim. I feel lost
without it in any other editor. I have some more points
I'd like to add to this tip:
* While in (any of the three) Visual mode(s), pressing
'o' will move the cursor to the opposite end of the
selection. In Visual Block mode, you can also press
'O', allowing you to position the cursor in any of the
four corners.
* If you have some yanked text, pressing 'p' or 'P'
while in Visual mode will replace the selected text
with the already yanked text. (After this, the
previously selected text will be yanked.)
* Press 'gv' in Normal mode to restore your previous
selection.
* It's really worth it to check out the register
functionality in Vim: ':help registers'.
* If you're still eager to use the mouse-juggling
middle-mouse trick of common unix copy-n-paste, or are
into bending space and time with i_CTRL-R<reg>,
consider checking out ':set paste' and ':set
pastetoggle'. (Or in the latter case, try with i_CTRLR_CTRL-O..)
(Btw - of course I never actually feel lost: I never
use any other editor. ;)
Anonymous, July 5, 2003 11:52
Tip #386 - Cut/copy and paste using visual selection : vim online
Tip #386 - Cut/copy and paste using visual selection : vim online
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #387 - A way to quickly prefix a char(or chars) to a parameter list, via :s : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Cut/copy and paste using visual selection | Insert C++, LaTeX, and other comments easily >>
Additional Notes
Tip #387 - A way to quickly prefix a char(or chars) to a parameter list, via :s : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #388 - Insert C++, LaTeX, and other comments easily : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<A way to quickly prefix a char(or chars) to a parameter list, via :s | search only in unfold text(intend
to work with diff) >>
Additional Notes
SBrueggemann<somewhere at>gmx.net, December 16, 2002 8:03
Tip #388 - Insert C++, LaTeX, and other comments easily : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #389 - search only in unfold text(intend to work with diff) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
hi,
sometimes I would like to search/replace the code in the
latest version. That is when I show diff between two
version of code, I would like to only search the unfold.
The following function may do the replace job:
function Foldrepl(spattern, tpattern)
normal gg
"go to top of the file
if &diff
"need to change fold option for
diff
exec "set diffopt=context:0"
endif
"echo a:spattern
"echo a:tpattern
let mycount =0
while search(a:spattern, "W") > 0 "find the search
pattern
if foldlevel(line(".")) < 1
"not in flod
exec "s/".a:spattern."/".a:tpattern."/g"
let mycount = mycount + 1
endif
endwhile
if &diff
"need to restore fold option,
mine is 4
set diffopt=context:4
endif
echo mycount ." lines are changed"
endfunction
It can be changed to do the search job or both
Demai
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Tip #389 - search only in unfold text(intend to work with diff) : vim online
<<Insert C++, LaTeX, and other comments easily | combining vimdiff with cvs diff >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
i like using vim's diff mode for comparing different revisions of source code files. usually
older versions do not live in the directory structure with the current versions, but in a cvs
repository. the command below, CVSdiff, can compare the current file to any given revision
number in the cvs repository. please note that in case a revision number does not exist, empty
files will be displayed, as the below script does not do any error checking (yep, i'm lazy, and
this works for me). a vertical split is performed on the current file and its given previous
revision.
command -nargs=1 CVSdiff silent call CVSdiff("%", "<args>")
function! CVSdiff(filename, cvsversion)
" append a:filename to keep extension and therefore highlighting mode
let patchname = tempname() . a:filename
let tempname = tempname() . a:filename
let newname
= tempname() . a:filename
execute "!cvs diff -a -r " . a:cvsversion . " " . a:filename . " > " . patch
execute "!cp " . a:filename . " " . tempname
execute "!patch -R -o " . newname . " " . tempname . " < " . patchname
execute "vertical diffsplit " . newname
call delete(patchname)
call delete(tempname)
call delete(newname)
endfunction
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<search only in unfold text(intend to work with diff) | Simple programmers TODO list using grep and quickfix >>
Additional Notes
xburgerhout@nospamplease.freeler.nl, December 18, 2002 5:53
http://www.vim.org/tips/tip.php?tip_id=390 (1 of 2) [18/02/2004 14:56:48]
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #391 - Simple programmers TODO list using grep and quickfix : vim online
Home
Search
Tip #391: Simple programmers TODO list using grep and quickfix
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<combining vimdiff with cvs diff | fileencodings: how to make it work correctly? >>
Additional Notes
alec aaattttt korn dddotttt ch, December 29, 2002 19:10
Tip #391 - Simple programmers TODO list using grep and quickfix : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Simple programmers TODO list using grep and quickfix | PCRE search and replace (Perl
Compatible Regular Expressions) >>
Additional Notes
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #393 - PCRE search and replace (Perl Compatible Regular Expressions) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<fileencodings: how to make it work correctly? | pop up menu for checking the meaning of the word
from internet >>
Additional Notes
ned@bike-nomad.com, December 31, 2002 10:11
Or if you have ruby compiled in (look for +ruby in :ver
output):
:rubydo sub! /pattern/,'replacement'
detlef@lindenthal.com, January 5, 2003 10:41
What are the advantages compared with this:
:1,$s/searchexpression/replaceexpression/gc ?
That now you can have the exact syntax of perl
regex?
myrddin@cwpn.org, January 7, 2003 11:26
The advantage is that when you know Perl regex well its
easier to write Perl regex than vi regex. Either is
find for simple expressions, but when the expressions
get more complex its much easier to work with the
syntax you know the best.
vimtips@iamafreeman.com, January 11, 2003 15:59
http://www.vim.org/tips/tip.php?tip_id=393 (1 of 3) [18/02/2004 14:56:55]
Tip #393 - PCRE search and replace (Perl Compatible Regular Expressions) : vim online
I'd
Tip #393 - PCRE search and replace (Perl Compatible Regular Expressions) : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #394 - pop up menu for checking the meaning of the word from internet : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #394: pop up menu for checking the meaning of the word from
internet
tip karma
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<PCRE search and replace (Perl Compatible Regular Expressions) | visual marks >>
Additional Notes
mark.thomas@bigswamp.org, January 3, 2003 1:55
http://www.vim.org/tips/tip.php?tip_id=394 (1 of 4) [18/02/2004 14:56:58]
Tip #394 - pop up menu for checking the meaning of the word from internet : vim online
Tip #394 - pop up menu for checking the meaning of the word from internet : vim online
Tip #394 - pop up menu for checking the meaning of the word from internet : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Hi,
Setting visual bookmarks in a file / buffer can be done
in a simple way by using VIM's 'sign' feature.
This solution just sets the background of the current
line to light blue.
Also see ':help sign'.
Add these lines to your gvimrc:
" define a highlight colour group for bookmarks
hi default BookmarkCol ctermfg=blue ctermbg=lightblue
cterm=bold guifg=DarkBlue guibg=#d0d0ff gui=bold
" define a bookmark / sign: just highlight the line
sign define MyBookmark linehl=BookmarkCol
" add something to the context menue (right mouse)
amenu 1.200 PopUp.-SEP3- :
amenu 1.200 PopUp.&mark.set\ bookmark :exe 'sign place
1000 name=MyBookmark line='.line(".").'
buffer='.winbufnr(0)<CR>
amenu 1.200 PopUp.&mark.del\ bookmarks :sign unplace
1000 <CR>
amenu 1.200 PopUp.&mark.list\ bookmarks :sign list<CR>
Happy VIMming
Thomas
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<pop up menu for checking the meaning of the word from internet | Highlighting whitespaces at end
of line >>
Additional Notes
maxiangjiang@hotmail.com, January 8, 2003 15:38
1 We need to add <silent> on the map to make it work
smoothly
amenu<silent> 1.200 PopUp.&mark.set\ bookmark :exe
'sign place 1000 name=MyBookmark line='.line(".").'
buffer='.winbufnr(0)<CR>
2. bookmark deletion doesn't work as expected.
Is it possible to delete highlighted bookmark under the
cursor?
Thanks.
Anonymous, January 8, 2003 23:34
The problem might be the 'id' (I used the same '1000'
for each bookmark).
You have to find a way to automatically use unique ids
or 'unplace'
will delete the bookmarks in the order they have been
created.
There is a script 'showmarks' in the script database
(search for 'showmarks'),
which shows 'normal' vim marks (Thanks to the author!).
Thomas
Anonymous, January 9, 2003 5:02
To get unique identifier you can use the actual line
number as identifier:
amenu<silent> 1.200 PopUp.&mark.set\ bookmark :exe
'sign place '.line(".").' name=MyBookmark
line='.line(".").' buffer='.winbufnr(0)<CR>
amenu<silent> 1.200 PopUp.&mark.del\ bookmark :exe
'sign unplace '.line(".")<CR>
Thomas
Anonymous, January 9, 2003 6:31
Just download the showmarks.vim plugin from this site
and forget about it :) It'll automatically show you a
mark as a sign when you set one.
showmarks.vim
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Anonymous, January 9, 2003 22:13
:set list
<Look at trailing spaces and tabs>
:set nolist
< Now get rid of them>
:%s/\s*$//g
xburgerhout at freeler dot nl, January 9, 2003 23:52
You can also add this line to .vimrc:
let c_space_errors=1
This wil enable trailing whitespace errors in C/C++
files only.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #397 - mapping for better browsing of :help docs : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Tip #397 - mapping for better browsing of :help docs : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Highlighting whitespaces at end of line | Mapping for quicker access to macros >>
Additional Notes
mark.addison@itn.co.uk, January 10, 2003 8:41
You can adapt this to also use it with the man page
file type, so you can hit return on a ref to another
man page etc.
I had to use the after config file
"~/.vim/after/ftplugin/man.vim" and nmap instead of
nnoremap to getting it working. (I think this is
because the default man.vim needs to set its remap of
<c-]> first.)
goulding@princeton.edu, January 10, 2003 21:22
Very useful mappings for helpfiles. I've added them to
my help.vim, which also contains these for navigating
from |label| to |label|:
nnoremap <buffer> <Tab> /<Bar>\k*<Bar><CR>
nnoremap <buffer> <S-Tab> ?<Bar>\k*<Bar><CR>
" Can't get s-tab to work in xterm, so...
nmap <buffer> . <Tab>
nmap <buffer> , <S-Tab>
Anonymous, February 23, 2003 9:09
hmmm, nice tip, but I couldn't get it working by using
the help.vim file. Adding these lines to .vimrc seems
to work though:
:au filetype help :nnoremap <buffer><cr> <c-]>
:au filetype help :nnoremap <buffer><bs> <c-T>
- Chris
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
:nnoremap <space> @q
Start recording keystrokes by hitting 'qq'.
End recording with 'q' (<esc> q if you're in insert
mode).
Play keystrokes by hitting space.
--Refs:
:help register
:help record
Life Changing
Helpful
Unfulfilling
rate
<<mapping for better browsing of :help docs | fold away empty lines >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
fold
Life Changing
Helpful
Unfulfilling
rate
<<Mapping for quicker access to macros | Fast scroll mappings (incl. insert mode) >>
Additional Notes
Anonymous, January 15, 2003 13:07
%s/^$/d
Anonymous, January 15, 2003 13:08
Oops:
%g/^$/d
kartikeya_rindani@hotmail.com, January 15, 2003 19:34
Probably the tip aims at getting rid of empty lines
from the display, not from the file.
Anonymous, January 15, 2003 23:08
exactly.
Anonymous, January 15, 2003 23:12
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #400 - Fast scroll mappings (incl. insert mode) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Tip #400 - Fast scroll mappings (incl. insert mode) : vim online
<<fold away empty lines | A mapping for easy switching between buffers >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #401 - A mapping for easy switching between buffers : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
<C-Up> :bn<Return>
<C-Down> :bp<Return>
Life Changing
Helpful
Unfulfilling
rate
<<Fast scroll mappings (incl. insert mode) | Just using space-bar: jump between splitted windows and
open them wide >>
Additional Notes
yourock@devo.com, January 14, 2003 18:53
Shazam!
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #402 - Just using space-bar: jump between splitted windows and open them wide : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #402: Just using space-bar: jump between splitted windows and
open them wide
tip karma
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<A mapping for easy switching between buffers | Request for tip - interleaving '.' and '@:' >>
Additional Notes
http://www.vim.org/tips/tip.php?tip_id=402 (1 of 3) [18/02/2004 14:57:17]
Tip #402 - Just using space-bar: jump between splitted windows and open them wide : vim online
Tip #402 - Just using space-bar: jump between splitted windows and open them wide : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #403 - Request for tip - interleaving '.' and '@:' : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: advanced
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Just using space-bar: jump between splitted windows and open them wide | Tags for Mixed
Assembly and C >>
Additional Notes
zzapper@ntlworld.com, January 16, 2003 0:40
A better place for requests is
comp.editors
http://groups.google.com/groups?q=comp.editors
Kartik Agaram, January 16, 2003 12:34
Apologies.
Kartik Agaram, January 16, 2003 12:45
Tip #403 - Request for tip - interleaving '.' and '@:' : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Request for tip - interleaving '.' and '@:' | ShowBlockName one-liner equivalent for one coding style
>>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #405 - ShowBlockName one-liner equivalent for one coding style : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
I look forward
Cheers,
William
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Tags for Mixed Assembly and C | Alternate delimiters for the replace command >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #406 - Alternate delimiters for the replace command : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<ShowBlockName one-liner equivalent for one coding style | PHPdoc: Use JCommenter.vim for phpscripts >>
Additional Notes
zzapper@ntlworld.com, January 18, 2003 5:52
:'a,'bs#str1#str2#gci
:1,23s=str1=str2=gci
I use one of the above ie either = or #
Tip #406 - Alternate delimiters for the replace command : vim online
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Alternate delimiters for the replace command | Enhance Calendar (script 52) with special dates >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
http://www.vim.org/tips/tip.php?tip_id=408
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Sign
Color
Description
10101
10217
10214
10414
10526
10703
10704
+ 1 day
10901
11127
+ 1 day
11128
11225
1 day
11226
1 day
n
p
v
s
m
i
i
blue
blue
red
green
blue
gold
gold
Jan
Feb
Feb
Apr
May
l
t
blue
blue
Sep 01
(Mon)
- Labor Day
Nov 27&28(Thu & Fri)- Thanksgiving Day
t
c
blue
silver
silver
Step 2)
01
17
14
14
26
Jul 3&4
(Wed)
(Mon)
(Fri)
(Mon)
(Mon)
http://www.vim.org/tips/tip.php?tip_id=408
Life Changing
Helpful
Unfulfilling
rate
<<PHPdoc: Use JCommenter.vim for php-scripts | Using selected text as part of a command? >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Enhance Calendar (script 52) with special dates | Allow Inform header files to be distinguished from
C headers >>
Additional Notes
Mark Hillebrand, January 22, 2003 2:01
1. yank your selected text using the 'y' key.
2. when entering your command you can use control-r
followed by " whenever you need your selections.
(control-r " inserts the contents of the "-register
which is the standard register for yanking)
I don't know exactly, if this was already possible in
vim 5.7.
michael@familie-boehler.de, January 22, 2003 3:08
Just put the cursor over the word in your text.
In the command line press <C-R><C-W> the to get the
word.
See h: c_<C-R>_<C-W>
lewocz@acm.org, January 22, 2003 5:25
:s/<C-R>//
:s/<C-R>//
I then just add the closing delimiter and flags and hit
return.
These mappings have
saved me a great deal of time.
zzapper@ntlworld.com, January 22, 2003 7:43
Hi,
A better place your discussions about VIm is
http://groups.google.com/groups?q=comp.editors
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #410 - Allow Inform header files to be distinguished from C headers : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim:
6.0
call
Tip #410 - Allow Inform header files to be distinguished from C headers : vim online
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
to \
in the tip above)
Life Changing
Helpful
Unfulfilling
rate
<<Allow Inform header files to be distinguished from C headers | Easy menu-style switch between files
with a simple map >>
Additional Notes
bnouane@uark.edu, March 6, 2003 12:45
just wanted to say that i use the windows version, and
i had to goto the directory vim/vim61/plugin, and i
added the line
norm \[i
at the very end of the file HiMtchBrkt.vim
also when i opened a file, an annoying window popped
up, so i commented out the echo command at line 108 of
the file.
boonth
cec@NgrOyphSon.gPsfAc.nMasa.gov, March 17, 2003 12:24
The fix for that annoying little message box is to use:
silent norm \[i
The box no longer shows up. Enjoy!
jlanus@netscape.net, October 4, 2003 7:20
I'm trying the plugin with those old FORTRAN progrms I
work with.
Most lines start with tabs, and the pligin seems to get
confused by this fact.
If I replace the tabs by spaces it works fine, even
witn multiline sentences.
Juan Lanus
TECNOSOL Argentina
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #412 - Easy menu-style switch between files with a simple map : vim online
Home
Search
Tip #412: Easy menu-style switch between files with a simple map
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<How to initialize plugins | Drag and Drop file names into VIM's command line >>
Additional Notes
jh_sec@gmx.net, January 29, 2003 23:14
great tip!
i've never memorized how to switch between my files,
this is great.
Anonymous, January 29, 2003 23:33
Tip #412 - Easy menu-style switch between files with a simple map : vim online
Try also:
and
Tip #412 - Easy menu-style switch between files with a simple map : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #413 - Drag and Drop file names into VIM's command line : vim online
Home
Search
Tip #413: Drag and Drop file names into VIM's command line
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Easy menu-style switch between files with a simple map | Change guifont to see more of your file.
>>
Additional Notes
foo@bar.com, January 30, 2003 23:47
This also works in an X-Windows environment, such as
Linux uses.
:edit <drag file on to Gvim window> <Return> also works
as you would expect.
Anonymous, January 16, 2004 13:27
In X, you don't even need to type ":edit" first. Just
grab a file from your file manager (like Rox) and
drag/drop it into Vim.
Add Note
Tip #413 - Drag and Drop file names into VIM's command line : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #414 - Change guifont to see more of your file. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Drag and Drop file names into VIM's command line | easy way to edit two files using split window >>
Additional Notes
jkr@jottkaerr.de, January 30, 2003 6:50
Tip #414 - Change guifont to see more of your file. : vim online
Tip #414 - Change guifont to see more of your file. : vim online
Tip #414 - Change guifont to see more of your file. : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #415 - easy way to edit two files using split window : vim online
Home
Search
Tip #415: easy way to edit two files using split window
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Change guifont to see more of your file. | Fix error "E97: Cannot create diffs" on VIM for Windows
>>
Additional Notes
skrishna23@excite.com, January 30, 2003 11:53
If you use 'k', what command do you use to move UP ???
Don't say remap....,It's better not to use existing
keys.
Anonymous, January 30, 2003 23:23
Tip #415 - easy way to edit two files using split window : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #416 - Fix error "E97: Cannot create diffs" on VIM for Windows : vim online
Home
Search
Tip #416: Fix error "E97: Cannot create diffs" on VIM for Windows
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<easy way to edit two files using split window | combining move and scroll [IMPROVED] >>
Additional Notes
justin.buist@siemens.com, April 30, 2003 7:56
Tip #416 - Fix error "E97: Cannot create diffs" on VIM for Windows : vim online
Tip #416 - Fix error "E97: Cannot create diffs" on VIM for Windows : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: intermediate
as of Vim: 5.7
Site Help
Now, Ctrl-J and Ctrl-K will move the cursor one line
down or up, and scroll one line down or up--so the
cursor remains on the same screen line (except near the
beginning and end of the file)--in both normal and
visual modes. And the scroll parameter is unaffected.
" N<C-D> and N<C-U> idiotically change the scroll
setting
function! s:Saving_scroll(cmd)
let save_scroll = &scroll
execute "normal" a:cmd
let &scroll = save_scroll
endfunction
" move and scroll
nmap <C-J>
:call
D>")<CR>
vmap <C-J> <Esc>:call
D>")<CR>
nmap <C-K>
:call
U>")<CR>
vmap <C-K> <Esc>:call
U>")<CR>
<SID>Saving_scroll("1<C-V><C<SID>Saving_scroll("gv1<C-V><C<SID>Saving_scroll("1<C-V><C<SID>Saving_scroll("gv1<C-V><C-
Life Changing
Helpful
Unfulfilling
rate
<<Fix error "E97: Cannot create diffs" on VIM for Windows | Stop the beeping in gvim. >>
Additional Notes
bach2tony@yahoo.com, February 6, 2003 9:48
OH YEAH, WELL YUO = TEH SUX0R!!!111
vimizer, February 8, 2003 19:21
I set 'scrolloff' value for somewhat of the same
effect. Your way is more complete though.
mkelly@hp.com, February 10, 2003 21:34
Thanks, this is great, almost exaclty what I was
looking for !
The only two things left I still am searching for are :
1) (related) I want to keep the cursor column in the
same place unless the new line is shorter in which case go to
the end of
the new line. This always puts the column at 0
when I scroll.
Still excellent tho, thanks !
2). (not related) I want to restore the screen buffer
to what it was
before I entered vim. I think a ioctl/tcgetattr
to get the initial
settings and then another one at the end to
restore might
do it - but I am just looking at the code now to
see how/where.
Maybe there is a better way ?
thanks for your help,
mark
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<combining move and scroll [IMPROVED] | Auto-fold perl subs (and possibly other languages) >>
Site Help
Additional Notes
darkeye@chol.net, February 3, 2003 20:38
:set vb
Have nice day!
srinath AT fastmail DOT fm, February 3, 2003 20:39
To all the intellectually challenged:
This is a place for posting "tips" which are objects of
information you beleive will help other vim users.
This is _NOT_ a place to ask questions. Use
comp.editors (with the word "vim" in the subject line),
or
subscribe to vim@vim.org and ask the really helpful
people there.
Please stop messing up this lovely website.
I wish there were some way of removing these obviously
bad "tips".
Anonymous, February 3, 2003 23:17
where the answer transform the question to tip ...
Anonymous, February 6, 2003 7:37
messages
(See also 't_vb')
messages
(See also 't_vb')
messages
(See also 't_vb')
endif
endfunction
-------------------------------------------------Re-start Vim and enter
:call Errorbells_off("beep") -- turns off beeps
:call Errorbells_off("flash") -- turns off flashes
:call Errorbells_off()
-- turns off both
We use this the Cream for Vim project
(http://cream.sourceforge.net).
samrat2107@hotmail.com, March 21, 2003 11:45
removing complexity of the program .
just type following in your .vimrc
set noerrorbells
set visualbells
set t_vb=
thats all folks.
dev@null.org, April 6, 2003 8:39
quote:
srinath AT fastmail DOT fm, February 3, 2003 20:39
To all the intellectually challenged:
This is a place for posting "tips" which are objects of
information you beleive will help other vim users.
end quote
Uhm.. If this is _not_ a place for posting "Tips" that
is supposed to help other vim users then what is this?
I do agree that the "tip" is a little useless for
seasoned vim users, you are just being too rash IMO...
Anonymous, April 29, 2003 9:58
I reached this thread instantly from gooling. The first
tip/advise/information is exacly what I needed, clear
and simple. I think people like srinath AT fastmail DOT
fm should go play with himself.
zzapper@ntlworld.com, May 21, 2003 16:41
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #419 - Auto-fold perl subs (and possibly other languages) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
<<Stop the beeping in gvim. | get rid of annoying menu/tool bar >>
Additional Notes
webmaster@topfx.com, February 3, 2003 21:49
rate
Tip #419 - Auto-fold perl subs (and possibly other languages) : vim online
Tip #419 - Auto-fold perl subs (and possibly other languages) : vim online
return "<1"
endif
let my_perldata = getline(my_perlnum)
if my_perldata =~ '^\s*\(\#.*\)\?$'
" do nothing
elseif my_perldata =~ '^\s*sub\s'
return "<1"
else
return "="
endif
endwhile
else
return "="
endif
endfunction
setlocal foldexpr=GetPerlFold()
setlocal foldmethod=expr
zak at pobox.com, February 4, 2003 0:42
The perl syntax file already has this functionality.
To enable it, just put the line:
let perl_fold=1
in your .vimrc, _vimrc or ftplugin/perl.vim.
webmaster@topfx.com, February 4, 2003 8:47
Aww man ! Why wasn't I told about this before !
Well, at least I learnt a little bit of vimscripting. The let perl_fold=1 seems to do it more
gracefully than my code.
Thanks for the tip.
Anonymous, February 7, 2003 0:05
In most cases one should look into the
$VIMRUNTIME/syntax/*.vim files. There is additional
'documentation' about extra options for folding and
syntax highlighting.
anonymous, February 10, 2003 16:44
Better yet - try ":help perl.vim" (or "help html.vim",
...)
cnf@antwerpen.be, July 4, 2003 12:15
if u put let perl_fold = 1 in your .vimrc
fold on marker doesnt work anymore
Tip #419 - Auto-fold perl subs (and possibly other languages) : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
if you also get annoyed by the menu bar and/or tool bar
in the gui version of vim, you can get rid
of them with the following:
set guioptions-=m
bar
set go-=T
bar
and then you're back to the look and feel of how vim
should always be =]
-your friendly neighbourhood garbage man.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Auto-fold perl subs (and possibly other languages) | the simplest map to highlight the current line >>
Additional Notes
Anonymous, February 10, 2003 21:21
ofcourse you can also put them back with
set guioptions += ...
Anonymous, February 10, 2003 23:06
and there might be people who do not want to think
about or figure out
HOW they have to do what they want to do - the menu
might help concentrating
on the real problem, not learning VIM.
Anonymous, February 11, 2003 23:11
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #421 - the simplest map to highlight the current line : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
Additional Notes
Anonymous, February 11, 2003 9:37
It should be either
'match Search /\%'
or
"match Search /\\%"
Anonymous, February 11, 2003 10:25
The initial
mk
is not required.
rate
Tip #421 - the simplest map to highlight the current line : vim online
Tip #421 - the simplest map to highlight the current line : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
Site Help
Interpretation
repeat the last command
enter <text> on current line, at
enter <text> on current line, at
enter <text> on current line, at next
enter <text> on current line, at the
enter <text> on a new line below
enter <text> on a new line above
replace characters by <character>
Interpretation
jump to the beginning, end of the line
left, down, up, right (you can also use
jump to the highest, middle, lowest
move up, down to the next empty line
jump to the corresponding parenthesis,
curly brace
jump to the beginning, end of the file
jump to the beginning, end of the file
jump to line <number> (without the
[[, ]]
:1, :$
<number>G
number, jumps to the
Interpretation
:r <file>
read file in
:w <file>
write current buffer to <file>
(default: write current
buffer to current file, if defined)
:w! <file>
same as write file, overriding
permissions
:wq, ZZ
write to file and quit
:wq!
write to file and quit, no matter what
:sp <file>
split window and edit file
:e <file>
edit <file>
:n
edit next file in list
:ls
list buffers
:buf <number>
edit buffer number <number>
Executing a command easily several times:
Mapped keys:
To map a key to a command to execute, type:
:map <key> <command>
Then, type <key> to execute <command>.
Macros:
To enter a macro, type:
q<character><commands>q
To execute the macro <number> (default: 1) times, type:
<number>@<character>
Important note: macros can contain calls to mapped
keys.
Registers:
To use a register named <character>, type "<character>
before your command.
Example: copying the word under the cursor and saving
into register z:
"zyw
Example: pasting the result of register c before this
word or line:
"cP
Important note 1: register characters are independent
http://www.vim.org/tips/tip.php?tip_id=422 (4 of 6) [18/02/2004 14:58:08]
Life Changing
Helpful
Unfulfilling
rate
<<the simplest map to highlight the current line | Finding more available keys to map >>
Additional Notes
Anonymous, February 12, 2003 22:31
To vi beginners I always say
"Think in English what you want to do, then type the
first letters of that words and just do it."
For Windows users it could be useful to have most of
these commands entered in the menu
until they get used to the keyboard shortcuts.
Thomas
Anonymous, February 13, 2003 9:23
Just a note about Ctrl-A and Ctrl-X. William says these
work to increment or decrement the number under the
cursor, but I have found that VIM's behavior is even more
handy: You don't have to have the cursor ON the number;
the incrementing or decrementing works for the next
number on the line on or after the cursor.
nonline@kocharhook.com, April 19, 2003 0:54
You're right about the next number after the cursor part,
but it appears Vim sticks to the same line. Still useful
as all heck. I like doing things such as "35^A".
Add Note
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<A Quick Reference | Copy, cut, and paste macros that also work in old vi >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #424 - Copy, cut, and paste macros that also work in old vi : vim online
Home
Search
Tip #424: Copy, cut, and paste macros that also work in old vi
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Tip #424 - Copy, cut, and paste macros that also work in old vi : vim online
of VIM better.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Finding more available keys to map | Forcing Syntax Coloring for files with odd extensions >>
Additional Notes
gmann@femto.med.unc.edu, February 16, 2003 18:08
Just making sure this is here as
well: http://vim.sf.net/tip_view.php?tip_id=312
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #425 - Forcing Syntax Coloring for files with odd extensions : vim online
Home
Search
Tip #425: Forcing Syntax Coloring for files with odd extensions
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Copy, cut, and paste macros that also work in old vi | Protecting a file you're referencing >>
Additional Notes
zzapper@ntlworld.com, February 13, 2003 11:45
Of course I meant
look in */vim/vim61/ftplugin
ftplugin == FileType Plugin
Anonymous, February 13, 2003 22:52
Tip #425 - Forcing Syntax Coloring for files with odd extensions : vim online
Tip #425 - Forcing Syntax Coloring for files with odd extensions : vim online
I have a number of
Tip #425 - Forcing Syntax Coloring for files with odd extensions : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Forcing Syntax Coloring for files with odd extensions | Fast window resizing with +/- keys >>
Additional Notes
Anonymous, February 19, 2003 11:15
I would also :set nomodifiable on the reference file.
zzapper@ntlworld.com, February 22, 2003 6:11
:set noma
(non modifiable)
Yes this is better than :set ro as it won't even let
you start changing stuff.
:set ro will only warn you (once)
zzapper@ntlworld.com, February 26, 2003 8:21
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #427 - Fast window resizing with +/- keys : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
gmann@femto.med.unc.edu, February 16, 2003 15:18
Depending on your screen size, and your brain's memory
capacity for more vim mappings (caution this will
affect your every day speech when vim mappings exceeds
100), you may want to increase the windows' frame size
to some preselected settings. I am sure there is a
more elegant solution for incrementing the size of this
(get the current setting into the buffer, increment it
and set it again). I am too lazy so I use full screen
and min screen based on my 1400x1050 and
guifont=lucida_console:h7:w5 " small (94 lines in one
screen)
Tip #427 - Fast window resizing with +/- keys : vim online
co=210<CR>:set lines=180<CR>
co=50<CR>:set lines=50<CR>
co=120<CR>:set lines=80<CR>
size
"my
Tip #427 - Fast window resizing with +/- keys : vim online
terminal's size)
| map <Up> <c-w>k<c-w>_<c-w><bar>
| map <Down> <c-w>j<c-w>_<c-w><bar>
| map <Left> <c-w>h<c-w>_<c-w><bar>
| map <Right> <c-w>l<c-w>_<c-w><bar>
Walking through windows and make them fullscreen at the
same time.
In addition, I've set winminwidth and winminheight to
0.
cu, Daniel
szathml@delfin.klte.hu, June 28, 2003 18:26
Using the ideas above I come up with this version :)
"Fast window resizing with +/- keys (horizontal); / and
* keys (vertical)
if bufwinnr(1)
map <kPlus> <C-W>+
map <kMinus> <C-W>map <kDivide> <c-w><
map <kMultiply> <c-w>>
endif
+ / - didn't work for me, it moved the cursor up and
down, but with kPlus, etc. it's OK.
Laszlo
fishburn@ianywhere.com, November 11, 2003 13:53
I have added the following to my vimrc file.
This came from the list, author unknown.
Holding down the SHIFT key and using the arrow keys is
quick and efficient for resizing the windows.
" Window
nnoremap
nnoremap
nnoremap
nnoremap
function! Resize(dir)
let this = winnr()
if '+' == a:dir || '-' == a:dir
execute "normal \<c-w>k"
let up = winnr()
if up != this
execute "normal \<c-w>j"
http://www.vim.org/tips/tip.php?tip_id=427 (3 of 4) [18/02/2004 14:58:20]
Tip #427 - Fast window resizing with +/- keys : vim online
let x = 'bottom'
else
let x = 'top'
endif
elseif '>' == a:dir || '<' == a:dir
execute "normal \<c-w>h"
let left = winnr()
if left != this
execute "normal \<c-w>l"
let x = 'right'
else
let x = 'left'
endif
endif
if ('+' == a:dir && 'bottom' == x) || ('-' == a:dir
&& 'top' == x)
return "5\<c-v>\<c-w>+"
elseif ('-' == a:dir && 'bottom' == x) || ('+' ==
a:dir && 'top' ==
x)
return "5\<c-v>\<c-w>-"
elseif ('<' == a:dir && 'left' == x) || ('>' ==
a:dir && 'right' ==
x)
return "5\<c-v>\<c-w><"
elseif ('>' == a:dir && 'left' == x) || ('<' ==
a:dir && 'right' ==
x)
return "5\<c-v>\<c-w>>"
else
echo "oops. check your ~/.vimrc"
return ""
endif
endfunction
" /*}}}*/
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Fast window resizing with +/- keys | Using '< and '> marks >>
Additional Notes
cec@NgrOyphSon.gPsfAc.nMasa.gov, February 20, 2003 8:27
How about a small mod:
noremap! <C-Y> <Esc>klyWjPa
cec@NgrOyphSon.gPsfAc.nMasa.gov, February 25, 2003 11:43
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
cec@NgrOyphSon.gPsfAc.nMasa.gov, February 20, 2003 8:18
gv is even easier!
Max Ischenko, February 21, 2003 6:04
> gv is even easier.
To repeat an Ex command (like :s) you don't have to
reselect block at all, so gv is not needed.
That's the point of this tip.
yeti@physics.muni.cz, February 21, 2003 9:52
Most people can type gv: much faster than :'<,'> (just
try it :-)
Moreover, gv makes the selection visible. (Yes, I know,
it's very non-vi to have a visual feedback for what you
are doing ;-)
Max Ischenko, February 24, 2003 1:20
> Most people can type gv: much faster than :'<,'>
I bet typing :<Up> still faster then gv:<Up>.
rickismyid@yahoo.com, March 5, 2003 5:09
I think just pressing the period will work too. Unless
I'm missunderstanding what is being done.
jaldri1 at gl dot umbc dot edu, June 6, 2003 12:47
So, I can start a visual block with <c-v> (win: <c-q>
|CTRL-V-alternative|) at the start of some columen and
select some text with, say, 4j$.
Now I have a
highlighted selection.
I can press y to yank. If I
press :, ex mode starts with :'<,'> already filled
in. If I press !, I get :'<,'>!. Unfortunately, if I
enter an external command such as sort, it operates on
the whole lines (^.*$) not just the column of the
visual block.
Anyway, I can yank and move elsewhere, paste, and then
return to the original selection with gv (not
:gv). And, that selection will be highlighted just as
before.
I can also use '< to move to the first line
of the selection or '> to move to the last line of the
selection.
Have I explained it well enough, or was there more
intended?
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
vigor96@linux.co.kr, March 4, 2003 16:35
it is better than using "write buffer" to ":set hidden"
salmanhalim@hotmail.com, March 5, 2003 6:06
Instead of doing all these checks, if you want the
buffer to be written automatically if you move away and
it's been modified, why not simply set 'autowrite' in
your vimrc? That way, you can map to simply :bn<cr> or
:bp<cr>. (It won't discard the buffer if autowrite is
NOT set -- it'll give you an error message.)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #431 - map to toggle between backslash and forwardslash : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #431:
map to toggle between backslash and forwardslash
tip karma
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Fast switching between buffers | Putting the current file on the Windows clipboard >>
Additional Notes
salmanhalim@hotmail.com, March 5, 2003 6:24
Tip #431 - map to toggle between backslash and forwardslash : vim online
Tip #431 - map to toggle between backslash and forwardslash : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #432 - Putting the current file on the Windows clipboard : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<
map to toggle between backslash and forwardslash | a rough mapping to spellcheck the buffer >>
Additional Notes
salmanhalim@hotmail.com, March 5, 2003 6:42
As an addendum, I didn't want to make a mapping out of
this because I don't do it often enough; however, one
can easily do something like:
:map <leader>cf :Copyfile<cr>
I noticed that hitting :C<tab> was almost as fast as
the mapping characters anyway.
maxiangjiang@hotmail.com, March 5, 2003 7:52
Tip #432 - Putting the current file on the Windows clipboard : vim online
Tip #432 - Putting the current file on the Windows clipboard : vim online
For vim rookies -like me- the way to copy current file
content in Windows clipboard is
:1,$ y *
that is, yanking from line 1 to end-of-file represented by $- into register '*'. After that, go to
Notepad and do a simply CTRL + V. And map it, if you
want
:map <F3> :1,$ y * <CR>
maxiangjiang@hotmail.com, March 9, 2003 20:04
simpler one:
:%y*<CR>
Anon, March 10, 2003 6:02
The file-content copy things probably should be a
separate tip altogether. Plus, it's not complete
without a mention of the 'clipboard' and 'guioptions'
options. Try :help gui-clipboard for more details.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
well, certainly
well, certainly there are plugins to do this much
better, but, if you
like to have most of the stuff placed on your vimrc
file, the
following must help:
map ,SS :exec system("ispell -l -t -d br <
".expand("%")." \| sort -u \| sed 's/\\(.*\\)/syntax
match Underlined \"\\\\<\\1\\\\>\" contains=TOP /'")
basically, i use 'ispell' to collect all misspelled
words, and assign
each one to the 'Underlined' syntax group (seems better
than 'Error')
=]
improvements aren't so hard to do; actually, I use
another mappings
for another 'spell' functions, but the essential can fit
in just one
line;
leorosa
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Putting the current file on the Windows clipboard | Autogroup commands for C/C++ editing inserting skeletons etc (long post!) >>
Additional Notes
Anonymous, March 5, 2003 11:29
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #434 - Autogroup commands for C/C++ editing - inserting skeletons etc (long post!) : vim online
Home
Search
Tip #434: Autogroup commands for C/C++ editing - inserting skeletons etc (long post!)
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Hi all,
When you start editing a *.h file, you'd need some format like this:
CODE STARTS:
/*****************************************************************
* Filename: abc.h
* Description:
* Created: Mar 5 03 09:00:00
* Last modified: Mar 6 03 09:00:00
* <some more stuff like author, copyright, blah-blah>
*
* Revision History
*
Date
Author
Remarks
*
Mar 5 2003
KG
File Created
*******************************************************************/
#ifndef _ABC_H_
#define _ABC_H_
#endif
// vim:ts=3:sw=3:ft=c
CODE ENDS
I wanted my gvim to do the following things at various stages of editing a abc.h
file:
1. Upon opening a new file, insert the skeleton like the one above, and leave me in
insert mode after "Description"
2. When writing a file, update the "Last Modified" timestamp
3. On opening a existing file, modify the "Revision History" to add a new line, and
leave me in insert mode below "Remarks"
Tip #434 - Autogroup commands for C/C++ editing - inserting skeletons etc (long post!) : vim online
The following autogroup (:help au) commands let you do these (put these in your
.vimrc):
CODE STARTS:
if !exists("autocommands_loaded")
let autocommands_loaded = 1
au BufNewFile *.h call InsertCHHeader()
au BufWrite *.h call ModifyTime()
" You might want to comment-out the line below - see note 6 at the end of the
post.
au BufReadPost *.h call ModifyHeader()
endif
function! InsertCHHeader()
call InsertSkeleton("skeleton.h")
call InsertFname()
1
" Search for Description
call search("Description:")
normal $
startinsert
endfunction
function! InsertSkeleton(fname)
let path_to_skeletons = $HOME . "/etc/skeletons/" " CHANGE this!
" Save cpoptions
let cpoptions = &cpoptions
" Remove the 'a' option - prevents the name of the
" alternate file being overwritten with a :read command
exe "set cpoptions=" . substitute(cpoptions, "a", "", "g")
exe "read " . path_to_skeletons . a:fname
" Restore cpoptions
exe "set cpoptions=" . cpoptions
" Delete the first line into the black-hole register
1, 1 delete _
" Search for Filename:
call search("Filename:")
exe "normal A " . expand("%:t")
" Search for Created:
let current_time = strftime("%b %d %Y %T") "CHANGE this!
call search("Created:")
exe "normal A " . current_time
" Search for Last modified:
http://www.vim.org/tips/tip.php?tip_id=434 (2 of 6) [18/02/2004 14:58:37]
Tip #434 - Autogroup commands for C/C++ editing - inserting skeletons etc (long post!) : vim online
Tip #434 - Autogroup commands for C/C++ editing - inserting skeletons etc (long post!) : vim online
startinsert
endif
endif
endfunction
function! ModifyTime()
" Do the updation only if the current buffer is modified
if &modified == 1
let current_time = strftime("%b %d %Y %X") " CHANGE this!
" Save current position at mark i
normal mi
" Search for Last modified:
let modified_line_no = search("Last modified:")
if modified_line_no != 0 && modified_line_no < 10
" There is a match in first 10 lines
" Go to the : in modified:
exe "normal f:2l" . strlen(current_time) . "s" . current_time
echo "Modified date stamp to " . current_time
sleep 500m
" Restore position
normal `i
endif
endif
endfunction
CODE ENDS
Notes:
1. The strftime( ) function is not-portable. You might need to change the format
specifier for your system
2. The autogroup commands assumes that there is a file called skeleton.h at the
location ~/etc/skeletons.
You might have to modify the path and file name. In my case, the skeleton.h
file looks like:
/******************************************************************************
* Filename:
* Description:
*
* Version: 1.0
* Created:
* Last modified:
* Revision: None
*
http://www.vim.org/tips/tip.php?tip_id=434 (4 of 6) [18/02/2004 14:58:37]
Tip #434 - Autogroup commands for C/C++ editing - inserting skeletons etc (long post!) : vim online
* Author:
Karthick Gururaj
* Company: [Removed]
* e-mail: [Removed]
*
* Revision history
* Date
Author
Remarks
*
******************************************************************************/
#ifndef
#define
#endif
// vim:sw=3:ts=3
Search the script for the pattern "CHANGE" to see where you might have to make
changes..
3. I have not tried to make the script super-portable (that looks obvious eh?). The
reasoning is, any changes are a one time effort.
4. The scripts don't modify search history or register values. I have used one
letter for marking thou'
5. If you open a new header file, and quit it without writing, no file is created.
6. I found having an autogroup command for modifing the revision history everytime
the file is opened to be irritating. So I have disabled this in my system. Note on
note: I also had some problems when trying to open the file thro' the quickfix
window.
7. You can define more such skeletons for other extentions.
8. Feedback is welcome!
Cheers!
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<a rough mapping to spellcheck the buffer | remarks to script c.vim : statement oriented editing of C / C++ programs >>
Additional Notes
salmanhalim@hotmail.com, March 8, 2003 11:37
Tip #434 - Autogroup commands for C/C++ editing - inserting skeletons etc (long post!) : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #435 - remarks to script c.vim : statement oriented editing of C / C++ programs : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Autogroup commands for C/C++ editing - inserting skeletons etc (long post!) | Accidently typed
control-u and lost your input? >>
Additional Notes
Tip #435 - remarks to script c.vim : statement oriented editing of C / C++ programs : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #436 - Accidently typed control-u and lost your input? : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<remarks to script c.vim : statement oriented editing of C / C++ programs | extending keywords >>
Additional Notes
sb@c-lab.de, March 7, 2003 3:36
If you don't want to change register a, use
:dis .
to see the contents of the . register, than yank with
the mouse.
/Siegfried
Anonymous, March 7, 2003 7:27
Tip #436 - Accidently typed control-u and lost your input? : vim online
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
1. edit your c.vim file [if you are coding c/c++] try
'vim61/runtime/syntax/' for location of these files,
and add the keywords in the correct groups,
2. the second way is you can put them all in a separate
file, and source it, eg:
say i had some new c types, called uTask or uMutex i
could get them highlighted as types
using the following command:
:syn keyword type uTask uMutex uNoMutex [etc..]
enjoy.
.. hzp.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Accidently typed control-u and lost your input? | Search/replace "within selection" in gvim using '< '>
>>
Additional Notes
salmanhalim@hotmail.com, March 8, 2003 11:29
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #438 - Search/replace "within selection" in gvim using '< '> : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
martine@cs.washington.edu, March 8, 2003 23:54
If you visually select a region (use "v") and hit
colon, it fills those extents in by default (or it at
least does so for me...).
salmanhalim@hotmail.com, March 9, 2003 8:22
It does that for all three visual selection types;
furthermore, if you get out of a visual selection but
decide that you want to then act on it again, hitting
gv will get you the last visual selection from where
you can type : to get the '<,'> bit (gv: is faster to
type).
http://www.vim.org/tips/tip.php?tip_id=438 (1 of 2) [18/02/2004 14:58:46]
Tip #438 - Search/replace "within selection" in gvim using '< '> : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Search/replace "within selection" in gvim using '< '> | Automatic formatting of paragraphs >>
Additional Notes
janjaapsandee@hotmail.com, March 14, 2003 5:10
I usually just do
:1,$s/{string}/{newstring}/g
the 1,$ can be replaced with any valid range of line
numbers.
Works quite fast. Except when certain strings should
not be replaced.
Anonymous, April 23, 2003 11:58
If certain strings should not be replaced, just add a
'c' (for confirm) at the end of your expression:
s/origword/neword/gc
This way, vim will ask you before each replace.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Replace text in highlighted search | Toggle auto-wrap using txtwidth in INSERT mode >>
Additional Notes
Anonymous, March 10, 2003 10:41
not bad, but if you do
set linebreak
set breakat=\
set nolist
, and place a mapping:
"move one 'corsor-line' line instead of one 'code-line'
up/down
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
you can also type and edit paragraphs, and will never
need to format it (because it will keep one long line
:)
yeti@physics.muni.cz, March 11, 2003 1:27
Keeping paragraphs as a one long line is a pretty bad
idea if the text is to be read by other people, with
other tools.
maxiangjiang@hotmail.com, March 11, 2003 9:26
This is double-edge settings.
I found it is a disaster for editing scripts, such as
vimrc and jsp,
but very good for editing free-style text file.
To get the best of both worlds, I used the following:
au BufEnter *.txt setl tx ts=4 sw=4 fo+=n2a
(Only all *.txt files will use this auto thing)
Stanislav Sitar, March 12, 2003 2:02
Reaction on notes.
There a few people that were demanding such
functionality
some time ago on the Vim mailing list. So when I saw
that
auto-format thing mentioned, I thought that some people
might be interested.
Of course auto-format is only useful in very specific
situations.
Like when I type mail AND I want to have list
characters switched
on. Sometimes I want to see control characters like
tabs, trailing
spaces and line feeds, so I do ':set list' but when I
do that, the
long lines are not wraped visualy on word boundaries.
For me,
this is the most annoying feature in Vim. I like to
have list enabled
all the time AND I would like to see long lines wraped
properly at
the same time. This is just a dirty workaround.
Stano
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #441 - Toggle auto-wrap using txtwidth in INSERT mode : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
complexity: basic
as of Vim: 6.0
Scripts
Tips
My Account
Site Help
Tip #441 - Toggle auto-wrap using txtwidth in INSERT mode : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Automatic formatting of paragraphs | Show all lines that contain keyword under cursor >>
Additional Notes
maxiangjiang@hotmail.com, March 11, 2003 14:33
I found on UNIX, we don't need the last part of the
map.
im <C-B> <C-O>:setl sr! fo<C-R>=strpart("+",&sr,1)<CR>=tc<CR>
maxiangjiang@hotmail.com, March 12, 2003 10:16
Just found that it is not related UNIX or Windows.
It is a settting of virtualedit. For current vim
version (6.1), if we
:set virtualedit=insert
We need the last part in the map, otherwise, we don't
need it.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #442 - Show all lines that contain keyword under cursor : vim online
Home
Search
Tip #442: Show all lines that contain keyword under cursor
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Toggle auto-wrap using txtwidth in INSERT mode | A better interfacing of (La)TeX with the quickfix
mode >>
Additional Notes
Anonymous, March 15, 2003 19:48
This is kind of useful but is there any way so that you
can run [I on all loaded buffers (or all files in a
directory)?
Anonymous, March 17, 2003 2:55
Actually, the [I is even more powerfull than that. It
does not search only current buffer, but also included
files, where meaning of 'included' depends on settings,
but defaults are set for C (i.e., #included files,
searched in ., /usr/include and maybe elsewhere). It is
really good thing.
To previous comment, :grep would be probably more
appropriate...
Anonymous, March 18, 2003 23:14
Tip #442 - Show all lines that contain keyword under cursor : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #443 - A better interfacing of (La)TeX with the quickfix mode : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Tip #443 - A better interfacing of (La)TeX with the quickfix mode : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Show all lines that contain keyword under cursor | quickfix show entire contents of multiline error in
cwindow on cn, cp and cc >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #444 - quickfix show entire contents of multiline error in cwindow on cn, cp and cc : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
<<A better interfacing of (La)TeX with the quickfix mode | Formatting stuff >>
Additional Notes
rate
Tip #444 - quickfix show entire contents of multiline error in cwindow on cn, cp and cc : vim online
" \cc
map <Leader>cc :cwindow<cr>:cc<cr><c-w>bz<cr><cr>
" \cn
map <Leader>cn :cwindow<cr>:cn<cr><c-w>bz<cr><cr>
" \cp
map <Leader>cp :cwindow<cr>:cp<cr><c-w>bz<cr><cr>
Ok, that should work.
"z<cr>" will reposition the buffer in the window so
that the current line becomes the top line in the
window
garyjohn@spk.agilent.com, March 17, 2003 23:03
Another solution to this problem is to "set
cmdheight=2" which will provide
two lines at the bottom of the screen for quickfix
error lines instead of the
default one.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Hello all, Im new to VIM, but I wanted to post some of my ideas for
everyone here. Mark T, a friend of mine, just reciently got me in to
VIM and I havent looked back yet! I really like this program, and I
feel it's a valuable tool.
Mark and I program in Lisp and Visual lisp for AutoCAD. (Its a program
for drafting) and I have been adding stuff to my 'rc' file for lisp
programing for abbout a month now. Mark has convinced me to post some
tips here. So here they are:
**********************************************************************
imap <Backspace> <left><del>
" this will allow me to always use the backspace key in insert mode
imap <C-j> <Esc>Ji
" this will allow me to join a line while still in insert mode
map .f v%zf
" fold an entire block of code
nnmap ,y <S-v>y
" This will select a whole line of text or it will select
" everything in a fold.
map .; v%:s/^/;;;/<CR>:noh<CR>
" comments out and entire block of code from paren to paren
:au BufRead *.lsp :loadview 1<cr>
:au BufRead *.LSP :loadview 1<cr>
" load the first fold view file for the current file
map st :set tw=70<cr>v<S-}>gq<End>
" this will allow you to format an entire block of text
**********************************************************************
John
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<quickfix show entire contents of multiline error in cwindow on cn, cp and cc | Quick and dirty Postgres query >>
Additional Notes
Anonymous, March 19, 2003 1:11
http://www.vim.org/tips/tip.php?tip_id=445 (1 of 2) [18/02/2004 14:59:06]
Hi!
Welcome to vim.
Regarding imap <backspace> ... you might want to
:help 'bs'
sitar at procaut.sk, March 19, 2003 2:44
You can also do
imap <C-j> <Esc>Ji
this way
imap <C-j> <C-o>J
this way you do not leave insert mode.
You might also consider using
inoremap <C-j> <C-o>J
I personaly use quite a few '<C-o> style' mappings
Most of them from example_vimrc file ;-)
see
:help i_CTRL-O
Anonymous, March 19, 2003 8:59
Hello there. Thanx for the welcome.
I will look into these sugestions you have given me, but if there
are any more, please keep 'em comming. (I would really like to learn
more.)
Thank you.
Anonymous, March 21, 2003 4:47
I found out more about the Backspace topic in the help file and in
the example rc file. Thanx for the tip.
set backspace=indent,eol,start
" allow backspacing over everything in insert mode
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Formatting stuff | Use the upper-lower case ~, also on Windows (ita) >>
Additional Notes
David Fishburn, March 24, 2003 13:04
You could also consider use the database extension
plugin for Vim, which provides a lot of features for
Postgress.
db_ext.vim
http://vim.sourceforge.net/script.php?script_id=356
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #447 - Use the upper-lower case ~, also on Windows (ita) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Quick and dirty Postgres query | Yank (copy) decimal numbers from hex numbers. >>
Additional Notes
Add Note
Tip #447 - Use the upper-lower case ~, also on Windows (ita) : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #448 - Yank (copy) decimal numbers from hex numbers. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Tip #448 - Yank (copy) decimal numbers from hex numbers. : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Use the upper-lower case ~, also on Windows (ita) | FORTRAN highlighting problems >>
Additional Notes
Anonymous, March 26, 2003 4:11
There is a way of doing this without changing the
search history
map \y :let @*=<C-R><C-W> +0<cr>
And a way to not change the " * " register contents
would be to use some global variables instead I
guess...Some think like
map \y :let g:HexYank=<C-R><C-W> +0<cr>
for yanking, and..
map \p :if exists("g:HexYank") <Bar> exe "normal i"
. g:HexYank <Bar> endif <cr>
for pasting
- Me Thinks
Anonymous, March 28, 2003 17:20
"<some-register>yiw
should also work instead of searching.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
" set
Life Changing
Helpful
Unfulfilling
rate
<<Yank (copy) decimal numbers from hex numbers. | Working with multiple sessions >>
Additional Notes
syrion@freesbee.fr, March 26, 2003 5:50
This one placed before "syntax on" works better:
au BufRead *.for let b:fortran_fixed_source=1
FB
Anonymous, March 26, 2003 23:34
You can also add the following line to a source file:
C
vim:set ft=fortran:
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
CODE STARTS
au VimLeave * call VimLeave()
au VimEnter * call VimEnter()
let g:PathToSessions = $HOME . "/.vim/sessions/"
function! VimEnter()
if argc() == 0
" gvim started with no files
if has("browse") == 1
let g:SessionFileName = browse(0, "Select
Session", g:PathToSessions, g:PathToSessions .
"LastSession.vim")
if g:SessionFileName != ""
exe "source " . g:SessionFileName
endif
else
" For non-gui vim
let LoadLastSession = confirm("Restore last
session?", "&Yes\n&No")
if LoadLastSession == 1
exe "source " . g:PathToSessions .
"LastSession.vim"
endif
endif
endif
endfunction
function! VimLeave()
exe "mksession! " . g:PathToSessions .
"LastSession.vim"
if exists("g:SessionFileName") == 1
if g:SessionFileName != ""
exe "mksession! " . g:SessionFileName
endif
endif
endfunction
" A command for setting the session name
com -nargs=1 SetSession :let g:SessionFileName =
g:PathToSessions . <args> . ".vim"
" .. and a command to unset it
com -nargs=0 UnsetSession :let g:SessionFileName = ""
CODE ENDS
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<FORTRAN highlighting problems | KDE Konsole renameSession to edited file name >>
Additional Notes
bertilow@gmx.net, March 27, 2003 7:48
Nice tip, but I had to change the code a lot before I
got it to work.
Perhaps your setup (or platform) is somehow different
from mine...
Anyway, here's my code. It works great for me:
------------------------------------------------------------au VimLeave * call VimLeave()
au VimEnter * call VimEnter()
let g:PathToSessions = $HOME . "/.vim/sessions"
function! VimEnter()
if argc() == 0
" gvim started with no files
if has("browse") == 1
let g:SessionFileName = browse(0, "Select
Session", g:PathToSessions, "/LastSession.vim")
if g:SessionFileName != ""
exe "source " . g:SessionFileName
endif
else
" For non-gui vim
let LoadLastSession = confirm("Restore last
session?", "&Yes\n&No")
if LoadLastSession == 1
exe "source " . g:PathToSessions .
"/LastSession.vim"
endif
endif
endif
endfunction
function! VimLeave()
exe "mksession! " . g:PathToSessions .
"/LastSession.vim"
if exists("g:SessionFileName") == 1
if g:SessionFileName != ""
exe "mksession! " . g:SessionFileName
endif
endif
endfunction
" A command for setting the session name
com! -nargs=1 SetSession :let g:SessionFileName =
g:PathToSessions . "/" . <args> . ".vim"
" .. and a command to unset it
com! -nargs=0 UnsetSession :let g:SessionFileName = ""
------------------------------------------------------------Anonymous, March 31, 2003 9:45
consider putting this in the scripts section rather
than the tips section.
tony.young@ir.com, March 31, 2003 23:47
I had to had a line to VimEnter:
exe "source ~/.vim/syntax/mysyntax.vim"
to keep my personal syntax highlighting.
Sourcing the session file seemed to switch the
highlighting back to the default.
Apart from that it was an excellent tip
bertilow@gmx.net, April 2, 2003 2:28
One more detail:
Instead of
:SetSession PROJ1
I find I have to do
:SetSession "PROJ1"
Me Thinks
function! VimEnter()
if argc() == 0
let LoadLastSession = confirm("Restore last
session?", "&Yes\n&No")
if LoadLastSession == 1
exe "source " . g:PathToSessions .
"/LastSession.vim"
else
call LoadSessions()
endif
endif
endfunction
function! LoadSessions()
let result = "List of sessions:"
let sessionfiles = glob(g:PathToSessions .
"/*.vim")
while stridx(sessionfiles, "\n") >= 0
let index = stridx(sessionfiles, "\n")
let sessionfile = strpart(sessionfiles, 0,
index)
let result = result . "\n " .
fnamemodify(sessionfile, ":t:r")
let sessionfiles = strpart(sessionfiles, index
+ 1)
endwhile
let result = result . "\n " .
fnamemodify(sessionfiles, ":t:r")
let result = result . "\n" . "Please enter a
http://www.vim.org/tips/tip.php?tip_id=450 (5 of 6) [18/02/2004 14:59:19]
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #451 - KDE Konsole renameSession to edited file name : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Working with multiple sessions | Unix: Editing multiple files, listed in a file, one per line, from the
command-line >>
Additional Notes
me again, March 28, 2003 13:04
This one set the title to the current working dirctory
when you leave vim.
autocmd VimLeavePre * :silent !dcop
$KONSOLE_DCOP_SESSION renameSession $PWD
lamba@faatc.com, April 8, 2003 23:19
Tip #451 - KDE Konsole renameSession to edited file name : vim online
Tip #451 - KDE Konsole renameSession to edited file name : vim online
chdir \!*;\\
setprompt;\\
set cds = ( $cds $cwd );\\
echo $cds'
#
alias lastdir
$cwd );\\
#
setprompt
#
### -------------------------------------------------------------#
#
### -------------------------------------------------------------# This is where the title bar of the xterm is set.
#
alias date '/bin/date "+%A, %B %e, %Y Time: %H:%M:%S"'
#
if ($?tcsh) then
#
set prompt="$host{`whoami`}%\!: "
#
if ($?term) then
alias cwdcmd 'echo -n "^[]2;" "$USER on
$host : $cwd
`date`^G"'
cwdcmd
endif
#else # regular csh
#
set prompt="$hostnm{`whoami`}\!: "
#
if ($term == xterm) echo -n "^[]0;$hostnm^G"
endif
#
### -------------------------------------------------------------Note: In the alias cwdcmd line, after the `echo -n
"^[]2;" the ^[ is a control h,
I think.
This is why I aliases vi to 'setenv mydate `vimdate` ;
/usr/bin/vim \!* ; cd `pwd`
When I do a cd `pwd` it automatically changes my title
bar to:
http://www.vim.org/tips/tip.php?tip_id=451 (3 of 4) [18/02/2004 14:59:21]
Tip #451 - KDE Konsole renameSession to edited file name : vim online
me on machine : $PWD
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #452 - Unix: Editing multiple files, listed in a file, one per line, from the command-line : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #452: Unix: Editing multiple files, listed in a file, one per line,
from the command-line
tip karma
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<KDE Konsole renameSession to edited file name | Use Taglist with LaTeX files >>
Additional Notes
salmanhalim@hotmail.com, March 29, 2003 8:05
Once the files have been loaded, why not just execute a
bufdo? It'll execute the same command (a :g/<expr>/d,
in this case) in all buffers.
Anonymous, March 31, 2003 12:48
Tip #452 - Unix: Editing multiple files, listed in a file, one per line, from the command-line : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
:Tlist
or see taglist doc
references :
Taglist :
http://www.vim.org/scripts/script.php?script_id=273
ctags : http://ctags.sourceforge.net
Vim-LaTeX : http://vim-latex.sf.net/
Life Changing
Helpful
Unfulfilling
rate
<<Unix: Editing multiple files, listed in a file, one per line, from the command-line | Syntax Highlighting
Keeps Breaking (and how to fix it!) >>
Additional Notes
xurelo AT onetel DOT net DOT uk, April 14, 2003 10:49
Could this be extended to work recursively?
iago
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #454 - Syntax Highlighting Keeps Breaking (and how to fix it!) : vim online
Home
Search
Tip #454: Syntax Highlighting Keeps Breaking (and how to fix it!)
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
<<Use Taglist with LaTeX files | Map a function key to toggle line wrapping >>
rate
Tip #454 - Syntax Highlighting Keeps Breaking (and how to fix it!) : vim online
Additional Notes
cec@NgrOyphSon.gPsfAc.nMasa.gov, April 16, 2003 8:32
syn sync fromstart
makes for improved accuracy in syntax highlighting, but
at a price: sluggish screen updating. This command is
telling vim to parse from the beginning of the file
every time the screen needs updating. Long files and
languages that involve complex highlighting rules will
be adversely affected, moreso, of course, on older
(slower) computers. Fair warning!
private, April 16, 2003 12:02
sluggish screen updates vs. constantly messed up syntax
highlighting == easy choice
I was about to give up on vim entirely before I found
out about this.
Since vim is basically useless if
everytime you page down or pageup it breaks you syntax
highlighting.
cec@NgrOyphSon.gPsfAc.nMasa.gov, April 17, 2003 8:58
Depends on how sluggish!
As a less sluggish alternative, something like
syn sync minlines=200
may be of help. That tells vim to start looking for
synchronization points 200 lines previous in the file;
use more if one needs to and fewer to improve
speed. The problem occurs in recognizing large
regions. Consider a large list of equations in LaTeX,
say 100 of them, one per line. With the screen
starting its display in the middle of the list, proper
highlighting will occur only if vim recognizes that its
in the middle of a list of equations. It needs to hunt
backwards to do this. If the minlines is too small, it
won't see the \begin{eqnarray} and so highlighting will
be incorrect. Set minlines too large or use the
fromstart suggestion, and vim will be doing a lot of
extra work that gets thrown away at every screen
refresh.
On the other hand, if one has a multi-gigahertz
machine, extra cpu work is cheap.
http://www.vim.org/tips/tip.php?tip_id=454 (2 of 3) [18/02/2004 14:59:29]
Tip #454 - Syntax Highlighting Keeps Breaking (and how to fix it!) : vim online
:)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #455 - Map a function key to toggle line wrapping : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Syntax Highlighting Keeps Breaking (and how to fix it!) | escape select mode in a map command
(used to map indent in select mode) >>
Additional Notes
maxiangjiang@hotmail.com, April 15, 2003 16:49
nn <F6> :setl wrap!<Bar>echon "wrap="&wrap<CR>
mike@mester.demon.co.uk, April 16, 2003 4:14
" Map F6 to toggle wrap on and off
imap <silent> <F6> <Esc>:set wrap!<CR>a
nmap <silent> <F6> :set wrap!<CR>
yeti@physics.muni.cz, April 20, 2003 12:29
Tip #455 - Map a function key to toggle line wrapping : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #456 - escape select mode in a map command (used to map indent in select mode) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
<Tab>
<S-Tab>
^0
^0
>
<
Life Changing
Helpful
Unfulfilling
rate
<<Map a function key to toggle line wrapping | Follow tag in new window >>
Additional Notes
Anonymous, April 16, 2003 12:32
The maps in this post have a space following the > and
<. This is probably ok
unless one has mapped <space> to something. If you
have mapped <space> be sure
to remove the trailing space if you copy/paste from
this post.
Anonymous, September 19, 2003 13:36
"Shit-Tab" - too cool.
Anonymous, September 19, 2003 13:36
Tip #456 - escape select mode in a map command (used to map indent in select mode) : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Site Help
<<escape select mode in a map command (used to map indent in select mode) | How to use quickfix
mode to see all errors in one window (:cwindow). >>
Additional Notes
James.A.Paget@aero.org, April 16, 2003 13:20
This creates a new window of maximal size and the
original window
shrinks to one line. To have the windows be of equal
size, just
eliminate the "<C-w>_" at the end.
Gary Johnson <garyjohn@spk.agilent.com>, April 16, 2003 14:17
Why not just 'CTRL-W ]'?
Anonymous, April 17, 2003 11:51
Why not <C-W>]? Because I did not know of that command
when I thought of this.
Thanks for the lesson.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #458 - How to use quickfix mode to see all errors in one window (:cwindow). : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #458: How to use quickfix mode to see all errors in one window
(:cwindow).
tip karma
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Follow tag in new window | Use Ctrl-O instead of Esc in insert mode mappings >>
Additional Notes
jallen@cashsystemsinc.com, April 30, 2003 7:19
I think you have to add a colon:
:help :cw
jallen@cashsystemsinc.com, April 30, 2003 8:20
not :help cw
but
Tip #458 - How to use quickfix mode to see all errors in one window (:cwindow). : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #459 - Use Ctrl-O instead of Esc in insert mode mappings : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<How to use quickfix mode to see all errors in one window (:cwindow). | how to implement vertical
lines showing tab groups.. >>
Additional Notes
dat1965@yahoo.com, May 2, 2003 23:52
Tip #459 - Use Ctrl-O instead of Esc in insert mode mappings : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #460 - how to implement vertical lines showing tab groups.. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Use Ctrl-O instead of Esc in insert mode mappings | Open a Perl module based on it's module
name >>
Additional Notes
Anonymous, April 21, 2003 13:35
Tip #460 - how to implement vertical lines showing tab groups.. : vim online
Tip #460 - how to implement vertical lines showing tab groups.. : vim online
Tip #460 - how to implement vertical lines showing tab groups.. : vim online
Gowri,
I've installed the script at
http://www.vim.org/scripts/script.php?script_id=627
with the change you suggested
cec@NgrOyphSon.gPsfAc.nMasa.gov, April 25, 2003 14:11
Hello!
OK, I've put my version, vimscript#628.
both
expandtab on and off cases. Enjoy!
It now handles
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #461 - Open a Perl module based on it's module name : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<how to implement vertical lines showing tab groups.. | G's of Vim >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
complexity: intermediate
as of Vim: 5.7
Hi Guys !!
You can play with THE "g" in VIM editor.
Scripts
Tips
My Account
Try this
Site Help
gd
will take you to the local declaration
gD
will take you to the global declaration.
g*
search for the word under the cursor. It's
just like * but don't put < or > around words
so here you can search word which contains
word under your cursor
Confused ???? try it NOW :-)
g#
same as g* but in backward direction
Life Changing
Helpful
Unfulfilling
rate
<<Open a Perl module based on it's module name | XSLT Mappings I use to speed up developing
XSLT files. >>
Additional Notes
Anonymous, April 23, 2003 11:25
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #463 - XSLT Mappings I use to speed up developing XSLT files. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
<<G's of Vim | search & replace the word under the cursor >>
Unfulfilling
rate
Tip #463 - XSLT Mappings I use to speed up developing XSLT files. : vim online
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #464 - search & replace the word under the cursor : vim online
Home
Search
Tip #464: search & replace the word under the cursor
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<XSLT Mappings I use to speed up developing XSLT files. | generic xml imap to make an element of
any word you type >>
Additional Notes
gmann, April 27, 2003 14:55
I am curious how this is more beneficial than cw ? Am
I missing something? One more keystroke? Thanks for
any advice.
maurice, April 27, 2003 15:08
As mentioned, this opens the prompt for search &
replace, which applies to the whole buffer and not only
for the one occurrence of the word.
Anonymous, April 27, 2003 17:14
your script is interesting, but non-standard, that's
why it's not very useful
http://www.vim.org/tips/tip.php?tip_id=464 (1 of 4) [18/02/2004 14:59:53]
Tip #464 - search & replace the word under the cursor : vim online
Tip #464 - search & replace the word under the cursor : vim online
Oh.. never used this jumps. But after trying them out
it seems that I will do this in the future. Very cool
:)
Guess I have to map this replace-stuff to another
key...
What is this non-standard-thing? Thought that if its
listed in the vim help, it is ok :)
gmann, April 30, 2003 20:06
Thanks for the clarification Maurice. The tip is quite
nice, standard or not. I like the jumps as well (vi =
very impressive). This would also be nice to map along
with the AllBuffers method, can you think of how I can
map this, so that I can do the same thing across all
buffers which I have open? Something like the
following (which doesn't work)
map <M-t> :call AllBuffers(":%s/\<<c-r><c-w>\>/
Maurice, May 1, 2003 8:22
I don't know about a function 'AllBuffers'. But I think
what you want is the bufdo-command.
Your mapping would be something like this:
map <M-t> :bufdo :%s/\<<c-r><c-w>\>/
JonathanOrlev@yahoo.com, May 21, 2003 1:55
Great macro, thanks.
I have a small question:
When entering this line as it is to my .vimrc file, the
last '/' "messes" the syntax of the configuration
file.
IE: it changes the colors of some of the following
commands. This is probably due to the special role of
'/' .
I "solved" it by removing the '/' (and I enter it
manually whenever I need to use the macro).
Any better advice ?
Regards,
Jonathan Orlev.
atum@gmx.de, May 21, 2003 2:01
Tip #464 - search & replace the word under the cursor : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #465 - generic xml imap to make an element of any word you type : vim online
Home
Search
Tip #465: generic xml imap to make an element of any word you type
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Hi all.
We're doing a lot of xml work, in docbook and custom xml
files.
I'd just like to share one macro I've developed, that I
really can't live without.
imap ,,, <esc>bdwa<<esc>pa><cr></<esc>pa><esc>kA
If in isert mode I type programlisting,,,
the text immediately get's modified to
<programlisting>
</programlisting>
with the cursor in between, still in Insert mode.
The same happens with any other word i type followed by
three commas.
<tryit>
</tryit>
It saves me a lot of work, and I'd like to share it.
Hope you can use it
Bart van Deenen. (bart@vandeenensupport.com)
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<search & replace the word under the cursor | Insert one character only >>
Additional Notes
gmann, April 29, 2003 18:46
please share any other mappings you like!
quite nice!
http://www.vim.org/tips/tip.php?tip_id=465 (1 of 5) [18/02/2004 14:59:55]
That one is
Tip #465 - generic xml imap to make an element of any word you type : vim online
Tip #465 - generic xml imap to make an element of any word you type : vim online
Hi
I improved my imap with a function (my first in vim)
(can probably be done in a one-liner :)
Put the following in xml.vim in your ftplugin
directory, our source it in your .vimrc. The ^] and ^M
are entered via <CTRL-V><esc> and <CTRL-V><CR>
function! Make_element()
"function to make an xml element at the current
cursor position out of the
"contents of the just deleted unnamed
register
"
"Bart van Deenen
if match(getline('.'),'^\s*'.@".'\s*$') == -1
"the deleted word was not alone on the line
let @w = "i<^[ea></^[pa>^[F<i"
else
"the deleted word was on it's
own on the line
let @w =
"i<^[ea>^M</^[pa>^[kA"
endif
endfunction
"include colon(58) for namespaces in xsl for instance
set iskeyword=@,48-57,_,192-255,58
imap <buffer> ,,, <Esc>bye:call
Make_element()<enter>@w
It seems to do the job with me.
Thanks for the question, I learned something from
finding the answer
Bart van Deenen
bart van deenen, May 1, 2003 10:41
hi
it's probably better to use :setlocal iskeyword than
:set
Bart
arnarb at oddi dot is, May 1, 2003 10:45
Tip #465 - generic xml imap to make an element of any word you type : vim online
Tip #465 - generic xml imap to make an element of any word you type : vim online
Hi
If you install vimscript #301 (Devin Weaver's xmledit)
you can do
i<foo>>
and get
<foo>
[cursore here]
</foo>
Also see
Have fun,
Tobi
Anonymous, November 29, 2003 4:48
Andr wrote:
This tip is great, but it does not work if the word is
only one character long, like "a" in html. If I type
a,,, the result is:
<
a></>
It has to do with a part of the script where I use bye
to go to the beginning of the word (a in your case),
and yank the word into a buffer. Unfortunately the 'b'
command skips over the start of the 'a' word, so you
end up with garbage.
I don't have a fix yet, but if I find one, I'll post
it. Somebody else?
Bart (the author of the tip)
P.S. sorry for the late answer, I was on honeymoon :-)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
I have not yet seen this idea yet. But early in my use
and love of Vim, I got frustrated in command mode when I
wanted to insert just one character of text. So I put
this in _vimrc:
"insert one character
noremap <somekey> i<Space><Esc>r
I think it has been one of the most time saving mappings
-- and I have remapped most of my keyboard.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<generic xml imap to make an element of any word you type | vim windows displaying output inside
vim window >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #467 - vim windows displaying output inside vim window : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
wnatter@nortelnetworks_cba.com, May 2, 2003 10:21
If you want, you can have the output of the command
sent into your file by using the '!' mechanism a little
further:
:<range>!<command>
This will send the lines in the range to the standard
input of your command, and replace them with the
standard output of the command (see help for
details). Please remove _cba in my address to send me
a note.
Tip #467 - vim windows displaying output inside vim window : vim online
Tip #467 - vim windows displaying output inside vim window : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<vim windows displaying output inside vim window | The use of %< instead of % >>
Additional Notes
Anonymous, May 1, 2003 10:47
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<display date-and-time on status line | Map to quickly swap/exchange arbitrary text >>
Additional Notes
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<The use of %< instead of % | Bridging the worlds: putting your rodent to work for vim in xterms >>
Additional Notes
david@tvis.co.uk, May 6, 2003 1:27
Hi I've needed this about a billion times!! zzapper
How it works (AFAIK)
vnoremap <C-X> <Esc>`.``gvP``P
<ESC> disappears visual selection
`.
return to exact spot of last modification
(the deleted text)
``
jump back to where you were (exactly)
gv
re-highlight last visual text
P
Put/paste last deleted text over visually
selected text
``
Toggle to where text was deleted
P
Visually Selected Text now in default
register so just paste it.
Notes:
Note use throughout of BACK tip `
When you initially delete text , don't delete the
trailing space
<C-X> can still be used for decrement
ad_scriven@postmaster.co.uk, May 7, 2003 3:18
This is a nice map. However it breaks in the case where
the
first word you delete is on the same line as the one
you
highlight and is further to the right (vim shifts the
`.
mark about). Here is a horrible fix. I'm sure someone
else
can do better. Replace ^V with ctrl-V.
vnoremap <silent> <C-X> <Esc>`.``:exe
line(".")==line("'.") && col(".") < col("'.") ? 'norm!
:let c=col(".")^V^V^V^V<CR>gvp```]:let c=col(".")c^V^V^V^V<CR>``:silent call
cursor(line("."),col(".")+c)^V^V^V^V<CR>P' : "norm!
gvp``P"<CR>
http://www.vim.org/tips/tip.php?tip_id=470 (2 of 4) [18/02/2004 15:00:10]
Antony
pjd@303.za.net, May 7, 2003 7:38
Good catch. The problem doesn't seem to be caused by
Vim moving the `. mark
about, though, but rather by the fact that Vim
*doesn't* move it.
IOW, when you change a line by inserting/deleting
characters, any marks to the
right of the change don't get adjusted to correct for
the change, but stay
pointing at the exact same column as before the change
(which is not the right
place anymore).
It seems there's already a todo-item for this (line
2998 in todo.txt):
7
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #471 - Bridging the worlds: putting your rodent to work for vim in xterms : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #471: Bridging the worlds: putting your rodent to work for vim in
xterms
tip karma
complexity: basic
as of Vim: 6.0
If, like me, you don't want to use the GUI vim because
you work in an xterm most of the time anyway, you may be
annoyed at the shortcomings this presents. For example,
during my webbrowsing, I'll often fire up vim in one of
the already lying around xterms to conveniently write a
long text (such as this one), and then paste from vim
into a textfield on a HTML form in the browser.
The first problem is caused by line numbering, which I
keep enabled at all times.
:set number
:help number
Normally, if you try to copy text out of the xterm that
vim is running in, you'll get the text as well as the
numbers. The GUI version gets this right: it only
selects the text, keeping the line numbers out of the
picture. But I don't want the GUI version. So instead, I
added this to my vimrc:
:set mouse=a
Much better. You can also selectively enable mouse
support for specific modes only by using something other
than 'a' (for 'all').
:help mouse
Now although I'm more of a keyboarder, when I juggle
text between X apps (or maybe between xterms), it's just
more convenient and efficient to keep my hands on my
mouse, since they're there anyway. Now, if you own a
moderately recent model, you'll know this lovely little
wheel they have (which usually also doubles as mouse
button 2). Rolling it scrolls the window in GUI vim,
which simplifies life when selecting several, distant
Tip #471 - Bridging the worlds: putting your rodent to work for vim in xterms : vim online
Life Changing
Helpful
Unfulfilling
<<Map to quickly swap/exchange arbitrary text | Handy option flag toggler >>
Additional Notes
pagaltzis at gmx dot de, May 8, 2003 7:52
rate
Tip #471 - Bridging the worlds: putting your rodent to work for vim in xterms : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Bridging the worlds: putting your rodent to work for vim in xterms | "compiler" for perl >>
Additional Notes
robin at isometry dot net, May 12, 2003 17:53
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Handy option flag toggler | have . restore the cursor position a la emacs in viper mode >>
Additional Notes
Anonymous, May 14, 2003 23:58
:h errorformat-perl
or have a look at $VIMRUNTIME/tools/efm_perl.pl
to use quickfix mode with perl scripts.
Thomas
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #474 - have . restore the cursor position a la emacs in viper mode : vim online
Home
Search
Tip #474: have . restore the cursor position a la emacs in viper mode
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim:
6.0
Tip #474 - have . restore the cursor position a la emacs in viper mode : vim online
Life Changing
Helpful
Unfulfilling
rate
<<"compiler" for perl | wrap visual selection with fold markers >>
Additional Notes
Anonymous, May 15, 2003 2:19
You can also use the following mapping, that doesn't
modify the z mark
noremap .
.'^
Tip #474 - have . restore the cursor position a la emacs in viper mode : vim online
'ciw' is great
.'^
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #475 - wrap visual selection with fold markers : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Site Help
<<have . restore the cursor position a la emacs in viper mode | multime errorformat & makeprgs >>
Additional Notes
Kartik Agaram, May 18, 2003 12:08
Prefer the zf command, in combination with
foldmethod=marker.
:help zf
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<wrap visual selection with fold markers | How to put the indentation level on the status line >>
Additional Notes
brett williams at agilent dot com, May 20, 2003 12:13
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #477 - How to put the indentation level on the status line : vim online
Home
Search
Tip #477: How to put the indentation level on the status line
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
complexity: basic
as of Vim: 5.7
Scripts
Tips
My Account
Site Help
fu ShowTab()
let TabLevel = (indent('.') / &ts )
if TabLevel == 0
let TabLevel='*'
endif
return TabLevel
endf
rate this tip
Life Changing
Helpful
Unfulfilling
<<multime errorformat & makeprgs | Copy the search results into clipboard >>
Additional Notes
Anonymous, May 20, 2003 16:50
fu ShowTab()
return (indent('.') / &ts )
endf
Anonymous, May 21, 2003 0:00
s/ts/sw/
;-)
Add Note
rate
Tip #477 - How to put the indentation level on the status line : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #478 - Copy the search results into clipboard : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<How to put the indentation level on the status line | Replace with NO Typing >>
Additional Notes
bsamim@yahoo.com, June 13, 2003 7:55
Tip #478 - Copy the search results into clipboard : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
2.
gy
gp
That's it!
If there are more than one badNames, type *N before
typing go, then n gp to change the next one.
I mapped go to put a space after the word, but someone
clever might be able to combine them.
Here is how I mapped the commands:
"replace word with register b WITH SPACE AFTER word
noremap go lb"bPldwi <Esc>hbye
"replace word with reg b WITHOUT SPACE after word
"(lb so no move to previous word, but gives error at end
of line)
noremap gp lb"bPldwhbyw
"copy this word to register b for replacing with go and
gp
noremap gy lb"bye
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Copy the search results into clipboard | editing files on an ftp server listening on a non-standard
port >>
Additional Notes
jallen@cashsystemsinc.com, May 23, 2003 11:05
I have always wanted to be a clever guy, so I took a
shot at combining them right after I wrote that. Try
this
noremap gp heli x<Esc>b"bPldwxbyw
and you can us gp for both words with and without
spaces.
Anonymous, May 24, 2003 20:35
" COMMENT:
'gp' is already assigned by vim
nmap gw lb"wPlcw<Esc>bb
"
Word from register w replaces the word under
cursor. Use with 'gy'
"
After replace, reposition to previous word for
possibly another replace.
nmap gy lb"wye
"
Yank word into register w.
"
----------------------------------------------Thanks to vimmers.
Anonymous, May 25, 2003 4:13
I usually search for "badName", then do a "cw" (Change
word), type "goodName", and then use the "." (repeat
last action) to substitute further occurences..
If the cursor is not at the beginning of "badName", I
can always do "bcw" (back-a-word + change word), or
"viwc" (change visual-inner-word)
Seems good enough! :-)
yeti@physics.muni.cz, June 1, 2003 1:49
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #480 - editing files on an ftp server listening on a non-standard port : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
Additional Notes
cec@NgrOyphSon.gPsfAc.nMasa.gov, May 29, 2003 13:02
rate
Tip #480 - editing files on an ftp server listening on a non-standard port : vim online
Tip #480 - editing files on an ftp server listening on a non-standard port : vim online
>
if getline(1) =~ "^$"
>
let l:mod=0
" No message=>it worked
>
else
>
" Output the error message
>
echoerr getline(1)
>
endif
772a791,796
>
if getline(1) =~ "^$"
>
let l:mod=0
" No message=>it worked
>
else
>
" Output the error message
>
echoerr getline(1)
>
endif
784a809
>
let l:mod=0
" Assume it worked
818a844
>
let l:mod=0
" Assume it worked
829a856
>
let l:mod=0
" Assume it worked
842c869
< if a:firstline == 1 && a:lastline == line("$")
--> if a:firstline == 1 && a:lastline == line("$") && l:mod
== 0
843a871,872
> else
>
set mod
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
<c-r>=strftime("%F")<cr>
Life Changing
Helpful
Unfulfilling
rate
<<editing files on an ftp server listening on a non-standard port | Use VIM as an organizer of Memos,
bookmarks, todo, etc. >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #482 - Use VIM as an organizer of Memos, bookmarks, todo, etc. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
No one has perfect memory. I know this when I saw clever person often key in notes in his
computer.
He uses a number of small files with ".txt" extension and "grep" through them. To me this is
not good
because you still need to give a different name to different things and as time goes by, you
will useup
common words and starts "name1", "name2", ... to enumerate.
Have you ever thought of having one single Memo at hand that can put things down as normal
editor, still very easy to search and navigate through? HTML would be perfect for hypertext
navigation, but it is not as perfect for writting notes. Who knows what <H3> means level 3
headings
when i just want to use to highlight my text, ... A lot inconvenience.
I use VIM! For many years it helps me remember almost everything and still enjoy it. Let me
share
the experience with you. Of course I expect you be a VIMMER as me first.
VIM as an organizing tool? The help system of VIM is so well organized that we can think
of reusing the same for our everyday purpose. For example, here is my own Memo (abridged):
<<cut here>>
*memo.txt*
My Memo
- extending my poor memories
|guide|
-----------------------------------------------------------------------------------------------------------*subjects*
*toc*
|cmd| command tips
|def|
definitions
|dev|
developments
|ed|
editors
|friends| friends
|lang| languages
|misc|
others
|private| personal info
|sys|
system
-----------------------------------------------------------------------------------------------------------Commands
*cmd*
Tip #482 - Use VIM as an organizer of Memos, bookmarks, todo, etc. : vim online
*General
http://www.cslab.vt.edu/manuals
......
|doskey|
DOS key utility
<F8>: expand history
|man|
Unix manual
man foo
nroff -man foo.1 | less
nroff -man foo.1 | a2ps -m
|unix|
http://gd.tuwien.ac.at/linuxcommand.org/
|winhelp|
.....
-----------------------------------------------------------------------------------------------------------Development
*develop*
*dev*
...
-----------------------------------------------------------------------------------------------------------vim:tw=78:fo=tcq2:isk=!-~,^*,^\|,^\":ts=8:ft=help:norl:
<<cut here>>
Some explainations:
1) The last line instructs VIM with a number of editing settings. The most
important one here is "ft=help", which says file-type is "help"! So the VIM
will highlight thing for us.
2) You can use *foo* to indicate an anchor to the "help" system of VIM.
If you press Ctrl + ] on a word "foo", the cursor will jump to the first *foo*.
You can also see |foo| as a way to highlight it as implicit keywords.
3) This is not magic. The mechanism behind is the tag system. VIM needs
to have the following tag file to go to where you want it to go:
===================================
%userprofile%
memo.txt
/*%userprofile%*
.htaccess
meo.txt
/*.htaccess*
access memo.txt
/*access*
access.conf memo.txt
/*access.conf*
addressbook memo.txt
/*addressbook*
anchor_keyword memo.txt
/*anchor_keyword*
apache memo.txt
/*apache*
as index.txt
/*as*
at index.txt
/*at*
awk index.txt
/*awk*
===================================
Each line defines a tag, the first element is the keyword,
the second is the file where the tag belongs (yes, you can use
multiple files as long as you know what they are), and the last
http://www.vim.org/tips/tip.php?tip_id=482 (2 of 8) [18/02/2004 15:00:41]
Tip #482 - Use VIM as an organizer of Memos, bookmarks, todo, etc. : vim online
<stdio.h>
<string.h>
<ctype.h>
<stdlib.h>
Tip #482 - Use VIM as an organizer of Memos, bookmarks, todo, etc. : vim online
{
fprintf(stderr, "Unable to open %s for reading\n", argv[0]);
continue;
}
while (fgets(line, LINELEN, fd) != NULL)
{
p1 = strchr(line, '*'); /* find first '*' */
while (p1 != NULL)
{
p2 = strchr(p1 + 1, '*'); /* find second '*' */
if (p2 != NULL && p2 > p1 + 1) /* skip "*" and "**" */
{
for (p = p1 + 1; p < p2; ++p)
if (*p == ' ' || *p == '\t' || *p == '|')
break;
/*
* Only accept a *tag* when it consists of valid
* characters and is followed by a white character or
* end-of-line.
*/
if (p == p2 && (p1 == line || p1[-1] != '-') &&
(strchr(" \t\n\r", p[1]) != NULL || p[1] == '\0'))
{
*p2 = '\0';
++p1;
printf("%s\t%s\t/*", p1, argv[0]);
while (*p1)
{
/* insert backslash before '\' and '/' */
if (*p1 == '\' || *p1 == '/')
putchar('\');
putchar(*p1);
++p1;
}
printf("*\n");
p2 = strchr(p2 + 1, '*'); /* find next '*' */
}
}
p1 = p2;
}
}
fclose(fd);
}
return 0;
}
http://www.vim.org/tips/tip.php?tip_id=482 (4 of 8) [18/02/2004 15:00:41]
Tip #482 - Use VIM as an organizer of Memos, bookmarks, todo, etc. : vim online
Life Changing
Helpful
Unfulfilling
rate
<<abbreviations only on shortcut | Using GREP for a list occurrences and quickfix help command. >>
Additional Notes
maurice, June 6, 2003 4:10
See also :helptags
digitect (at) mindspring com, June 6, 2003 14:04
Make your own tags file within Vim with:
:execute "helptags " . expand("%:p:h")
from within the open file.
Sreny@SverGbc.Pbz (Rot13ed), June 7, 2003 9:29
There is one downside with :helptags. It opertes only on *.txt files.
Here is another method for generating a tags file for *word* style tags; written in python
and based off the ptags.py from the python22 distribution
Usage:
tags.py [file] [file,etc.]
i.e.
tags.py myfile.html myfile.c etc.etc
tags.py:
>>>
#! /usr/bin/env python
#{{{ File header information
"""
/*!
\file
tags.py
\brief
Create a tags file (of *WORDS*), usable with VIM61, possibly earlier.
http://www.vim.org/tips/tip.php?tip_id=482 (5 of 8) [18/02/2004 15:00:41]
Tip #482 - Use VIM as an organizer of Memos, bookmarks, todo, etc. : vim online
\note
distribution
style tags (for my documtation) output
ptags.py from the python22 distribution.
Feral <Sreny@SverGbc.Pbz> (Rot13ed)
Changelog:
1.01: [Feral:240/02@08:36] now warns on a duplicate entry, slow and crude method
(checks each addition to tags)
1.00: [yesterday]
Initial version, based on ptags.py from the python22 distrobution.
*/
"""
#}}}
import sys, re, os
tags = []
def main():
args = sys.argv[1:]
print args
for file in args:
treat_file(file)
# keep in mind that the tags are sorted, this line !should! end up at the top...
tags.append("!_TAG_FILE_SORTED\t1\n")
print tags
if tags:
fp = open('tags', 'w')
tags.sort()
for s in tags:
fp.write(s)
print s
expr = '.*\*([a-zA-Z0-9_]+)\*.*'
matcher = re.compile(expr)
def treat_file(file):
print "treating file", file
dacount = 0
try:
fp = open(file, 'r')
http://www.vim.org/tips/tip.php?tip_id=482 (6 of 8) [18/02/2004 15:00:41]
Tip #482 - Use VIM as an organizer of Memos, bookmarks, todo, etc. : vim online
#
#
#
#
#
#
#
except:
sys.stderr.write('Cannot open %s\n' % file)
return
base = os.path.basename(file)
while 1:
line = fp.readline()
print "line:",line
if not line:
break
m = matcher.match(line)
if m:
content = m.group(1)
s = content + '\t' + base + '\t/*' + content + '*\n'
SO: [Feral:240/02@08:32] Hack in a warning if the item exists already.
Original:
tags.append(s)
THe hack:
for item in tags:
if item == s:
print "Duplicate entry:", content
tags.append(s)
EO: Feral [Feral:240/02@08:32]
print "content: ",content
print s
dacount = dacount + 1
print "\t", dacount, "matches."
if __name__ == '__main__':
main()
#EOF
<<<
Now hopefully this forum didn't mangle the indent! heh
Anonymous, June 8, 2003 16:39
Also see Thlnk.vim
http://www.vim.org/scripts/script.php?script_id=293
gpwen, June 11, 2003 18:40
Tip #482 - Use VIM as an organizer of Memos, bookmarks, todo, etc. : vim online
It will be better if combined with the folding. I put this on the modeline:
vim:fdm=marker:tw=78:isk=!-~,^*,^\|,^\":ts=8:ft=help:norl:
And add folding marks at the end of the section title, like this:
==================================================
Commands
{{{1
==================================================
"{{{1" is the default folding mark for level one. You can use multiple level
folders as well (:he Folding). Vim will folder the items automatically so you
can get all items at one glance. Really nice feature!
yijun@cs.toronto.edu, July 29, 2003 12:54
Thank you for helping me to simplify the task! I have modified my Memo with the following
template:
--------------------------------------TITLE
*tag* {{{
...content...
}}}
In summary, using "helptags ." can also warn me about any redundant tags.
Another idea, maybe useful, is it possible to use two connected words as the tags
automatically? Like
WikiWiki, PikiPiki and MoinMoin (don't need to enter | | and * *, just use a pattern like [AZ][a-z0-9]*[A-Z][a-z0-9]*.
Furthermore, is it possible to allow Unicode keywords to be automatically found?
davev at ziplip dot com, November 22, 2003 19:25
I just intregrated much of these functions (links, folding, etc.) into one script on
Vimscript#828.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #483 - Using GREP for a list occurrences and quickfix help command. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #483: Using GREP for a list occurrences and quickfix help
command.
tip karma
complexity: intermediate
as of Vim: 6.0
Tip #483 - Using GREP for a list occurrences and quickfix help command. : vim online
nnoremap <m-kPlus>
nnoremap <m-kMinus>
endif
:cnewer<CR>
:colder<CR>
Tip #483 - Using GREP for a list occurrences and quickfix help command. : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Use VIM as an organizer of Memos, bookmarks, todo, etc. | Console-like fonts for Windows GVim
>>
Additional Notes
Sreny@SverGbc.Pbz (Rot13ed), July 2, 2003 3:11
by the by, another way to list occurrences (at least
for the current file)
would be a :g//:p (see :h :g and :h :p) and have the
text you want to list as
your current search pattern.
Just as an aside, :cnext can be abbreviated to :cn and
:cprev can be
abbreviated to :cp, of course.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Site Help
<<Using GREP for a list occurrences and quickfix help command. | Open a new window and read in
the man page for the word under the cursor >>
Additional Notes
Anonymous, June 9, 2003 4:28
The link is
http://www.uwe-sieber.de/dosfon_e.html
Anonymous, June 11, 2003 1:28
I quite like
http://www.raize.com/DevTools/Tools/RzFont.htm
Anonymous, July 3, 2003 11:16
Also recommended, esp. for those who loved Monaco on
the Mac or 6x10/6x13 on X11: ProFont (available for
Windows and MacOS as TrueType). http://www.tobiasjung.de/seekingprofont/
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #485 - Open a new window and read in the man page for the word under the cursor : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #485: Open a new window and read in the man page for the word
under the cursor
tip karma
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Tip #485 - Open a new window and read in the man page for the word under the cursor : vim online
<<Console-like fonts for Windows GVim | Search for word under cursor, but don't move. >>
Additional Notes
jez.hancock@munk.nu, June 14, 2003 4:34
Addendum:
"AFTER THIS:
" and delete it:
:exe ":delete"
" ADD THIS!:
" finally set file type to 'man':
:exe ":set filetype=man"
Which formats the page for man type (make sure to
'setenv TERM xterm' first or similar to see the pwetty
colours :)
goulding@princeton.edu, June 14, 2003 13:25
Note that if you're using a recent version of groff,
you may have to disable SGR (Ansi escape sequences) in
order to view man pages within vim. If you see a whole
lot of garbage on the screen, try adding to your .vimrc
the line:
let $GROFF_NO_SGR=1
bstrohhaecker@gmx.de, June 16, 2003 1:27
Also take a look at ":e $VIMRUNTIME/ftplugin/man.vim".
lpenz@terra.com.br, June 16, 2003 9:11
I'd rather put in my ~/.vimrc:
source $VIMRUNTIME/ftplugin/man.vim
nnoremap K :Man <C-R><C-W><CR>
jacob@fugal.net, June 18, 2003 8:44
Tip #485 - Open a new window and read in the man page for the word under the cursor : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #486 - Search for word under cursor, but don't move. : vim online
Home
Search
Tip #486: Search for word under cursor, but don't move.
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Open a new window and read in the man page for the word under the cursor | jump to a file to a
certain line number >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Dear VIMMERS:
It is useful to have cn, cl for locating errors.
however, when the compilation was done off-line,
gcc ... >& compile.log
how to use the compile.log to locate the errors? for
example,
vim.h:1506
if i use "gf" when the cursor is over "vim.h", it just
jumps to the begining of the file.
here may be one solution by combining several steps:
nmap gt mAT f:l"aywbbgf:^Ra^M
"mA"
--- marks the current position to global register
A so that i can return the log file by 'A
"T "
--- goes to the begining of the tag, so in any
characters of "vim.h:1506", it first places the cursor
to "v".
"f:"
--- goes to the ":" separator
"l"
--- goes to the starting of line number
"ayw
--- try to use register a to remember the line
number
"bb"
--- move cursor back to the filename
"gf"
--- now jump to the file
":^Ra^M"
--- jump to the line number remembered in
register a
nmap gt ... place the above steps into key combinations
"g" "t" so next time use "gt" instead of "gf" on the
error tag!
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Search for word under cursor, but don't move. | vimrc setting for wider vim diff window (gVim) >>
Additional Notes
gpwen, June 16, 2003 21:48
You can try the :cfile command:
:help cfile
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #488 - vimrc setting for wider vim diff window (gVim) : vim online
Home
Search
Tip #488: vimrc setting for wider vim diff window (gVim)
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
The Vim diff feature (fantastic as it is) opens with the default
window width (gVim), and the two files each get a half width
buffer windows with a vertical split between them. When you
resize, only one buffer window changes. We might write function
to automatically center the split and possibly trigger it
automatically with an autocmd (advanced). However, we can still
have Vim open with a wider window when performing a diff. The
following code can be added to the vimrc file. Be sure to
adjust the numbers for the available screen real-estate and the
other settings to taste.
"===============================================================
" Window settings
set lines=60
" Set window height
set columns=98
" Set window width 'co'
set guioptions+=b
" Add bottom scroll bar 'go'
" If comparing files side-by-side, then ...
if &diff
" double the width up to a reasonable maximum
let &columns = ((&columns*2 > 172)? 172: &columns*2)
endif
"===============================================================
Remember, the default for the columns setting is either 80 or
the terminal width. I wouldn't expect consistant results for
non-gVim usage. By the way, I still need to add a test to
detect vim vs. gVim in my own vimrc (perhaps greping $VIM for
gvim) so that I can adjust colors and other settings
accordingly. Note that the expression in the let statement can
be replaced with a constant. But, that expression may prove
usefull if the columns setting is to vary (e.g. a filetype
plugin). For a general function (intermediate), someone would
want to come up with some global names like MaxScreenColumns or
MaxBufferColumns.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Tip #488 - vimrc setting for wider vim diff window (gVim) : vim online
Additional Notes
niklas, June 18, 2003 3:32
To check if the GUI is enabled, just test with:
if has("gui_running") ... endif
Another solution is to put GUI-specific code in your .gvimrc
instead, which can make stuff a lot cleaner.
jaldri1 at gl dot umbc dot edu, June 18, 2003 3:38
Thanks to everyone for the feedback on testing for a GUI
mode.
For code that should only be executed when running gVim, wrap
it in:
if has("gui")
" ...
endif
You can also check the availability of options with
exists("+guioptions"). Note that for exists(), '+' is
different then '&'.
Anonymous, July 17, 2003 20:03
If you want exactly 80 columns in each half:
if &diff
let &columns = 160 +
2*&foldcolumn + 1
endif
The last 1 is for the vertical separator.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
This is a small mapping that can be used for jumping sections in a latex
file (just like ]m and [m for Java methods)
map <silent> ]s :/\\\(sub\)\{,2}section\s*{<CR> :noh<CR>
map <silent> [s :?\\\(sub\)\{,2}section\s*{<CR> :noh<CR>
I want to extend it to recognize something like 2]s to move two sections
forward. How to do it.
Aditya
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<vimrc setting for wider vim diff window (gVim) | Paste vim registers in search or colon command-line instead of using the system
clipboard >>
Additional Notes
juhas@seas.upenn.edu, June 19, 2003 14:17
Here is an excerpt from my tex ftplugin, where section jumping works
with
count. The search() function is used rather than // command to avoid
the
wrap-arounds and end-of-file messages. Also, if you want to keep the
original search pattern, just comment out the "let @/ = pat" line.
Hope this helps,
Pavol
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" section jumping
noremap <buffer> <silent> ]] :<c-u>call TexJump2Section( v:count1, ''
)<cr>
noremap <buffer> <silent> [[ :<c-u>call TexJump2Section( v:count1, 'b'
)<cr>
function! TexJump2Section( cnt, dir )
let i = 0
let pat =
'^\\\(part\|chapter\|\(sub\)*section\|paragraph\)\>\|\%$\|\%^'
let flags = 'W' . a:dir
while i < a:cnt && search( pat, flags ) > 0
let i = i+1
endwhile
let @/ = pat
endfunction
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #490 - Paste vim registers in search or colon command-line instead of using the system clipboard : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: intermediate
as of Vim: 5.7
To paste something into a search or the colon commandline without using the system clipboard, press Ctrl-R"
(including the quote, which represents the unnamed
register), or replace the quote with another register.
For more information about registers, see ":help
resisters".
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<Section jump in Latex | can anyone tell me how to get rid of the F1 mapping ? >>
Additional Notes
japaget@ix.netcom.com, June 20, 2003 22:59
The correct help command is ":help registers", not
":help resisters".
This correction aside, this is an excellent tip!
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #491 - can anyone tell me how to get rid of the F1 mapping ? : vim online
Home
Search
Tip #491: can anyone tell me how to get rid of the F1 mapping ?
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
complexity: basic
as of Vim: 5.7
owkay
i have been googeling for 2 hours now
Scripts
Tips
My Account
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<Paste vim registers in search or colon command-line instead of using the system clipboard | jump to
file from :CVSDiff output >>
Additional Notes
cnf@antwerpen.be, June 21, 2003 0:05
owkay, seems it works, but not on all files ...
nnoremap <F1> za<esc>
works on a perl file
does NOT work on a tex file
anyone know why ?
insaneevilcoder@yahoo.com, June 21, 2003 5:51
nnoremap <F1> <ESC>
inoremap <F1> <ESC>
yacoob@chruptak.plukwa.net, June 22, 2003 3:49
Tip #491 - can anyone tell me how to get rid of the F1 mapping ? : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
"
"
" get
" get
| "
| "
Life Changing
Helpful
Unfulfilling
rate
<<can anyone tell me how to get rid of the F1 mapping ? | Open the directory for the current file in
Windows >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #493 - Open the directory for the current file in Windows : vim online
Home
Search
Tip #493: Open the directory for the current file in Windows
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
rpilkey at magma.ca, June 24, 2003 9:42
Good tip, I changed it to this:
map <C-e>
Tip #493 - Open the directory for the current file in Windows : vim online
Very good!
I call instead the windows explorer the explorer plugin
with:
map <C-e>
:Exp %:p:h:gs?\/?\\\\\\?<CR>
Tip #493 - Open the directory for the current file in Windows : vim online
endif
endfunc
command! OpenCWD call OpenCWD() " or whatever you like
I'm not sure how flawless it is, but it has worked for me
on a couple of different platforms.
radbelt_res@yahoo.com, June 26, 2003 19:07
A solution that I like is to use the vi file manager
(http://vifm.sourceforge.net). You can use it with or
without being in vim (a vim plugin comes with the
distribution). Unfortunately, I have not been able to get
it to compile in cygwin on windows yet, and I am on a
windows machine right now, so I can't access it to give
more of the specifics. I think the plugin comes with a
command like :Vifm, but, that could be mapped.
sgovindachar at yahoo, June 27, 2003 8:38
Since I perfer to stay within Vim, I use the following:
:sf %:p:h
This splits the window and lists the contents of the
directory of the file. Putting the cursor on an item from
the list in that window and typing o opens up a new window
with the contents of the item.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Open the directory for the current file in Windows | Backspace key using puTTY to RH9 box >>
Additional Notes
Anonymous, June 26, 2003 12:12
NI
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #495 - Backspace key using puTTY to RH9 box : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<maximize or restore window | This is the hyperlinked html format of the Vim Reference Manual. >>
Additional Notes
omanakuttan(at)tataelxsi(dot)co(dot)in(nospam), June 28, 2003 5:50
If you use dtelnet (dave's telnet) to RH 7.3, and 8.0,
same problem appears, not only in vim, but throughout
the session. Choosing term=linux from the menu helps
you there also.
lmasterson at hcocntf dot org, July 22, 2003 7:36
The key thing here is changing the string that PuTTy
sends to 'linux' from the default of 'xterm'
Doing this magically made everything work as it
should.
Add Note
Tip #495 - Backspace key using puTTY to RH9 box : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #496 - This is the hyperlinked html format of the Vim Reference Manual. : vim online
Home
Search
Tip #496: This is the hyperlinked html format of the Vim Reference Manual.
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
DESCRIPTION
---------This is the hyperlinked html format of the Vim Reference Manual.
Vim is much more than just a text editor; it's a cross-platform working
environment, but quite counter-intuitive to use. A Greek translation
of the Vim Tutor and Menu is on the drawing board at LynxX.org.
If you have a Web browser, the official hypertext version is
currently at <http://www.vim.org/>;. This unofficial version looks much
nicer than the official hypertext versions that exist at vim.org or can
readily be converted to html from the RefMan documents, but is an exact
copy of the source docs.
You can downloaded it from here:
-- FTP <ftp://lynxx.org/misc/download>;
-- HTTP <http://lynxx.org/misc/download>;
DISCLAIMER
---------This document is freely redistributable, but I take no liability
for the correctness and safety of any procedures or advice given here.
This document is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY, explicit or implied for the MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
BUGS
---If you find any mistakes or dead links, please contact:
<vangelise@lynxx.org>
Vangelis Eustratius
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Backspace key using puTTY to RH9 box | Replacing a string with default buffer contents >>
Additional Notes
mmm@hotmail.com, June 27, 2003 16:31
Tip #496 - This is the hyperlinked html format of the Vim Reference Manual. : vim online
http://lynxx.org/misc/download/ is empty
ftp://lynxx.org requires login/password
:-(
Marena
lynxx238@lynxx.org, June 28, 2003 9:00
Alternate download links for vimeditor_manual_html:
http://blake.prohosting.com/keytron/misc/download/vimeditor_manual_html.tgz
http://blake.prohosting.com/keytron/misc/download/vimeditor_manual_html.zip
Vangelis E.
david@rayninfo.co.uk, June 30, 2003 3:40
http://lynxx.org/misc/download/
now working but seems to have missing index.html or refmain.html
vangelise@lynxx.org, August 16, 2003 2:50
This document is readily available and can be viewed on-line at:
http://lynxx.org/ranerox/scripts/demos/vim_refman/index.html
Vangelis E.
vangelise@lynxx.org, August 27, 2003 12:54
Above-mentioned Greek language menus/messages/encodings for Vim61 are now
available at, and can be freely downloaded from:
http://lynxx.org/misc/download/vim-6.1-menu_el.zip
http://lynxx.org/misc/download/vim-6.1-menu_el.tgz
See VimTip #545 for more details.
That's all, folks
GREEKLISH
--------Ellynika menou gia to Vim61 einai diahesima kai mporoun na metafortwhoun
apo tyn parapanw istoselida.
Des VimTip
Xairete
Vangelis Eustratius
vangelise@lynxx.org
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #497 - Replacing a string with default buffer contents : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<This is the hyperlinked html format of the Vim Reference Manual. | Completation using the syntax file >>
Additional Notes
niklasl, June 28, 2003 3:44
Tip #497 - Replacing a string with default buffer contents : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
<<Replacing a string with default buffer contents | View character class >>
Additional Notes
maxiangjiang@hotmail.com, June 29, 2003 12:19
It is cool.
How to make it work without
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: advanced
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
mmetzger@mv-research.com, July 3, 2003 7:55
You might also want to include the mappings for the
normal mode as well. For example, going to a specific
line
#+shift G will not work unless you put these additional
mappings in _vimrc.
:map
:map
:map
:map
:map
:map
:map
:map
:map
:map
^[Oq
^[Or
^[Os
^[Ot
^[Ou
^[Ov
^[Ow
^[Ox
^[Oy
^[Op
1
2
3
4
5
6
7
8
9
0
^[0A
^[0A
^[0A
^[0A
<Up>
<Down>
<Left>
<Right>
I'm using :
:imap <Esc>Oq
:imap <Esc>Or
:imap <Esc>Os
:imap <Esc>Ot
:imap <Esc>Ou
:imap <Esc>Ov
:imap <Esc>Ow
:imap <Esc>Ox
:imap <Esc>Oy
:imap <Esc>Op
:imap <Esc>On
:imap <Esc>OQ
:imap <Esc>OR
:imap <Esc>Ol
:imap <Esc>OS
1
2
3
4
5
6
7
8
9
0
.
/
*
+
-
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
cnf@antwerpen.be, July 4, 2003 20:51
ok
solved it with
autocmd Syntax perl do foo
a spot of trouble arose with "let perl_fold=1" but i
got around that too
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<syntax check | Open windows Help files (chm) using <CWORD> or selected area >>
Additional Notes
Anonymous, July 7, 2003 20:09
Pine's email editor is almost exactly like pico as far
as I can tell... nothing like vim
Anonymous, July 7, 2003 21:51
well, the point is that PINE allows you to use VIM
instead of PICO as the default editor. so you get a
sophisticated mail client, and you get to use vim to do
your editing.
hermitte {at} free.Fr, July 8, 2003 7:59
Pine is not the only MUA that can be interfaced with
Vim. You can also check mutt and many more.
nothing
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #506 - Open windows Help files (chm) using <CWORD> or selected area : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
If you want to open a CHM (HTML Help) file and force the
index to go to a specific entry you can do the following
(on WinXP or any windows platform that has keyhh.exe).
" Create mappings to launch the ASA9 Help file with
context
nnoremap <C-F1> :silent!!cmd.exe /cstart keyhh.exe \#klink "<C-R><C-W>" "$ASANY9\docs\dbmaen9.chm"<CR><CR>
vnoremap <C-F1> :<C-U>let
old_reg=@"<cr>gvy:silent!!cmd.exe /cstart keyhh.exe \#klink "<C-R><C-R>""
"$ASANY9\docs\dbmaen9.chm"<CR><CR>:let
@"=old_reg<cr>:echo ""<CR>
Each of these are on one line.
nnoremap opens the help file using the <CWORD> that the
cursor is on.
vnoremap allows you to visually select a block of text
and open the search window with that text. It also
restores what ever was previously visually selected
after the launch.
If you use the map repeatedly, the same HTML Help window
will be used.
Life Changing
Helpful
Unfulfilling
rate
Tip #506 - Open windows Help files (chm) using <CWORD> or selected area : vim online
Additional Notes
David Fishburn, July 9, 2003 7:51
If you windows machine does not have keyhh.exe it can
be downloaded (free) from:
http://www.keyworks.net/keyhh.htm
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Open windows Help files (chm) using <CWORD> or selected area | Problem with .vimrc >>
Additional Notes
uws@xs4all.invalid, July 14, 2003 1:41
Addition:
I use <Ctrl> plus Cursor Keys to resize the current
window relative to the neighbour window of a splitted
screen.
' resize horzontal split window
nmap <C-Left> <C-W>-<C-W>nmap <C-Right> <C-W>+<C-W>+
' resize vertical split window
nmap <C-Up> <C-W>><C-W>>
nmap <C-Down> <C-W><<C-W><
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Hello,
I am new to vim/gvim. I have used some of the tips given in
this page but when i type gvim <filename> The following
warning is comming:
Error detected while processing /users/pakeer/.vimrc:
line
6:
E518: Unknown option: on
Warning: Cannot convert string "<Key>Escape,_Key_Cancel" to
type VirtualBinding
Warning: Cannot convert string "<Key>Home,_Key_Begin" to type
VirtualBinding
Warning: Cannot convert string "<Key>F1,_Key_Help" to type
VirtualBinding
Warning: Cannot convert string "Shift<Key>F10,_Key_Menu" to
type VirtualBinding
Warning: Cannot convert string "<Key>F10,Shift_Key_Menu" to
type VirtualBinding
Warning: Cannot convert string "<Key>KP_Enter,_Key_Execute"
to type VirtualBinding
Warning: Cannot convert string
"Alt<Key>Return,Alt_Key_KP_Enter" to type VirtualBinding
Can somebody help me out what i need to do in my .vimrc.
Regards,
Pakeer.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Quick window resizing | Commands that don't clobber the search register >>
Additional Notes
insaneevilcoder@yahoo.com, July 12, 2003 8:54
please post your problem on in the comp.editors news group
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #509 - Commands that don't clobber the search register : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
<<Problem with .vimrc | one way to set $VIMRUNTIME within vimrc >>
rate
Tip #509 - Commands that don't clobber the search register : vim online
Additional Notes
Anonymous, July 15, 2003 8:35
The "without or without range" should be "with or
without range". (Probably obvious, but I didn't want
anybody to think I was stuttering!)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #510 - one way to set $VIMRUNTIME within vimrc : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Commands that don't clobber the search register | key mapping for goto the absolute line number
>>
Tip #510 - one way to set $VIMRUNTIME within vimrc : vim online
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #511 - key mapping for goto the absolute line number : vim online
Home
Search
Tip #511: key mapping for goto the absolute line number
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<one way to set $VIMRUNTIME within vimrc | Automatic insertion of C/C++ header gates >>
Additional Notes
jigho@caramail.com, July 20, 2003 23:35
Why do you need to add a third entry for an action that
already have 2 ?
"<count>G"
or
":<count><enter>"
are enough, don't you think ?
animesh@motorola.com, July 21, 2003 7:31
"<count>G"
or
":<count><enter>"
out of these two options, second one needs 3... for the
first one, I prefer "<count><ENTER><ENTER>" over
"<count>G".
gsinclair@soyabean.com.au, July 22, 2003 8:30
57gg to go to hte 57th line does me fine, thank you
very much!
gsinclair@soyabean.com.au, July 22, 2003 8:30
Tip #511 - key mapping for goto the absolute line number : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<key mapping for goto the absolute line number | Automatic insertion of C/C++ header gates >>
Additional Notes
anonymous, August 8, 2003 10:54
These commands could be shortened a bit with use
of :put ='text'
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Automatic insertion of C/C++ header gates | Automatic insertion of C/C++ header gates >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Automatic insertion of C/C++ header gates | see filenames of all scripts that vim loaded or tried to
load >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #515 - see filenames of all scripts that vim loaded or tried to load : vim online
Home
Search
Tip #515: see filenames of all scripts that vim loaded or tried to load
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
system/personal
# plugins
:help startup
rate this tip
Life Changing
Helpful
Unfulfilling
<<Automatic insertion of C/C++ header gates | find two words in either order >>
Additional Notes
Add Note
rate
Tip #515 - see filenames of all scripts that vim loaded or tried to load : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: intermediate
as of Vim: 6.0
Site Help
\(alice.*bob\)\|\(bob.*alice\)
-- "old-style" regexp
^\(.*Alice\)\@=\(.*Bob\)\@=
Keywords: find, match, search, words in either order,
regular expression
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<see filenames of all scripts that vim loaded or tried to load | Rejustification of *roff style markup. >>
Additional Notes
zzapper@ntlworld.com, July 23, 2003 10:35
Cool!
Just added to my Best of Vim Tips vimtip #305
zzapper@ntlworld.com, July 23, 2003 17:15
:h \& is the relevant help section
Anonymous, July 25, 2003 7:39
one thing to note is that the \& variant is much slower
than the more verbose \| variant.
not that it matters most of the time :-)
matches
matches
matches
matches
matches
in
in
in
in
in
1s for ^\(.*www\&.*x\)
1s for ^\(.*www\)\@=\(.*x\)\@=
5s for .*www\&.*x
9s for www.*x\|x.*www
18s for \(www.*x\)\|\(x.*www\)
I like
'.a:re
:endfunction
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Rejustification of *roff style markup. | Folding like in Visual Basic .NET >>
Additional Notes
Anonymous, August 29, 2003 18:41
Spaces should be prexeded with a \ so the exact string
is:
errorformat=%E%f(%l):\ %m,%-C,%-C%p,%Z
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
bhilverdink@hotmail.com, July 31, 2003 5:41
:g/^#R/,/^#E/fo
eric_boucher60@yahoo.com, August 5, 2003 10:52
I made a big mistakes when entering this line:
syn region myFold start="#Region" end="#End Region"
transparent fold keepend extend
It is in fact:
syn region myFold start="#Region" end="#End Region"
fold
Please replace the old on with the new one for those
who copy/pasted this tips.
I'm very sorry for any inconvenience. The old one was
simply a test for myself.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
The problem:
It's always annoying trying to do a search and replace
for identifiers in C when the identifier that you are
searching for is a substring of other identifiers or
keywords in the program. For instance, let's say you
want to search for every place you access the ubiquitous
loop variable 'i'. If you do a search, you'll hit all
the i's in the "if" and "while" keywords and any other
identifiers that contain the letter i. For awhile I
have been looking for some way to do this in vim. Other
IDE's that I have seen have a "whole word" option where
the text must be the whole word. Vim has the "]CTRL-I"
command, but that is useless for search and replace
because when you replace one instance, you won't have
the original identifier under your cursor any
more. Until recently, I didn't know how to do it in vim
without manually typing the whole regular expression for
C identifiers.
The solution:
Use the "\<" and "\>" in your search. Evidently, these
respresent the start and end of words. So, to search
for all occurrences of the variable 'i', you would use
the following command:
/\<i\>
If you want all identifiers that start with 'i', you use
"/\<i" and similarly, for all identifiers ending in 'i',
use "/i\>".
If anyone knows a better solution, I would love to know
about it.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Folding like in Visual Basic .NET | Something in GVIM for fun >>
Additional Notes
Anonymous, July 30, 2003 10:43
You can also use the '*' key in command mode. Check tip
# 1 for more details.
'gd' will bring you to the first occurence of the word
under the cursor.
Sreny@SverGbc.Pbz (Rot13ed), July 30, 2003 12:30
No Evidently about it, see ":h \<" and ":h \>"
What I like to do is highlight the var I want to
replace as a search string
(say via '*' or the like) this allows me to visually
(and easily) see what I am
about to replace.
I then linewise visual (:h linewise-visual) the section
of code I wish to
change (say all of a for loop).
It is then a simple matter of ":s//new_value_here/g"
linnc@cs.arizona.edu, July 31, 2003 14:43
For those as lazy as myself:<br>
If you happen to already have at least one occurrence
of your variable onscreen, you can place your cursor
over it and use Shift+# and it will automatically do a
search for the word using the \<mystring\> notation.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
anonymous@slashdot.org, July 31, 2003 17:07
As a note, the encryption is ROT-13
qwert, August 3, 2003 11:56
for cript visual mode not necessary
ggg?G
jigho@caramail.com, August 4, 2003 0:57
":set rl" only works if you installed the "rightleft"
option... and I do not see why we should install it if
we don't need it ? gvim is huge enough without it...
anonymous, August 12, 2003 8:20
How do you un-do it?
Anonymous, August 20, 2003 10:34
repeat it to undo
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Something in GVIM for fun | Folding functions with the prototype included >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #523 - Folding functions with the prototype included : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Fix an autoindent error | evaluate expression in any mode, including normal mode, using <CTRL-R>= >>
Additional Notes
hermitte {at} free {dot} fr, August 2, 2003 18:34
Tip #523 - Folding functions with the prototype included : vim online
Tip #523 - Folding functions with the prototype included : vim online
How can I have both these forms fold andstill see prototype
in a single line.
void func()
{
...
}
void func() {
...
}
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #524 - evaluate expression in any mode, including normal mode, using <CTRL-R>= : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Tip #524 - evaluate expression in any mode, including normal mode, using <CTRL-R>= : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Folding functions with the prototype included | JavaBeans helper function >>
Additional Notes
srinath AT fastmail DOT fm, August 4, 2003 1:28
To get the behavior like i_CTRL-r in normal mode, use
@=. For example, in normal mode, @='dd'<cr> will
delete the current line just as if you had pressed dd
in normal mode.
:help @
for more information. You can also do things like
:let @a = 'dd'
and then press @a in normal mode. This does the same
thing.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<evaluate expression in any mode, including normal mode, using <CTRL-R>= | enhancing Benji Fisher's
word_complete.vim script >>
Additional Notes
demian0311@yahoo.com, August 28, 2003 11:41
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<enhancing Benji Fisher's word_complete.vim script | Make search results appear in the middle of
the screen. >>
Additional Notes
tom@canobe.com, August 11, 2003 1:32
For those of you who like the old school VGA console
feel, heres a truetype version of the VGA font used by
most graphics cards. Make sure you set it to be used at
size 17 cos thats the only font size it will work at.
http://canobe.sourceforge.net/VGA.ttf
jose_de_paula@ig.com.br, September 5, 2003 7:04
Man, this should be distributed with vim among the
other colorschemes. I think the only thing that is
missing are the colors of the ruler (when switching
colorschemes, the ruler's colors are not updated).
Perhaps
hi StatusLine guifg=black guibg=gray
should do the trick. Thanks!
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #528 - Make search results appear in the middle of the screen. : vim online
Home
Search
Tip #528: Make search results appear in the middle of the screen.
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
n nmzz.`z
N Nmzz.`z
* *mzz.`z
# #mzz.`z
g* g*mzz.`z
g# g#mzz.`z
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
p.w.debruin@its.tudelft.nl, August 11, 2003 0:24
Why set the marks? The following works without messing
up existing marks:
nmap
nmap
nmap
nmap
nmap
nmap
n nzz
N Nzz
* *zz
# #zz
g* g*zz
g# g#zz
Tip #528 - Make search results appear in the middle of the screen. : vim online
:-)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: intermediate
as of Vim: 5.7
Site Help
Diagnosis:
Make sure you are getting something from the keypress.
Go into insert mode:
and press <control-v> then <tab>
You should get a tab.
and press <control-v> then <shift-tab>
You should get ^[[Z
If this happens, it is good, you can skip the next part
of the diagnosis.
Diagnosis Part 2:
If you get nothing when you do <control-v> then <shifttab> go to a command line prompt (#) and type:
# xmodmap -pke | grep 'Tab'
It should either show:
keycode 23 = Tab
or
keycode 23 = Tab ISO_Left_Tab
Now, which one is the 'right' one seems to depend on
what terminal program you are using its various
settings.
(I need to use the 'ISO_Left_Tab' one with 'xterm' but
the 'Tab' one with Eterm)
I suggest you try changing to the mapping to the other
one and test what you get from the keypresses again. If
http://www.vim.org/tips/tip.php?tip_id=529 (1 of 3) [18/02/2004 15:03:08]
Life Changing
Helpful
Unfulfilling
rate
<<Make search results appear in the middle of the screen. | How do I get the name of the current file
>>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #530 - How do I get the name of the current file : vim online
Home
Search
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
Site Help
see also:
help @
help expand
vimtip #296 for why it might be a useful thing to do.
Life Changing
Helpful
Unfulfilling
rate
<<Making <s-tab> (shift-tab) work | 1-2-3, let's make gvim.exe for free >>
Additional Notes
Anonymous, August 13, 2003 13:34
to enter the name of the current file in insert or
command mode, use <C-R>%.
Anonymous, August 14, 2003 5:36
If you want to use it as part of a command line just
use %
eg: !echo %
see also:
:help cmdline-special
oxcrete@yahoo.com, August 14, 2003 19:40
Tip #530 - How do I get the name of the current file : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #531 - 1-2-3, let's make gvim.exe for free : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<How do I get the name of the current file | usefule keymaps -- for comment out,etc.. >>
Additional Notes
ptoennies@hotmail.com, September 4, 2003 14:59
Tip #531 - 1-2-3, let's make gvim.exe for free : vim online
http://www.mingw.org/
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
-->a key map for commenting out lines -- use f12 key
append this line into your .vimrc/.gvim rc file
map <F12> ^i#<Esc>j
-->key maps to avoid a long shift press
nmap :X
:x
nmap :W
:w
nmap :Q
:q
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<1-2-3, let's make gvim.exe for free | Page 1 of 123 in header of :hardcopy >>
Additional Notes
yeti@physics.muni.cz, August 18, 2003 12:40
Remapping :something in normal mode is quite silly.
command -nargs=0 -bang Q q<bang>
is probably a better method of dealing with the too
long shift problem.
ewan.chalmers@comnitel.com, August 19, 2003 8:06
Key maps for Java style comment/uncomment
"comment out with CTRL-/
map ^_ 0i//<esc>j
"uncomment with CTRL-\
map ^\ :s/\/\///<CR>j
shawvrana at acm dot org, August 19, 2003 9:22
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
To get this to work you have to know how many lines per
page :hardcopy
is normally making. Open empty document and in Normal
mode "100o". Then
make ":%s/^/\=line('.')". Now ":hardcopy > nu.ps". Open
nu.ps in
PostScript viewer. You will see how many lines per page
Vim is printing.
In my case this is 73.
Now set 'printheader' option:
:set printheader=%<%f%h%m%=Page\ %N\ of\
%{line('$')/73+1}
Explanations of % items in option are here
|'statusline'|.
line('$') - number of lines in buffer
73 - number of lines per page
+1 - Vim don't know floating point math and everything
rounds down.
rate this tip
Life Changing
Helpful
Unfulfilling
<<usefule keymaps -- for comment out,etc.. | for verilog users only >>
Additional Notes
Mikolaj, August 19, 2003 4:36
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Page 1 of 123 in header of :hardcopy | Working with only one term/console? >>
Additional Notes
inti.rajesh@analog.com, August 19, 2003 20:50
an improved version of this if you are using a
searching for a particular net/wire and then u want to
know in which module you are really in.add this to your
.vimrc/.gvimrc file
map ` ma?module<CR>Wyiw'a/<Up><Up><CR>:echo "module ->" @0<CR>
if your are not searching for any particular net the
above map will do.
inti.rajesh@analog.com, August 19, 2003 20:51
smart !
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<for verilog users only | Automaticly quit Vim if quickfix window (buffer) is the last >>
Additional Notes
Anonymous, February 2, 2004 4:05
I like to use GNU screen in only one terminal/console.
Pressing C-a C-a can quickly switch between different
"windows" . And C-a C-c opens a new window.
http://www.gnu.org/software/screen/screen.html
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #536 - Automaticly quit Vim if quickfix window (buffer) is the last : vim online
Home
Search
Tip #536: Automaticly quit Vim if quickfix window (buffer) is the last
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Working with only one term/console? | mimicking the shift-arrows (mark block) in terminals that
don't understand shift-arrow (e.g. putty) >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #536 - Automaticly quit Vim if quickfix window (buffer) is the last : vim online
Tip #537 - mimicking the shift-arrows (mark block) in terminals that don't understand shift-arrow (e.g. putty) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
<<Automaticly quit Vim if quickfix window (buffer) is the last | e-mail archive >>
Additional Notes
rate
Tip #537 - mimicking the shift-arrows (mark block) in terminals that don't understand shift-arrow (e.g. putty) : vim online
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Site Help
<<mimicking the shift-arrows (mark block) in terminals that don't understand shift-arrow (e.g. putty) |
Quick access to vim tips and scripts with konqueror / kde >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #539 - Quick access to vim tips and scripts with konqueror / kde : vim online
Home
Search
Tip #539: Quick access to vim tips and scripts with konqueror / kde
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Anonymous, August 23, 2003 18:41
With a uri of
"http://vim.sourceforge.net/scripts/script.php?script_id=\{@}"
and the same method you can also easily access a specific
script.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Quick access to vim tips and scripts with konqueror / kde | How to get help using VIM >>
Additional Notes
Anonymous, August 25, 2003 18:40
Exactly like you said, not the right place to ask
questions...
Also, you don't provide enough information about your
situation, in particular, did you install vim 6.2 as an
RPM or after compiling it yourself? If it is an rpm,
check the rpm doc, rpm can display you the locations it
will install files to, it you used ./configure && make
then check in /usr/local/...
Bye,
Squisher
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: intermediate
as of Vim: 6.0
If Vim is your main text editor, and if you do a lot of XML editing,
then this mini howto might help you to make that even more fun:
Vim as XML Editor
http://www.pinkjuice.com/howto/vimxml/
Site Help
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
tobiasreif pinkjuice com, October 13, 2003 3:41
I appreciate any feedback. Error reports are especially welcome.
email: tobiasreif pinkjuice com
Tobi
william at knowmad dot com, December 29, 2003 14:15
Tobias,
This is a most excellent tutorial! Many thanks for your work in
putting this documentation together. I hope that others find it as
useful.
Do you have any info about using Vim to edit DocBook files? It'd be
nice to have folding support. Is this possible?
Thanks,
William
tobiasreif pinkjuice com, December 31, 2003 8:54
Hi William,
thank you very much for the kind words.
> Do you have any info about using Vim to edit DocBook files?
Various sections use DocBook as example language , see
http://www.pinkjuice.com/howto/vimxml/tasks.xml
and
http://www.pinkjuice.com/howto/vimxml/moretasks.xml
I recommend to set up OASIS catalogs, see
http://www.pinkjuice.com/howto/vimxml/setup.xml#catalogs
If you have more specific questions feel free to post them here or
to send them via email.
> It'd be nice to have folding support. Is this possible?
Yes, folding is discussed shortly in
http://www.pinkjuice.com/howto/vimxml/tasks.xml#creatingdocuments
See
http://www.pinkjuice.com/howto/vimxml/setup.xml#vimrc
under
map <Leader>x
for stuff to set:
:set filetype=xml<CR>
\:source $VIMRUNTIME/syntax/xml.vim<CR>
\:set foldmethod=syntax<CR>
[...]
Tobi
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Using vim to view source and edit textarea in mozilla/firebird | Vim as XML Editor >>
Additional Notes
Anonymous, October 10, 2003 13:27
I think this would break all those scripts that use a
comma as a leading character.
Anonymous, October 13, 2003 4:46
See ":help :update"
map , :update<cr>
misof, December 16, 2003 13:06
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #581 - Using vim to view source and edit textarea in mozilla/firebird : vim online
Home
Search
Tip #581: Using vim to view source and edit textarea in mozilla/firebird
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Switching back and forth between ViM and Visual Studio .NET | Quick way to write to your file. >>
Additional Notes
dicpan@hotmail.com, October 9, 2003 1:45
The current version 1.07 does not work quite as it sounds.
I opened the Mozilla mail and the vim is not launched when
composing a message.
When Viewing the page source or edit textarea, it reports an
error: temporary directory c:\windows\temp does not
exist.What the heck is this? it certainly does not exist on
any PCs which do not have windows98 installed, neither does
it exist on PCs which do not have the system installed on
drive c:
The 'standard' temp directory should be
%systemdrive%\winnt\temp. While user may specify their
preference of temp directory in environment variable %temp%.
What is more, I found problem uninstalling this plugin...
maxiangjiang@hotmail.com, October 9, 2003 10:18
Tip #581 - Using vim to view source and edit textarea in mozilla/firebird : vim online
in
Tip #581 - Using vim to view source and edit textarea in mozilla/firebird : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #580 - Switching back and forth between ViM and Visual Studio .NET : vim online
Home
Search
Tip #580: Switching back and forth between ViM and Visual Studio .NET
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
This tip is for when you work on a devstudio project and need the
debugger heavily and/or can't stay in ViM all the time. But when it
comes time to make changes you want to do them in ViM and don't want to
relocate the file and line number.
After you have made the change and perhaps opened another file or
navigated your way to a new section of the code you want to switch back
to devstudio at the spot you were in ViM. It may be because you want to
set a breakpoint or any reason.
The easy part:
Launching ViM from DevStudio.NET is easy.
From the DevStudio menu item Tools|External Tools... add a new entry
where:
The "Command Line" field is set to the path of the ViM executable
The "Arguments" field contains: --servername gmain --remote-silent
+$(CurLine) +"normal zz" $(ItemPath)
The "Initial Directory" may optionally contain: $(ItemDir)
This will start a ViM session or connect to an already existing one (-remote-silent) named gmain (--servername gmain). This will use only one
instance of ViM for all devstudio editing. It will open the file
specified by $(ItemPath) and set the cursor pos to $(CurLine). It will
also execute the normal command zz to center the cursor.
You can then create a keyboard shorcut to map to this tool
(Tools|Options||Environment|Keyboard, select Tools.ExternalCommandX)
and you will be able to switch to ViM quickly.
The hard part:
Opening a file in an existing DevStudio.NET instance is a pain and
setting the cursor to a line number is even more so.
DevStudio cannot be controlled by the command line. To open a file in
an existing instance a DDE call must be initiated. Its an old and
obsolete technology called Dynamic Data Exchange used for interprocess
communication. When you click on a .cpp file in the Windows Explorer it
calls devenv.exe with the /DDE switch (its undocumented) and sends it
an Open DDE command. You can see it for yourself if you look at the
file type mapping of .cpp in the Windows Explorer (if you haven't
already changed them to open ViM :-)). The Explorer shell is DDE
enabled but I found no way to send DDE from the command line (I didn't
really look for it either ;-)). So I wrote a small C++ console app from
the code I got from an Experts Exchange question. I formatted the code,
renamed references from DevStudio to DevEnv and put it in a project.
Tip #580 - Switching back and forth between ViM and Visual Studio .NET : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Cut&Paste without too much newlines, eg. into WORD | Using vim to view source and edit textarea in mozilla/firebird >>
Additional Notes
mosh@cs.albany.edu, October 6, 2003 18:46
I have the script send-to-msdev.sh, that uses Perl + Win32::Ole
to open files in VC. You can even set breakpoints from perl,
this script has pointers to MSDN documentation.
http://www.cs.albany.edu/~mosh/Perl/send-to-msdev.ksh
Caveats: All win32 perl to be buggy in some respect,
but active perl55 is the only one that can talk to vc.
Very few commands in msdev can be automated, some dont
even have a name, you just have to click to get to them!
- Mohsin
"Her bed is India; there she lies, a pearl" - Troillus and Cressida
1.1, WS.
# Guts of the OLE messages that work (part of sh script)
d:/perl/perl_55x/bin/perl.exe -e '
push(@INC,"d:/perl/perl_55x/lib/site");
require Win32::OLE;
$app = Win32::OLE->GetActiveObject("MSDev.Application");
$app = Win32::OLE->new("MSDEV.APPLICATION") if ! defined $app;
die "Cant open MsDev.\n" unless $app;
$app->{"WindowState"} = 1 if $app->{"WindowState"} == 2;
http://www.vim.org/tips/tip.php?tip_id=580 (2 of 4) [18/02/2004 15:03:52]
Tip #580 - Switching back and forth between ViM and Visual Studio .NET : vim online
$app->{"Visible"}=1;
$app->{"Active"}=1;
$file = $app->{"Documents"}->Open("'$VIEWFILE'");
die "Cant open file='$VIEWFILE' in msdev.\n" unless $file;
print( $app->FullName()," ",$file->FullName()," type=",$file>Type(),".\n" );
print("PWD=",$app->CurrentDirectory(),".\n");
$file->Selection()->GotoLine("'$GOTOLINE'") if $ENV{"GOTOLINE"};
# dsMatchWord is in vc/include/objmodel/textdefs.h
$file->Selection()->FindText($ENV{"FINDTEXT"},2) if $ENV{"FINDTEXT"};
$file->Selection()->Selectline(); # highlight it.
exit 0;
'
dunderxiii@hotmail.com, October 10, 2003 7:39
I udated the DevEnvDDE program to connect to Visual Studio .NET 2003.
The code now supports an extra command line parameter that specifies
the visual studio instance to open the file in (VS6, VSNET or
VSNET2003). Simply download the new sources (same link).
Note: it now defaults to Visual Studio .NET 2003 instead of Visual
Studio .NET
Anonymous, October 22, 2003 13:47
Thanks for this!
Just a small note regarding the perl script - you don't say which
version of Win32::GUITest you are using but I found that I had to
change WaitWindow to FindWindowLike to get the script
working. WaitWindow must be deprecated or something.
orthober@msoe.edu, January 29, 2004 8:30
Just to let you know, to open a file with Visual Studio (At least the
current versions) you simple can put the file name as an arument to
the command line.
Example:
"C:\Program Files\Microsoft Visual Studio .NET
2003\Common7\IDE\devenv.exe" "BE-NotInDirectory\main.cpp" "CClate\main.c
pp" "DO\Lab 5.cpp" "MG\Lab5.cpp" "NathanK\main.cpp" "NH\func.h"
"NH\func.cpp" "NH\main.cpp" "NM-late\main.cpp"
Would open all of these files.
What I am looking for is a way to tell VS to Auto Print these
files. I have also made a program that will SENDKEYS to VS to print
these, but I would like a better way.
Thanks
Jeff O
Add Note
Tip #580 - Switching back and forth between ViM and Visual Studio .NET : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #579 - Cut&Paste without too much newlines, eg. into WORD : vim online
Home
Search
Tip #579: Cut&Paste without too much newlines, eg. into WORD
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Tip #579 - Cut&Paste without too much newlines, eg. into WORD : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Specify Range with search patterns | Switching back and forth between ViM and Visual Studio .NET
>>
Additional Notes
sgovindachar at yahoo, October 6, 2003 9:43
Here's another way:
Step 1: set text width to a very large number; the
number should
be bigger than the number of words in any
para.
Example: set tw=5000
Step 2: Reformat the entire text with the gq command,
for
example, by using the series of commands
below
(the first three commands below select the
text, the
last is the gq command):
gg
Ctrl-q
G
gq
To copy to word, one can do the following:
gg
"*yG
The preceding copies the text into the clipboard.
Then go to word and paste using "Ctrl-v"
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Access vim@vim.org using Newsgroup Reader | Cut&Paste without too much newlines, eg. into
WORD >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
For some reason one may not prefer mailling lists over
usenet newsgroups (like me).
IMHO Newsgroup reader is a lot more versatile and easy
to use. So, find a newsgroup equivalent for vim@vim.org
is improtant for newsgreoup users. Unfortunately, the
comp.editors on USENET is not as active as vim@vim.org.
The non-official news server news.gmane.org, have a
mirror to vim@vim.org, named gmane.editors.vim, the
maillist vim@vim.org and newsgroup gmane.editors.vim
seemed to be syncronised together.
To access the gmane news, just new an account with the
NNTP server news.gmane.org, then find the newsgroup
gmane.editors.vim, then you can enjoy vim@vim.org with
your favorate news reader program, and without messing
up mailling list messages with your private e-mail
client (which is what the newsgroup designed for).
I think gmane.editors.vim should be highly recommended
for newsgoup users.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<one call to generate all unicode "characters" from within vim | Specify Range with search patterns
>>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #576 - one call to generate all unicode "characters" from within vim : vim online
Home
Search
Tip #576: one call to generate all unicode "characters" from within vim
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Tip #576 - one call to generate all unicode "characters" from within vim : vim online
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
maxiangjiang@hotmail.com, October 5, 2003 18:15
Here is the screen shot:
http://www.clarkson.edu/~maxi/unicode.gif
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
:%s!\(.\{-
:amenu Mo1.Format.JoinHypenatedLines
\n(\s*)(\S+)\s*, \1\3^M\2,gc
:%s,\v\s+(\w+)-
:amenu Mo1.Format.JoinBackSlashLines
:%s,\\\n,,gc
Life Changing
Helpful
Unfulfilling
rate
<<delete/move matching paragraphs/lines | one call to generate all unicode "characters" from within
vim >>
Additional Notes
Anonymous, December 3, 2003 13:46
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
" Put these in .vimrc, and these four items will become
menu items.
" You can of course just type these one liners, if you
don't have menus.
" Edit /word/ before pressing return,
" Note: /word/ can be any perl expression to select
paras.
:amenu Mo1./.Delete-Matching-Paras<tab>:1,$!perl :1,$!
perl -0000lne 'print if m/word/'
:amenu Mo1./.Delete-Matching-Lines<TAB>:g//d
:g//d<CR>
:amenu Mo1./.Delete-Non-Matching-Lines<TAB>:v//d
:v//d<CR>
:amenu
ma:g//
:amenu
ma:v//
Mo1./.Move-Matching-Lines-Top<TAB>g//\.m0
.m0<CR>`a
Mo1./.Move-Non-Matching-Lines-Last<TAB>v//\.m$
.m$<CR>`a
Life Changing
Helpful
Unfulfilling
<<Repeating a substitute from current cursor position | chop long lines. >>
Additional Notes
Add Note
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #573 - Repeating a substitute from current cursor position : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Tip #573 - Repeating a substitute from current cursor position : vim online
Life Changing
Helpful
Unfulfilling
rate
<<auto highlight word under cursor (when reading new code) | delete/move matching paragraphs/lines
>>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #572 - auto highlight word under cursor (when reading new code) : vim online
Home
Search
Tip #572: auto highlight word under cursor (when reading new code)
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<source ..../vimrc and use ..../tags in an ancestor directory. | Repeating a substitute from current
cursor position >>
Tip #572 - auto highlight word under cursor (when reading new code) : vim online
Additional Notes
Salman Halim, October 1, 2003 6:42
I would suggest placing the CursorHold event inside an
autocommand group (augroup); the way this is right now
would clobber my other CursorHold autocommands. . .
Anonymous, October 1, 2003 18:29
Question. What does the colon do here? I noticed some
other people use it also.
Anonymous, October 6, 2003 14:02
Well, what does the colon do when you're using vim
normally? Starts a command. Same thing here.
Anonymous, November 3, 2003 9:56
I'm new to vim, but why do u need the colons at the if
else and endif statements then?
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #571 - source ..../vimrc and use ..../tags in an ancestor directory. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Align badly formatted text region into table. | auto highlight word under cursor (when reading new code) >>
Additional Notes
hermitte at free dot fr, October 1, 2003 13:51
It does not handle tags directly, but the following plugin
handles local-vimrc's.
http://vim.sourceforge.net/scripts/script.php?script_id=727
Tip #571 - source ..../vimrc and use ..../tags in an ancestor directory. : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #570 - Align badly formatted text region into table. : vim online
Home
Search
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Insert line numbers or filter thru perl. | source ..../vimrc and use ..../tags in an ancestor directory. >>
Tip #570 - Align badly formatted text region into table. : vim online
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #569 - Insert line numbers or filter thru perl. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Use temporary tags file when browsing new source. | Align badly formatted text region into table. >>
Additional Notes
Siegfried.Bublitz@c-lab.de, October 1, 2003 0:13
If you don't have access to Perl, you can do it
directly from VIM by calling this function:
function! Listing()
" set line numbers in front of lines
let i=line("$")
let pre = ' '
while (i > 0)
if match(i, '^9*$') == 0
let pre = pre . '0'
endif
call setline(i, pre . i . "\t" . getline(i))
let i=i-1
endwhile
endfunction
http://www.vim.org/tips/tip.php?tip_id=569 (1 of 2) [18/02/2004 15:04:21]
Tip #569 - Insert line numbers or filter thru perl. : vim online
- Siegfried
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #568 - Use temporary tags file when browsing new source. : vim online
Home
Search
Tip #568: Use temporary tags file when browsing new source.
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
" Create and Use $TMP/tags for local source dir (which
may be unwriteable)
" Unix users can change c:/tmp to ~/tmp/ (I use $TMP
with sh).
:map <c-k>t :!(cd %:p:h;ctags -o c:/tmp/tags -R
.)&<CR>:set tags^=c:/tmp/tags<CR>
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<Edit a temporary copy of the current file | Insert line numbers or filter thru perl. >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #567 - Edit a temporary copy of the current file : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
Site Help
Life Changing
Helpful
Unfulfilling
rate
<<Autocomplete with TAB when typing words | Use temporary tags file when browsing new source. >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #566 - Autocomplete with TAB when typing words : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
dictionary="/usr/dict/words"
Life Changing
Helpful
Unfulfilling
<<never see ^M again | Edit a temporary copy of the current file >>
Additional Notes
Anonymous, September 30, 2003 23:35
http://www.vim.org/tips/tip.php?tip_id=566 (1 of 2) [18/02/2004 15:04:30]
rate
Tip #566 - Autocomplete with TAB when typing words : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<mouse wheel for scroll only - disable paste on middle button press. | Autocomplete with TAB when
typing words >>
Additional Notes
zzapper@ntlworld.com, September 29, 2003 6:59
# \r easier to type tham ^m
# cope with possible multiple trailing ^m's
autocmd BufRead * silent! %s/\r\+$//
# also delete pesky trailing whitespace at the same
time
autocmd BufRead * silent! %s/[\r \t]\+$//
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #564 - mouse wheel for scroll only - disable paste on middle button press. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #564: mouse wheel for scroll only - disable paste on middle
button press.
tip karma
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
<<useful Occurences under cursor and with prompt | never see ^M again >>
Additional Notes
cristi001 at hotmail, October 7, 2003 17:08
rate
Tip #564 - mouse wheel for scroll only - disable paste on middle button press. : vim online
While at it, take care also of 2-MiddleMouse, 3MiddleMouse and (oh, humanity! :) ) 4-MiddleMouse.
(that's for middle double clicks and triple and ...)
Alternatively, instead of simply ignoring it, make it
the same as a left click with a noremap <MiddleMouse>
<LeftMouse> (also with noremap!, and the whole 2-,3,etc. list above).
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #563 - useful Occurences under cursor and with prompt : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<modeline sets vimrc options on a per file basis | mouse wheel for scroll only - disable paste on
middle button press. >>
Additional Notes
http://www.vim.org/tips/tip.php?tip_id=563 (1 of 2) [18/02/2004 15:04:38]
Tip #563 - useful Occurences under cursor and with prompt : vim online
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #562 - modeline sets vimrc options on a per file basis : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Context Sensitive h and l | useful Occurences under cursor and with prompt >>
Additional Notes
Anonymous, September 23, 2003 12:00
To read more about modelines, type:
:help auto-setting
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
the desired
vimrc will map
only caveat is
their usual
http://www.techuser.net?content=5
------------------------------------cut here---------------------------------nmap <silent> h :<C-U>call ContextLeft()<CR>
nmap <silent> l :<C-U>call ContextRight()<CR>
func! ContextLeft()
let cnt = v:count == 0 ? 1 : v:count
if col('.') == 1 && line('.') != 1 && &ve != "all"
exe "normal! " . cnt. "k$"
else
exe "normal! " . cnt. "h"
endif
endfunc
func! ContextRight()
let cnt = v:count == 0 ? 1 : v:count
if col('.') >= strlen(getline('.')) && line('.') !=
line('$') && &ve != "all"
exe "normal! " . cnt . "j^"
else
exe "normal! " . cnt . "l"
endif
endfunc
------------------------------------cut here----------------------------------
Life Changing
Helpful
Unfulfilling
rate
<<Generate calendar file | modeline sets vimrc options on a per file basis >>
Additional Notes
cec@NgrOyphSon.gPsfAc.nMasa.gov, September 20, 2003 9:09
Check out :he 'ww' ; in particular try :set
ww=h,l . For a more complete set, try
set ww=b,s,<,>,[,],h,l
latif@techuser.net, September 24, 2003 20:32
The 'ww' option works much better than my script, so I
will be taking the script off my site. Thanks for
posting the comment.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
2003
Q 1
Jan 2003
========================================
========================================
----------------------------------------
This may be stored in a file accessible by a single key stroke from vim.
Here is the function:
function! Calendar(year, month, day, weekday, week, daycount)
" output daycount calendar days starting from given date
" into new buffer
new
set buftype=nofile bufhidden=hide noswapfile
let year = a:year
let month = a:month
let day = a:day
let wd = a:weekday
let week = a:week
let index = 0
let date = ''
let diy = 777 " day in year, wrong before next year
while (index < a:daycount) " no of days to output
let diy = diy + 1
if (wd > 7)
let wd = 1
let week = week + 1
if (week >= 53)
if (week >= 54)
let week = 1
elseif (day >= 28 || day <= 3)
let week = 1
endif
endif
endif
if (wd == 1) " day name
let dn = "Mo"
elseif (wd == 2)
let dn = "Tu"
elseif (wd == 3)
let dn = "We"
elseif (wd == 4)
let dn = "Th"
elseif (wd == 5)
let dn = "Fr"
elseif (wd == 6)
let dn = "Sa"
elseif (wd == 7)
let dn = "Su"
else
let dn = "** ERROR: Unknown day name ** "
endif
if ((day > 31) || (month == 2 && (day > 29 || day > 28 && year % 4))
\ || (month == 4 && day > 30) || (month == 6 && day > 30)
\ || (month == 9 && day > 30) || (month == 11 && day > 30))
let day = 1
let month = month + 1
if (month > 12)
let month = 1
let diy = 1
let year = year + 1
if (wd <= 3)
let week = 1
endif
endif
if (month == 1)
let yline = "===================="
call append(line("$"), yline . "
" . year . "
" . yline . yline )
call append(line("$"), yline . "
Q 1
" . yline . yline )
let monthn = "Jan" " month name
elseif (month == 2)
let monthn = "Feb"
elseif (month == 3)
let monthn = "Mar"
elseif (month == 4)
let monthn = "Apr"
call append(line("$"), yline . "
Q 2
" . yline . yline )
elseif (month == 5)
let monthn = "May"
elseif (month == 6)
let monthn = "Jun"
elseif (month == 7)
let monthn = "Jul"
call append(line("$"), yline . "
Q 3
" . yline . yline )
elseif (month == 8)
let monthn = "Aug"
elseif (month == 9)
let monthn = "Sep"
http://www.vim.org/tips/tip.php?tip_id=560 (2 of 5) [18/02/2004 15:04:48]
Life Changing
Helpful
Unfulfilling
rate
<<Use Vim to Expire your Mail (So that Mutt can delete them later) | Context Sensitive h and l >>
Additional Notes
Siegfried.Bublitz@c-lab.de, September 22, 2003 5:07
-", "w")
SourceForge
Logo
Tip #559 - Use Vim to Expire your Mail (So that Mutt can delete them later) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #559: Use Vim to Expire your Mail (So that Mutt can delete them
later)
tip karma
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Using TagList for ANT build files | Generate calendar file >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Tip #559 - Use Vim to Expire your Mail (So that Mutt can delete them later) : vim online
Logo
Tip #558 - Using TagList for ANT build files : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Tip #558 - Using TagList for ANT build files : vim online
very powerful.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Opening several files in vim via ListFile | Use Vim to Expire your Mail (So that Mutt can delete them
later) >>
Additional Notes
Anonymous, September 17, 2003 9:16
Wow, this is cool!
A few further suggestions on the ctags config file
(things I've added to mine now):
(1) a pattern can also be (optionally) added for
properties:
--regex-ant=/^[ \t]*<[ \t]*property.*name="([-.a-zA-Z09 ]+)".*>/\1/r,property/i
(2) Since almost any character can be used in an Ant
name, I also modified the regex for the names to only
exclude those characters that Ant won't allow:
--regex-ant=/^[ \t]*<[ \t]*project.*name="([-.a-zA-Z0-9
]+)".*>/\1/p,project/i
--regex-ant=/^[ \t]*<[ \t]*target.*name="([-.a-zA-Z0-9
]+)".*>/\1/t,target/i
--regex-ant=/^[ \t]*<[ \t]*property.*name="([-.a-zA-Z09 ]+)".*>/\1/r,property/i
Also, to use the property tags, change the
tlist_ant_settings in the .vimrc to:
let g:tlist_ant_settings =
'ant;p:Project;t:Target;r:Property'
Anonymous, September 17, 2003 9:18
Arggghh! Stupid me.
supposed to be:
--regex-ant=/^[ \t]*<[
\t]*project.*name="([^<"&]+)".*>/\1/p,project/i
--regex-ant=/^[ \t]*<[
\t]*target.*name="([^<"&]+)".*>/\1/t,target/i
--regex-ant=/^[ \t]*<[
\t]*property.*name="([^<"&]+)".*>/\1/r,property/i
(sorry)
http://www.vim.org/tips/tip.php?tip_id=558 (2 of 3) [18/02/2004 15:04:54]
Tip #558 - Using TagList for ANT build files : vim online
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #557 - Opening several files in vim via ListFile : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
<<Help on <F2> for Python with pydoc | Using TagList for ANT build files >>
Additional Notes
Anonymous, September 26, 2003 10:15
rate
Tip #557 - Opening several files in vim via ListFile : vim online
try:
gvim -c ":args `type mylist`"
FWIW,
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #556 - Help on <F2> for Python with pydoc : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Vim as bookmark manager | Opening several files in vim via ListFile >>
Additional Notes
fritz@mail4free.at, September 11, 2003 16:42
You may replace the xterm in the two lines to the gnometerminal or kterm or some other
fs111@linuxmail.org, September 12, 2003 0:29
Does not work for me, what may be wrong?
Anonymous, September 12, 2003 1:48
Tip #556 - Help on <F2> for Python with pydoc : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Smarter Table Editing II | Help on <F2> for Python with pydoc >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Kartik Agaram, September 14, 2003 0:41
Nice, but I think it belongs in the documentation of the corresponding script. No need to allocate multiple
tip/script ids for the same thing. Hence I vote -1 here but 1 on the script.
latif@techuser.net, September 16, 2003 22:15
it from a
The scripts
simply
lots of
I realize that whether something constitutes a tip or script is a subjective opinion. You may disagree with me,
but it is not worth debating imo. Select one of the two sections. Just one.
As a postscript, it is interesting to compare the karma of your vimtip #548 and Robert Kelly's vimscript #763. I
will hazard the hypothesis that the vim online community has a pretty good idea of where that particular (very
useful!) idea belongs.
Anonymous, November 10, 2003 12:38
Great plugin.
Suggestion: add some messages to the user such as "tablemode: enabled" and "tablemode: heading is invalid", etc.,
using echo
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
RESULT
DESCRIPTION
Number
append {string}
Number
number of files
Number
current index in
String
{nr} entry of
Life Changing
Helpful
Unfulfilling
rate
<<Vim goes INTL - Translating Messages, Menus, Encodings | Using H and L keys as context
sensitive pagedown/pageup >>
Additional Notes
latif@techuser.net, September 1, 2003 18:32
If you have any suggestions as to improving the table
editing feature outlined in this tip please send your
comments to latif@techuser.net. I am giving out free
text processing consulting on my website
http://www.techuser.net. You can make a request for any
additional functionality (vim scripts, etc.) not
related to this tip on my website.
tkieselstein@web.de, September 3, 2003 2:39
In my settings, I had to use offset = -1 to start
exactly at the next table column.
Alternatively, change line 37 of the function
from:
call cursor(linenum,nextposn+a:offset)
to:
call cursor(linenum,nextposn+a:offset-1)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #546 - Vim goes INTL - Translating Messages, Menus, Encodings : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: advanced
as of Vim: 5.7
[1.1]
^
|
Tip #546 - Vim goes INTL - Translating Messages, Menus, Encodings : vim online
'
|
|
|
|
.
`-------------<--------------|
(#3)
|
+--- LANG.po <--- New LANG.pox
<----'
|
.--- LANG.gmo <--- msgfmt <---'
|
|
(#4)
(#5)
|
`---> install ---> /.../LANG/PACKAGE.mo ---.
|
+---> "Hello
world!"
`-------> install ---> /.../bin/PROGRAM -------'
~~~~~~~~~~~~~~ END QUOTE ~~~~~~~~~~~~~~
(drwng got distorted in textarea)
STEP #1
------Get the most recent of the vim sources (vim-6.1-src1.tar.gz,
vim-6.1-src2.tar.gz) from http://www.vim.org/download.php
# create a temporary folder - let's call it "vim_tmp" # anywhere on your disk:
mkdir /path/to/vim_tmp
# copy the vim source tarball(s) in the temporary directory:
cp /original/location/vim???.tar.gz /path/to/vim_tmp
# change to that directory:
cd /path/to/vim_tmp
# and decompress them (currently there are only two source
# archives):
tar xvfz vim-6.1-src1.tar.gz ; tar xvfz vim-6.1-src2.tar.gz
NOTE: Several subdirectories are created, but only the `src'
directory contains really translatable strings.
[1.1]
------We bypass this step since all canditate strings for
translation in C sources are already marked with `N_()' or `_()'
in
vim source files. For a full discussion of how to mark strings
as
translatable in C source files, please refer to the GNU `gettext'
utilities manpage. We'll return later to this step as the
keywords in
Tip #546 - Vim goes INTL - Translating Messages, Menus, Encodings : vim online
vim source files (`N_' and `_') are needed as an argument to the
`xgettext' command.
IMPORTANT: Before proceeding to make the PO file, we'll have to
tag the sources, i.e. create the `tags' file:
# since the `src' directory is the only one containing
# translatable strings, and because only *.c files plus
# two more fileS (globals.h, if_perl.xs) have them,
# we switch to the `src' directory and issue:
etags *.[ch] *.xs
# to make sure all files get tagged
# we could just as well have issued:
etags src/*/*.*
STEP #2
------The command-line options we'll use are fully described
in the gettext manpage.
NOTE: (i) We'll add the `join' option in the second instance
of the command line so that the strings for the second keyword
(`_')
be extracted and appended to the same vim.po file; otherwise a
second
file vim.po would have to be created. (ii) We use
INPUTFILE=*.[ch]
because we know where the strings are to be exctracted from; else
we
must use INPUTFILE=* to exctract from all files.
# We are ready
# keyword, and
#
# translatable
xgettext -a -d
Tip #546 - Vim goes INTL - Translating Messages, Menus, Encodings : vim online
#: globals.h:1053
msgid "E14: Invalid address"
msgstr ""
...
Now before proceeding to get the binary text we're after
(vim.mo), we'll have to translate _all_and_each_messages_
listed in the vim.po file. The translator must insert the
translated sting as the value of the `msgstr' variable
(between quotation marks).
To stay with the previous quotation, the Italian translation
of the excerpt above is:
...
#: ex_cmds.c:4421
msgid "E149: Sorry, no help for %s"
msgstr "E149: Spiacente, nessun aiuto per %s"
#: globals.h:1053
msgid "E14: Invalid address"
msgstr "E14: Indirizzo invalido"
...
[2.1]
------We currently have no use for the `tupdate' command since
there's no vim.po file yet; however, this program comes handy
when we
already have a *.po file and must update it based on a new
release of
sources. The command is simple enough. After unpacking the new
tarballs to our "vim_tmp" directory (step 1), we issue:
# change to tmp directory
cd /path/to/vim_tmp
# rename "vim.po" to "OLD_vim.po" assuming it's placed here:
mv vim.po OLD_vim.po
# update OLD_vim.po:
tupdate NEW_vim.po OLD_vim.po
# rename "NEW_vim.po" back to its usable filename:
mv NEW_vim.po vim.po
In case we don't want to go through the whole process of
creating a vim.po file after a new vim-###-src#.tar.gz
release, this program will take care of recreating our updated
vim.po file (NEW_vim.po) from OLD_vim.po, including the old
translations which will be taken over to the newly created
file as long as they still match. However, it is recommended
that, after a new vim_src### release, we actually start over.
Just in case!
http://www.vim.org/tips/tip.php?tip_id=546 (4 of 9) [18/02/2004 15:05:14]
Tip #546 - Vim goes INTL - Translating Messages, Menus, Encodings : vim online
STEP #3
------Next step is simplicity itself--assuming all messages
have already been translated in vim.po. We'll only use one option
out
of several that the `msgfmt' program supports; they are fully
described
in the `msgfmt' manpage. For hints on internationalizing Vim see
the
previous VimTip (VimTip#).
# change to tmp directory where our vim.po is placed:
cd /path/to/vim_tmp
# create vim.mo from vim.po:
msgfmt -o vim.mo vim.po
# or in full-text:
msgfmt --output-file=vim.mo vim.po
STEP #4
------Installing the vim.mo file requires that a directory
in $VIMRUNTIME$ (i.e. currently /path/to/vim61) exists or is
created
express for the language you'll be supporting.
Let's suppose the language we support is Greek (abbreviated as
`gr' or `el'). We do:
# create directory named `el' in $VIMRUNTIME$/path/to/lang
# with a standard subdirectory `LC_MESSAGES':
mkdir /path/to/vim61/lang/el
mkdir /path/to/vim61/lang/el/LC_MESSAGES
# copy our vim.mo file for Greek language supported:
cp /path/to/vim_tmp/vim.mo /path/to/vim61/lang/el/LC_MESSAGES
STEP #5
------Vim detects the system's local language settings when
starting and--if supported--loads it automatically; else you'll
have
to change default message language from within Vim using:
" lan[guage] {name} e.g.: lan el
" now let's test if it's working by issuing an erroneous vim
command--like: :HELP
" and you'll get the message:
: HELP
" that's all Greek to me: HELP
http://www.vim.org/tips/tip.php?tip_id=546 (5 of 9) [18/02/2004 15:05:14]
Tip #546 - Vim goes INTL - Translating Messages, Menus, Encodings : vim online
Menu Translation
================
BASICS
-----For Latin-based languages, menu translation is
fairly painless. Open a `menu_xx_xx.latin1.vim' and use it as
a template to create the menu after translating the relevant
strings into the Latin-based language you intend to support.
You only have to pay attention that unique letter identifiers
in a given submenu don't repeat (e.g. &Open binds the letter
`O' uniquely so that the keyboard responds to Alt-O, and
cannot be repeated in the "File" menu. For Latin-based
languages, at least one encoding must be defined as the
default encoding for a given system; Latin1 is used on all
OS'. If your canditate language is non-Latin but Latin-based,
--as a rough rule--do menu translations in at least one of the
following encodings:
o utf-8
o iso-####-#
o an MS-DOS/wINDOWS code page
--consult old MS-DOS (v.5 or 6.2) online help for
codepage and/or country setting details).
HOW-TO
-----To create the menu file, we use one or several
word processors that supports one or several of the encodings
for the language we intend to support. If we can find the
above encodings in the SaveAs option of our word processor(s),
it's already sufficient -- depending on the number of OS' you
wish to support. We can use, for example, an existing
menu_xx_xx.latin1.vim template and translate the translatable
strings pretty much like the gettext program prepares them by
distinguishing between `msgid "ABC"' and `msgstr "XYZ"'.
Instead we'll do it manually. Save only the translated
strings of the supported language (i.e. `msgstr "XYZ"' in our
example) into a separate file using the Save As option of a
word processor (e.g. MS-Word). Now we have, for example, a
file containing the translated stings, say in iso-####-x with
filename `msgstr_iso-####-x'.
http://www.vim.org/tips/tip.php?tip_id=546 (6 of 9) [18/02/2004 15:05:14]
Tip #546 - Vim goes INTL - Translating Messages, Menus, Encodings : vim online
&Help
&Overview<Tab><F1>
&How-to\ links
&User\ Manual
Tip #546 - Vim goes INTL - Translating Messages, Menus, Encodings : vim online
not use the word processor that helped with the encoding; else
you might get the wrong bytes in encodings when the left-most
part of the file is saved along with the rest.
We can repeat the same (painstaking, yet menus are short)
process with utf-8 encoding, MS-wINDOWS codepage, and any
other encoding we need to support.
Encodings
=========
To create the language encodings files for Vim in any
language, we first jot down the full specification of the
encodings in the most common OS' for the language we intend to
support.
Next we create a corresponding menu_xx_yy.ABC_mn-zz.vim file
for each of these supported encondings (making sure they
exist!).
We may use only one or several menu translations (we suggested
three basic ones above, sect. 2); one of these -- the one
with the translated strings -- can be used as the default
encoding to reference other ones. We reference the encodings
we cannot create with a word processor to the default encoding
using any menu_xx_yy.ABC_mn-zz.vim as a template.
Here's the Spanish menu for the MS-wINDOWS codepage 850
specification (lang/menu_spanish_spain.850.vim):
~~~~~~~~~~~~~~~~~~~~~~ QUOTE ~~~~~~~~~~~~~~~~~~~~~~
source <sfile>:p:h/menu_es_es.iso_8859-1.vim
~~~~~~~~~~~~~~~~~~~~ END QUOTE ~~~~~~~~~~~~~~~~~~~~
As you can see, it contains only one line and sources this spec
here from another one (i.e. es_es.iso_8859-1 in this case).
Examples
========
As an example for fully supporting a specific language you may
download the Greek tarball:
http://lynxx.org/misc/download/vim-6.1-menu_el.zip
http://lynxx.org/misc/download/vim-6.1-menu_el.tgz
See also VimTip "Vim goes Greek - Complete set of Greek language
support for Vim 6.1" (VimTip#).
Disclaimer
==========
Tip #546 - Vim goes INTL - Translating Messages, Menus, Encodings : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Vim goes Greek - Greek language support for Vim 6.1 | Smarter Table Editing >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #545 - Vim goes Greek - Greek language support for Vim 6.1 : vim online
Home
Search
Tip #545: Vim goes Greek - Greek language support for Vim 6.1
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
complexity: intermediate
as of Vim: 5.7
Vim goes Greek - Complete set of Greek language support for Vim 6.1
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Scripts
Tips
My Account
ENGLISH TEXT
------------
Site Help
Tip #545 - Vim goes Greek - Greek language support for Vim 6.1 : vim online
http://lynxx.org/misc/download/vim-6.1-menu_el.tgz
To use Vim to edit in Greek (or any) language, we first enable
the language option for the keyboard (Control
Panel|Keyboard|Languages|Greek) and enable a key sequence
(e.g. Ctrl-Shift) to toggle between the default language and
Greek. In Vim the Greek language is displayed correcty.
Finally, we unzip vim-6.1-menu_el to the vim61 directory. This
ensures that the above files are place in the correct path. If
you don't know how to extract to $VIMRUNTIME, unzip to any
temporary folder. Then drag&drop or copy-and-paste each of the
above files to its place after creating the container folders
(/path/to/vim61/lang/el).
This is what one may call manual extraction, so please wash your
hands beforehand.
For help on setting up Vim to support Greek -- from Vim do:
:help language
:help messages
:help encoding
For messages you'll have to set at least:
let $LANG='el' / let $LANG='gr'
:lan mes el / :lan mes gr
For menus:
:menut English Greek / let menut=Greek
from the cmdline or in the _vimrc file.
For more information see VimTip #
"Vim goes INTL Translating Vim Editor Messages, Menus, Encodings".
Enjoy Vim a la Greek!
GREEK TEXT
---------Vim - Vim 6.1
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
,
Vim 6.1.
:
++++++++++++
vim.pot --
vim-6.1 (
Tip #545 - Vim goes Greek - Greek language support for Vim 6.1 : vim online
vim.po -- vim.pot
.
lang/el/LC_MESSAGES/vim.mo
-- vim.po
(vim.mo)
lang/menu_gr_gr.greek.vim
-- Greek
lang/menu_gr_gr.latin1.vimq
-- Latin
lang/menu_gr_gr.iso_8859-1.vim
-- ISO
,
iso_8859-7
lang/menu_gr_gr.iso_8859-7.vim
-- ISO
-
lang/menu_greece_greek.737.vim -- MS-DOS/wINDOWS
(737)
lang/menu_greek_greece.1253.vim -- MS-DOS/wINDOWS
(1253)
lang/menu_greek_greece.cp437.vim
-- Unix
(nl_cp437)
lang/menu_gr_gr.utf-8.vim
-- UTF-8
tutor/tutor.gr -- Vim
README.TXT --
:
http://lynxx.org/misc/download/vim-6.1-menu_el.zip
http://lynxx.org/misc/download/vim-6.1-menu_el.tgz
Vim
( ,
( ||
|) (.. )
. Vim .
, vim-6.1-menu_el vim61.
. $VIMRUNTIME,
. --
--
(///vim61/lang/el).
Tip #545 - Vim goes Greek - Greek language support for Vim 6.1 : vim online
,
.
Vim
, Vim, :
:help language
:help messages
:help encoding
Vim.
:
let $LANG='el' / let $LANG='gr'
:lan mes el / :lan mes gr
:
:menut English Greek / let menut=Greek
_vimrc.
, VimTip # ("Vim goes INTL Translating Vim Editor Messages, Menus, Encodings").
Kales epejergasies keimenou!
Vaggelis Efstratiou
vangelise@lynxx.org
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Vim goes Greek - Greek language support for Vim 6.1 | Vim goes INTL - Translating Messages, Menus, Encodings >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
http://www.vim.org/tips/tip.php?tip_id=544
Home
Search
Tip #544: Vim goes Greek - Greek language support for Vim 6.1
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
complexity: intermediate
as of Vim: 5.7
Vim goes Greek - Complete set of Greek language support for Vim 6.1
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Scripts
Tips
My Account
ENGLISH TEXT
------------
Site Help
http://www.vim.org/tips/tip.php?tip_id=544
GREEK TEXT
---------Vim - Vim 6.1
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
,
Vim 6.1.
:
++++++++++++
vim.pot --
http://www.vim.org/tips/tip.php?tip_id=544 (2 of 4) [18/02/2004 15:05:30]
http://www.vim.org/tips/tip.php?tip_id=544
vim-6.1 (
vim.po -- vim.pot
.
lang/el/LC_MESSAGES/vim.mo
-- vim.po
(vim.mo)
lang/menu_gr_gr.greek.vim
-- Greek
lang/menu_gr_gr.latin1.vimq
-- Latin
lang/menu_gr_gr.iso_8859-1.vim
-- ISO
,
iso_8859-7
lang/menu_gr_gr.iso_8859-7.vim
-- ISO
-
lang/menu_greece_greek.737.vim -- MS-DOS/wINDOWS
(737)
lang/menu_greek_greece.1253.vim -- MS-DOS/wINDOWS
(1253)
lang/menu_greek_greece.cp437.vim
-- Unix
(nl_cp437)
lang/menu_gr_gr.utf-8.vim
-- UTF-8
tutor/tutor.gr -- Vim
README.TXT --
:
http://lynxx.org/misc/download/vim-6.1-menu_el.zip
http://lynxx.org/misc/download/vim-6.1-menu_el.tgz
Vim
( ,
( ||
|) (.. )
. Vim .
, vim-6.1-menu_el vim61.
. $VIMRUNTIME,
. --
--
http://www.vim.org/tips/tip.php?tip_id=544
(///vim61/lang/el).
,
.
Vim
, Vim, :
:help language
:help messages
:help encoding
Vim.
:
let $LANG='el' / let $LANG='gr'
:lan mes el / :lan mes gr
:
:menut English Greek / let menut=Greek
_vimrc.
, VimTip # ("Vim goes INTL Translating Vim Editor Messages, Menus, Encodings").
VimTip #
:
http://www.vim.org/tips/tip.php?tip_id=
Kales epejergasies keimenou!
Vaggelis Efstratiou
vangelise@lynxx.org
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<vim.po - Internationalizing the Vim editor | Vim goes Greek - Greek language support for Vim 6.1 >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Edit remote files locally via SCP/RCP/FTP | Vim goes Greek - Greek language support for Vim 6.1
>>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #542 - Edit remote files locally via SCP/RCP/FTP : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Tip #542 - Edit remote files locally via SCP/RCP/FTP : vim online
Life Changing
Helpful
Unfulfilling
rate
<<How to get help using VIM | vim.po - Internationalizing the Vim editor >>
Additional Notes
rob@machorro.net, August 27, 2003 11:18
Soon after I had posted this item, I stumbled into
http://www.vim.org/tips/tip.php?tip_id=337 from Matthew
Weier O'Phinney. Don't want to post a similar Tip so as
soon as I figure out how to delete this Tip, I will.
cec@NdjOinnSi.gPsfAc.nMasa.gov, August 27, 2003 12:53
There's no way to delete a tip, sorry to say.
<netrw.vim> also supports rsync, fetch, dav, and rcp.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
If you need help with vim and do not know where to go.
Check out the Community link on the left. Or click this
link
http://vim.sourceforge.net/community.php
Life Changing
Helpful
Unfulfilling
rate
Site Help
<<vim6.2 or vim6.1? | Edit remote files locally via SCP/RCP/FTP >>
Additional Notes
zzapper@ntlworld.com, August 23, 2003 15:53
also
http://groups.google.com/groups?group=comp.editors
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #548 - Using H and L keys as context sensitive pagedown/pageup : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Tip #548 - Using H and L keys as context sensitive pagedown/pageup : vim online
Unfortunately, I am not
aware of a way to make that count available to the user
functions I wrote. The
typical vim behavior in case of user functions is to
supply the count as a
range to the user function. This works most of the time
but sometimes the count
gets rejected because of range checking. If you are
aware of a workaround
please let me know.
You can contact me by writing to latif@techuser.net. If
you have suggestions as
to other keys that can be made context sensitive without
affecting their
original function, email me. I also maintain a webpage
where you can ask help
for your text processing problems. The webpage is at
http://www.techuser.net
---------------------------------Cut Here--------------------------------------func! Hcontext()
if (winline() == 1 && line(".") != 1)
exe "normal! \<pageup>H"
else
exe "normal! H"
endif
echo ''
endfunc
func! Lcontext()
if (winline() == winheight(0) && line(".") !=
line("$"))
exe "normal! \<pagedown>L"
else
exe "normal! L"
endif
echo ''
endfunc
---------------------------------Cut Here--------------------------------------rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Smarter Table Editing | Switching normal and insert-mode disturbes cursorposition >>
Additional Notes
http://www.vim.org/tips/tip.php?tip_id=548 (2 of 5) [18/02/2004 15:05:45]
Tip #548 - Using H and L keys as context sensitive pagedown/pageup : vim online
Tip #548 - Using H and L keys as context sensitive pagedown/pageup : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #548 - Using H and L keys as context sensitive pagedown/pageup : vim online
Tip #549 - Switching normal and insert-mode disturbes cursorposition : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Tip #549 - Switching normal and insert-mode disturbes cursorposition : vim online
<<Using H and L keys as context sensitive pagedown/pageup | FreeBSD Fix: Arrow keys/cursor
movement prints A B C D letters on remote shell: xterm, vt100. >>
Additional Notes
latif@techuser.net, September 3, 2003 17:42
Vim provides the <C-O> combination to invoke functions
from insert mode. You can use the following mapping:
imap <A-F12> <C-O>:call EchoCursor()<CR>
The above will report the correct cursor position and
also leave the cursor in insert mode. You might have
trouble viewing the echo message as it will be quickly
replaced. You can use the getchar() function to make
vim wait and let you see the echo message.
:he inserting
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #550 - FreeBSD Fix: Arrow keys/cursor movement prints A B C D letters on remote shell: xterm, vt100. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Hi,
I wonder how many of you are pissed of with arrow keys
behavior during INSERT mode in Vim.
So was I.
Leave all the key mappings default, do not change your
TERM environment.
Here's a simple tip,
:set term=cons25 and save the settings for Vim usage.
It was tested with Vim 5.8 and 6.1 editions on; FreeBSD
4.X-STABLE; xterm(-color),VT100 remote terminals; (t)csh
shells.
Greets.
Peace.
Legalize it.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Switching normal and insert-mode disturbes cursorposition | automatic indenting XML file in VIM
with the help of XSLT >>
Additional Notes
cat@eecs.harvard.edu, September 25, 2003 17:07
Tip #550 - FreeBSD Fix: Arrow keys/cursor movement prints A B C D letters on remote shell: xterm, vt100. : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #551 - automatic indenting XML file in VIM with the help of XSLT : vim online
Home
Search
Tip #551: automatic indenting XML file in VIM with the help of XSLT
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: advanced
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<FreeBSD Fix: Arrow keys/cursor movement prints A B C D letters on remote shell: xterm, vt100. | replace buffer
list when switching >>
Tip #551 - automatic indenting XML file in VIM with the help of XSLT : vim online
Additional Notes
anon@hello.com, September 6, 2003 13:21
What is xsltproc?
fs111@linuxmail.org, September 7, 2003 7:21
It is a command line tool and it is part of the gnome libxslt.
Look at their website for more information:
http://xmlsoft.org/XSLT.html
regards Andr
nil@nil.com, September 11, 2003 7:19
Yep, using an XSLT which copies the document (not the file) is
a common way to get pretty-printed XML.
Here are some more tips, variations, and alternatives:
http://www.pinkjuice.com/howto/vimxml/tasks.xml#prettyprinting
and
http://www.pinkjuice.com/howto/vimxml/setup.xml#xsltlint
Tobi
joey@neuralyte.org, October 2, 2003 18:50
If you don't have a copy of XSLT, you can use the following to
indent XML/HTML:
:%s/></>\r</g
:0
=:$
Anonymous, October 28, 2003 11:15
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">;
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
Anonymous, October 28, 2003 11:15
Tip #551 - automatic indenting XML file in VIM with the help of XSLT : vim online
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">;
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
complexity: basic
as of Vim: 5.7
Scripts
Tips
My Account
Site Help
2. Quit vim
:xa
3. Restart with different session file:
vim -S ~/v/project2.vim
I was exiting and re-opening vim because if I just
loaded the second project file, a list of /both/
projects buffers would appear in my buffer list. This
was not what I wanted-- I wanted to replace the first
buffer list completely wtih the second.
There is a simple way to do this.
At the top of a session file, add this:
1,999bdelete
That will delete the first 999 existing buffers,
effectively allowing any new buffer definitions in the
rest of the session file to replace
what is currently there. Now you can switch directly to
a new session without exiting. Just use:
:so ~/v/project2.vim
Life Changing
Helpful
Unfulfilling
<<automatic indenting XML file in VIM with the help of XSLT | Prev and Next >>
rate
Additional Notes
of(AT)oersted(DOT)dtu(DOT)dk, September 10, 2003 0:22
Instead of
1,999bdelete
which deletes 'only' buffers 1 to 999 (which is
sufficient in most cases), you can easily write
%bdelete
which deletes ALL buffers.
jkr@jottkaerr.de, September 10, 2003 23:34
This won't always work.
%bdelete
only deletes as many buffers as there are lines in the
current buffer.
vim@torrin.net, September 11, 2003 16:17
How about this . . .
:execute "1," . bufnr("$") . "bdelete"
That should delete all the buffers. When I say delete,
it will only unlist them. The check this execute the
above command then run this command.
:ls!
akawaka@nospam.skynet.ie, October 8, 2003 21:29
Is there anyway to reset the buffer index numbers?
After switching between two or three sessions for a
while the buffer numbers can become pretty large.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Try it.
Use it.
Have a nice day.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
better.not@11101010010101001000101010110110100101001.101,
September 10, 2003 10:06
:jumps
not
:jumplist
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Usage:
Select region and press <A-q> to format.
In ~/_vimrc put (-j is for justify lines)
:set formatprg=par\ -w60
: map <A-q> {v}!par -jw60<CR>
:vmap <A-q> !par -jw60<CR>
Examples from par.man
Before:
/*
/*
/*
/*
/*
/*
/*
/*
/*
/*
in
/*
We the people of the United States,
*/
/* order to form a more perfect union, establish
*/
/* justice, insure domestic tranquility, provide
http://www.vim.org/tips/tip.php?tip_id=584 (1 of 12) [18/02/2004 15:06:06]
*/
/* for the common defense, promote the general
*/
/* welfare, and secure the blessing of liberty
*/
/* to ourselves and our posterity, do ordain
*/
/* and establish the Constitution of the
United */
/* States of
America.
*/
Or after "par -59f":
/*
/*
/*
/*
/*
/*
/*
/*
/*
*/
*/
*/
*/
*/
*/
*/
*/
*/
in
/*
We the people of the United States,
*/
/* order to form a more perfect union, establish
*/
/* justice, insure domestic tranquility,
*/
/* provide for the common defense, promote
*/
/* the general welfare, and secure the
*/
our
the
*/
Or after "par -59lf":
/*
/*
/*
/*
/*
*/
*/
*/
*/
*/
/*
/*
/*
/*
*/
*/
*/
*/
*/
/* in order to form a more perfect
union,
*/
/* establish justice, insure
domestic
*/
/* tranquility, provide for the common
*/
/* defense, promote the general welfare,
*/
/* and secure the blessing of
liberty
*/
/* to ourselves and our posterity,
do
*/
/* ordain and establish the Constitution
*/
/* of the United States of
America.
*/
Or after "par -59j":
/*
We
the people
of
the
United States,
in
*/
/* order to form a more perfect union, establish
*/
/* justice, insure domestic tranquility, provide
*/
/* for the
the general
*/
/* welfare, and
of liberty
*/
/* to ourselves and our posterity, do ordain and
*/
/* establish
the
Constitution
of
the
United
*/
/* States of
America.
*/
We
the
people
of
order
to
form
the
United
States,
more
perfect
*/
/* in
*/
/* union,
establish
justice,
insure
domestic
*/
/* tranquility, provide for
*/
/* promote
the
general
welfare,
and
secure
*/
/* the
blessing
of
/* our
posterity, do
liberty to
ourselves
and
*/
ordain and
establish the
*/
/* Constitution of the United States of America.
*/
Before:
Preamble
to the US
Constitution
in order to form
a more perfect union,
establish justice,
insure domestic tranquility,
provide for the common defense,
promote the general welfare,
and secure the blessing of liberty
to ourselves and our posterity,
do ordain and establish
the Constitution
of the United States of America.
States,
Before:
1
2
3
4
5
6
7
8
9
10
3
4
5
to
justice,
ourselves
6
the
America.
Before:
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
We the people
of the United States,
in order to form a more perfect union,
establish justice,
ensure domestic tranquility,
provide for the common defense,
America.
After "par -52":
>
>
>
>
>
>
>
>
>
>
>
>
>
>
We the people
of the United States,
in order to form a more perfect union,
establish justice,
ensure domestic tranquility,
provide for the common defense,
Promote the general welfare,
and secure the blessing of liberty
to ourselves and our posterity,
do ordain and establish
the Constitution of the United States of
America.
After "par -52d":
>
>
>
>
>
>
>
>
>
>
Before:
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
4.
5.
6.
7.
8.
ensure domestic
tranquility.
Provide for the common
defense
Promote the general
welfare.
And secure the blessing
of liberty to ourselves
and our posterity.
Do ordain and establish
the Constitution.
Of the United States of
America.
Before:
/*****************************************/
/*
We the people of the United States, */
/* in order to form a more perfect union, */
/* establish justice, insure domestic
*/
/* tranquility,
*/
/*
*/
/*
*/
/*
[ provide for the common defense, ] */
/*
[ promote the general welfare,
] */
/*
[ and secure the blessing of liberty ] */
/*
[ to ourselves and our posterity, ] */
/*
[
] */
/*
*/
/* do ordain and establish the Constitution */
/* of the United States of America.
*/
/******************************************/
After "par -42r":
/********************************/
/*
We the people of the
*/
/* United States, in order to
*/
/* form a more perfect union,
*/
/* establish justice, insure
*/
/* domestic tranquility,
*/
/*
*/
/*
*/
/*
[ provide for the common ] */
/*
[ defense, promote the
] */
/*
[ general welfare, and
] */
/*
[ secure the blessing of ] */
/*
[ liberty to ourselves
] */
/*
[ and our posterity,
] */
/*
[
] */
http://www.vim.org/tips/tip.php?tip_id=584 (7 of 12) [18/02/2004 15:06:06]
/*
*/
/* do ordain and establish the */
/* Constitution of the United
*/
/* States of America.
*/
/********************************/
Or after "par -42re":
/********************************/
/*
We the people of the
*/
/* United States, in order to
*/
/* form a more perfect union,
*/
/* establish justice, insure
*/
/* domestic tranquility,
*/
/*
*/
/*
[ provide for the common ] */
/*
[ defense, promote the
] */
/*
[ general welfare, and
] */
/*
[ secure the blessing of ] */
/*
[ liberty to ourselves
] */
/*
[ and our posterity,
] */
/*
*/
/* do ordain and establish the */
/* Constitution of the United
*/
/* States of America.
*/
/********************************/
Before:
Joe Public writes:
> Jane Doe writes:
> >
> >
> > I can't find the source for uncompress.
> Oh no, not again!!!
>
>
> Isn't there a FAQ for this?
>
>
That wasn't very helpful, Joe. Jane,
just make a link from uncompress to compress.
After "par -40q":
Joe Public writes:
> Jane Doe writes:
>
>
> > I can't find the source for
http://www.vim.org/tips/tip.php?tip_id=584 (8 of 12) [18/02/2004 15:06:06]
I've
I've
Before:
John writes:
: Mary writes:
: + Anastasia writes:
: + > Hi all!
: + Hi Ana!
: Hi Ana & Mary!
Please unsubscribe me from alt.hello.
After "par Q+:+ q":
John writes:
:
:
:
:
:
:
:
:
:
Mary writes:
+ Anastasia writes:
+
+ > Hi all!
+
+ Hi Ana!
Hi Ana & Mary!
Life Changing
Helpful
Unfulfilling
Additional Notes
faugn@despammed.com, October 12, 2003 3:00
http://www.nicemice.net/par/
aldy0169@yahoo.com, October 16, 2003 12:18
set equalprg=par
visually select an area and hit '='
ykhov@uwaterloo.ca, October 24, 2003 16:19
rate
I'm using par -w78 option right now and loves it.
Anybody know the option for par to leave double spaces
after each sentences?
Anonymous, November 26, 2003 10:16
Most of what I can see here can be done with built-in
commands as well. See "=", "gq" for instance...
Anonymous, December 5, 2003 5:20
see also fmt(1) on a BSD System
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
fs111@linuxmail.org, October 13, 2003 3:38
The server is down, has someone a copy to share?
Andr
Anonymous, October 13, 2003 7:22
Server should be available again.
It is just a private server with dynamic DNS on DSL.
Feel free to publish the file elsewherean a more
reliable server, but please put a link here.
Greetz, Bjrn
P.S.: Corrections and Additions are welcome!
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Keymap for normal mode | Preview current file in Mozilla through localhost >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #587 - Preview current file in Mozilla through localhost : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Tip #587 - Preview current file in Mozilla through localhost : vim online
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
markwoodwardATbigpond.com, October 14, 2003 20:38
I'd be interested if there's a way to open in a new tab
in moz rather than a new window? Or even open in the
current window (replacing the old page). Does anyone
have any suggestions?
-Mark
fs111@linuxmail.org, October 18, 2003 4:40
Try something like this:
mozilla -remote 'openURL(http://www.vim.org, new-tab)'
HTH
Andr
antoine.mechelynck@belgacom.net, October 30, 2003 12:49
A related piece of info for Windows:
start filename.ext
(in the shell) "opens" the named file with its default
action. This means, for instance, that
:w | ! start %
(in Vim with the cursor on an html file) will save the
current file, then open it in your default browser. On
my system, it opens a new Dos Box and a new Netscape 7
http://www.vim.org/tips/tip.php?tip_id=587 (2 of 3) [18/02/2004 15:06:16]
Tip #587 - Preview current file in Mozilla through localhost : vim online
: just press F9
: press alt and F9
: press ctrl and F9
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Examples:
Original, visual-block select the central column
one
two
three
four five
six
seven eight nine
ten
eleven twelve
:'<,'>Vissort
seven eight nine
ten
eleven twelve
four five
six
one
two
three
:'<,'>B !sort
one
eight three
four eleven six
seven five
nine
ten
two
twelve
:'<,'>B Bisort
one
eight three
four eleven six
seven five
nine
ten
two
twelve
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Preview current file in Mozilla through localhost | Vim as refactoring tool (with examples in C#) >>
Additional Notes
NdrOchip@ScampbellPfamily.AbizM - NOSPAM, January 22, 2004 7:33
vissort has been updated to version 3: it now has
BlockSort() which permits one
to sort blocks of text based on tags contained within
them.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #589 - Vim as refactoring tool (with examples in C#) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Tip #589 - Vim as refactoring tool (with examples in C#) : vim online
return strOutput;
}
XmlNodeList nodeList =
XMLDoc.DocumentElement.ChildNodes;
...
Imagine 50 lines of code here.
Use the "extract method refactoring" to make a "composed
method".
I use a vim function (see below) to build the exracted
method.
I highlight the code part I want to extract and press
\em (for e-xtract m-ethod).
A dialog appears and asks me how to name the new method.
I type in "GetXmlDocumentFrom" and do get this:
// = GetXmlDocumentFrom();
private GetXmlDocumentFrom()
{
XmlDocument XMLDoc = new XmlDocument();
try {
XMLDoc.Load(file);
}
catch (Exception e)
{
strOutput = e.GetBaseException().ToString();
return strOutput;
}
// return ;
}
Now I have time to think what parameters the method
needs and what to return.
I end up with the following function and
the original function:
remove it from
Tip #589 - Vim as refactoring tool (with examples in C#) : vim online
}
catch (Exception e)
{
strOutput = e.GetBaseException().ToString();
ErrorMessage(strOutput);
}
return XMLDoc;
}
In the original code I put two lines.
XmlDocument XMLDoc = new XmlDocument();
XMLDoc = GetXmlDocumentFrom(XmlFile);
So I reduced the original code for 8 lines and made it
clearer what the code does.
I do this with the rest of the code again and again.
Since the class gets bloated because of the many new
methods I later will use
the "Extract Class" refactoring to put this method in an
own XmlDocument-class.
This has the advantage that our new function is also
available for other
similar purposes.
I will create the new class also with the help of vim,
the actual extracting of
the method into the new class is just a matter of copy &
paste.
Here is the vim-code:
vmap \em :call ExtractMethod()<cr>
function! ExtractMethod() range
let name = inputdialog("Name of new method:")
'<
exe "normal O\<bs>private " . name ."()\<cr>{\<esc>"
'>
exe "normal oreturn ;\<cr>}\<esc>k"
s/return/\/\/ return/ge
normal j%
normal kf(
exe "normal yyPi// = \<esc>wdwA;\<esc>"
normal ==
normal j0w
endfunction
Tip #589 - Vim as refactoring tool (with examples in C#) : vim online
Example 2:
The "Self Encapsulate Field" refactoring.
I have heard a programmer who just uses Visual Studio
(nothing against Visual
Studio, it's a great tool!) say: "I do not use
properties. It's too much
work." He just uses fields instead.
With vim it is no problem to write a property, id est to
use the "Self
Encapsulate Field" refactoring.
I write a name e.g. "Name" press CTRL-C CTRL-P CTRL-S (create p-roperty with
s-tring). Voila, the new property appears in just a
second:
private string m_Name;
public string Name
{
get
{
return m_Name;
}
set
{
m_Name = value;
}
}
Here are the vim mappings and the underlying function:
"Create property
imap <C-c><C-p><C-s> <esc>:call
CreateProperty("string")<cr>a
imap <C-c><C-p><C-i> <esc>:call
CreateProperty("int")<cr>a
function! CreateProperty(type)
exe "normal bim_\<esc>b\"yywiprivate ".a:type."
\<esc>A;\<cr>public ".a:type."
\<esc>\"ypb2xea\<cr>{\<esc>oget\<cr>{\<cr>return
\<esc>\"ypa;\<cr>}\<cr>set\<cr>{\<cr>\<tab>\<esc>\"yPa =
value;\<cr>}\<cr>}\<cr>\<esc>"
normal 12k2wi
endfunction
You can combine Visual Studio and vim. You can work in
Visual Studio and load
http://www.vim.org/tips/tip.php?tip_id=589 (4 of 7) [18/02/2004 15:06:22]
Tip #589 - Vim as refactoring tool (with examples in C#) : vim online
Example 3:
The "Replace Conditional with Polymorphism" refactoring.
Imagine a switch and you want to replace it with an
abstract class and some
concrete classes which inherit from this parent class.
You may think "Why should I replace this switch? It's
too much work. Writing
all these classes ..."
With vim it's just a question of a few seconds.
To build the abstract class I type, say "Fruit".
Then I press CTRL-C CTRL-A CTRL-C (c-reate a-bstract class) and get
public abstract class Fruit
{
public abstract void |();
}
| means the Cursor position.
Now I fill in the methods.
public
{
public
public
public
}
Tip #589 - Vim as refactoring tool (with examples in C#) : vim online
Tip #589 - Vim as refactoring tool (with examples in C#) : vim online
Life Changing
Helpful
Unfulfilling
rate
<<How to sort using visual blocks | Using vim to send mail on windows >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Vim as refactoring tool (with examples in C#) | Have a nice and easy use of plugins >>
Additional Notes
hermitte {at} free {dot} fr, October 22, 2003 15:38
Are you sure about the "-f" flag ? So far, I've never
seen this flag do anything under windows. That's why I
use mutt compiled for cygwin with the win32 version of
Vim.
Anonymous, October 22, 2003 22:27
You wrote "Finally there *is* an elegant solution", but
there is *many* solutions: at random Mahogany
http://mahogany.sf.net (excellent one) or pine (great,
ever great) or ...use google ;-)
Kartik Agaram, October 23, 2003 10:12
Let me get this right - you want me to switch to a
whole new email client just so that I can change its
default editor to something else. Not just vim *anything*. How is this a vim tip, exactly??
hermitte {at} free {dot} fr, October 24, 2003 1:49
You are unfair. I think this is an interresting thing
to know when we are to decide which MUA to install and
use.
When considering which tool to use (IDE, MUA, newsreader, etc.), I often check if I will be able to use
an external editor (which is Vim of course).
Anonymous, November 26, 2003 10:09
PC-Pine offers an external-editor-feature too.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #591 - Have a nice and easy use of plugins : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Tip #591 - Have a nice and easy use of plugins : vim online
Tip #591 - Have a nice and easy use of plugins : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Using vim to send mail on windows | Smart <Home> and <End> keymaps >>
Additional Notes
hermitte {at}free {dot} fr, October 24, 2003 15:18
I definitively agree that plugins are a must -- AFAIK,
ftplugins are the major improvment of Vim over Vi.
However, I have a few remarks:
- You forget the anti-reinclusion guards,
- You can propose a way to override the default
mappings you propose in your plugin -- check vimtip#147
that is a must-read
- You'd better always use ":normal!" and "*noremap"
instead of ":normal" and ":*map". We are never sure of
mappings defined into other plugins.
hermitte {at} free {dot} fr, October 24, 2003 15:24
Tip #591 - Have a nice and easy use of plugins : vim online
I almost forget.
If you want the exact path of the current plugin:
let s:file = expand('<sfile>:p')
nnoremap <silent> <s-12> :silent exe 'source '.s:file
But a better solution is to rely on ":runtime".
BTW, $VIMRUNTIME is not really meant to be polluted
with our own scripts.
jcclavier@free.fr, October 28, 2003 6:16
These are useful remarks that show that this Tip is not
complete.
It is only a first step to make minimal plugins that
will be ok for self use.
It's aim is rather to show the interest of plugins and
user-commands than to give the best method to develop
plugins to be distributed (vimtip#147 is much better
for that).
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
I found interesting the way <Home> and <End> keys act in some editors
and I wondered why try not
carry it out with Vim.
Put the following lines in your ~/.vimrc and so <Home> will move the
cursor between the first column and
the first non-blank character. <End> is similar but work at the end of
the line.
I think this should be very useful to the indented code and trailing
characters.
let g:home_key = '0'
let g:end_key = '$'
function ToggleHome()
exe "normal! \<Esc>".g:home_key
let g:home_key = g:home_key == '0'? '^' : '0'
endfunction
function ToggleEnd()
exe "normal! \<Esc>".g:end_key
let g:end_key = g:end_key == '$'? 'g_' : '$'
endfunction
inoremap
nnoremap
inoremap
nnoremap
<silent>
<silent>
<silent>
<silent>
Life Changing
Helpful
Unfulfilling
rate
<<Have a nice and easy use of plugins | basic postfix abbreviations >>
Additional Notes
hermitte {at} free {dot} fr, October 26, 2003 12:26
This mapping is not very handy as it is does take the position of the
cursor into account.
The function you are looking for is available here into a plugin that
define some key bindings inspired by VC++, and as a standalone into:
http://hermitte.free.fr/vim/ressources/vimfiles/plugin/homeLikeVC++.vim
It will be easy to fix the mapping for <end> as well.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Smart <Home> and <End> keymaps | Lookup javadoc HTML help from vim >>
Additional Notes
nrdean@purdue.edu, October 26, 2003 5:36
word of warning, I gave a dangerous example.
abbreviations expand on any word break, so don't use
just for as your abbreviation name. Use something that
doesn't come up in syntax, like Xfor or qqfor.
Sreny@SverGbc.Pbz (Rot13ed), October 27, 2003 17:19
I thought this such an interesting idea and that I like
the post decision to expand I hacked togther vimscript
#804.
It is a quicky but might be useful.
Neat tip, thank you :)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #594 - Lookup javadoc HTML help from vim : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Do you use VIM for lot of Java Coding, but miss the feature
of looking up
javadoc help like some other Java based IDEs ?
Well I have written I plugin to do just that, right now its
in an infant state, but
can lookup javadoc html of a java Class, from VIM
get it at
http://vim.sourceforge.net/scripts/script.php?script_id=801
Please leave any comments , notes, feature request on this
tip or
email me at vim_power@yahoo.com
thanks
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<basic postfix abbreviations | suppressing file changed warnings in a specific buffer >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #595 - suppressing file changed warnings in a specific buffer : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Lookup javadoc HTML help from vim | Insert location of the currently edited file >>
Additional Notes
Sreny@SverGbc.Pbz (Rot13ed), October 30, 2003 1:51
Tip #595 - suppressing file changed warnings in a specific buffer : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #596 - Insert location of the currently edited file : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
With
:imap <C-r>@ <C-r>=expand("%:p:h")<cr>
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<suppressing file changed warnings in a specific buffer | indet a code block - >i{ >>
Site Help
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Insert location of the currently edited file | (PHP) on line help >>
Additional Notes
hermitte {at} free {dot} fr, October 30, 2003 11:26
With the indent options correctly defined, =% works
just fine ...
none@nowhere, October 31, 2003 11:25
Holy crap, these are very good tips. Both the original
and the = tip. visual = just made my day! Thanks.
don@seiler.us, January 14, 2004 7:45
You are truly the king of kings.
http://www.vim.org/tips/tip.php?tip_id=597 (1 of 2) [18/02/2004 15:06:50]
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
Hi,
vim is my favorite; so, I use it for .php file.
Very often I need the php manual to see the parametrs
order for functions.
Unitl a month ago I always opened a browser and gone to
http://http://ro.php.net/FUNCTION_NAME
for example http://ro.php.net/printf .
Site Help
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
catalin at run.ro, November 6, 2003 3:38
And How can I get back in my file after I visit the doc
file?
marcel_preda@yahoo.com, November 6, 2003 7:10
after you get out from the browser [use q]
all you have to do is:
`Hit ENTER or type command to continue'
[vim says that]
info at multivitaminicdream.com, November 19, 2003 23:07
If you work in X and you use more mozilla than lynx i
think you could like this script instead of other:
#!/bin/bash
#php_doc
mozilla=/when/you/have/mozilla
if ( $mozilla -remote "ping()" &> /dev/null );then
$mozilla -remote
"openurl(http://www.php.net/$1, new-tab)" &
else
$mozilla http://www.php.net/$1 &
fi
This script start mozilla if not running, and send it
the new url.
If you want to know the others command to use with remote flag see here:
http://www.mozilla.org/unix/remote.html
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<(PHP) on line help | Copy current file name into windows clipboard >>
Additional Notes
hermitte {at} free {dot} fr, November 1, 2003 8:08
Please, when you find a bug in a plugin, contact its
author.
Tips are meant to be tips not a forum. :(
Anonymous, November 27, 2003 0:58
and if the author won't change and update, we will die
dumb ...
;-)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #600 - Copy current file name into windows clipboard : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
maxiangjiang@hotmail.com, October 30, 2003 15:36
An alternative for the first of your map:
nmap ,cs :%y*<CR>
(It works even when we have no filename.)
Marcel van der Laan, October 31, 2003 0:16
This is not quite the case... You are yanking the
contents of the file, not the file name.
maxiangjiang@hotmail.com, October 31, 2003 9:40
Tip #600 - Copy current file name into windows clipboard : vim online
Ops, you are right. Mine was for content, not for
filename.
I am offering a third one, to make it up :)
nmap ,c8 :let @*=expand("%:p:8")<CR>
(For Windows users, to get DOS filename)
hermitte {at} free {dot} fr, November 1, 2003 8:04
Another way for the first map (only):
nnoremap <leader>cs :let @+=@%<cr>
JonathanOrlev@yahoo.com, November 9, 2003 7:19
Great tip !
Thank you very much.
Jonathan Orlev
fishburn@ianywhere.com, November 11, 2003 14:02
I use the following in my vimrc:
" Copy the filename of the current buffer into the
clipboard
if has('win32')
nnoremap <Leader>ff :let
@*=substitute(expand("%:p"), "/", "\\", "g")<cr>
else
nnoremap <Leader>ff :let @*=expand("%:p")
endif
This takes care of flipping the slashes for windows
platforms.
This came from:
Tip #296: Attach the currently open file to email
http://vim.sourceforge.net/tip_view.php?tip_id=296
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Copy current file name into windows clipboard | How to remove one mark or all marks at once >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #602 - How to remove one mark or all marks at once : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Tip #602 - How to remove one mark or all marks at once : vim online
call RemoveMark("c")
call RemoveMark("d")
call RemoveMark("e")
call RemoveMark("f")
call RemoveMark("g")
call RemoveMark("h")
call RemoveMark("i")
call RemoveMark("j")
call RemoveMark("k")
call RemoveMark("l")
call RemoveMark("m")
call RemoveMark("n")
call RemoveMark("o")
call RemoveMark("p")
call RemoveMark("q")
call RemoveMark("r")
call RemoveMark("s")
call RemoveMark("t")
call RemoveMark("u")
call RemoveMark("v")
call RemoveMark("w")
call RemoveMark("x")
call RemoveMark("y")
call RemoveMark("z")
catch
endtry
endfunction
Could you think of other possibilities?
Please share it with us.
Note:
I am using the try-catch clause so the following works
only for >= vim 6.2.
If you want to use the functions for an older version
remove the try-catch
clauses.
Happy vimming
Klaus
Life Changing
Helpful
Unfulfilling
rate
Tip #602 - How to remove one mark or all marks at once : vim online
Additional Notes
Klaus Horsten, November 1, 2003 1:12
Alas!
I put the title in the wrong field (in the author
field).
Pair programming would be good.
Klaus
Anonymous, November 2, 2003 12:18
http://www.mono211.com/content/releases/mtkmp120.html
cec@NgrOyphSon.gPsfAc.nMasa.gov, November 3, 2003 6:42
\mh is a mapping to s:ShowMarksClearMark(), which is
provided by the
<showmarks.vim> plugin (see vimscript#152). So don't
expect the \mh
command to work without that plugin. Furthermore, the
plugin doesn't
actually remove the mark; instead, it moves it to line
1.
juhas@seas.upenn.edu, November 8, 2003 20:09
To remove all marks you can also use
or :%!type on windows.
:%!cat
on unix
Tip #602 - How to remove one mark or all marks at once : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
<<How to remove one mark or all marks at once | Doing <enter> in nmode >>
rate
Additional Notes
mosh.cs.albany.edu, November 14, 2003 17:55
Please add a single backslash to the second arg of escape, in
all three calls. It gets deleted while posting.
eg. escape("\\n",'') should be escape("\\n",'backslash-here')
vimuser@mailinator.com, November 15, 2003 8:59
double backslash =\\
single back slash=\ <= is this visible?
manu.anand@igate.com, November 17, 2003 1:51
Script breaks if the file has any spaces or . in the filename.
Also the header part ie part before :amenu confuses Vim Script
Interpretor.
Env: WinNT, Vim6.2
fred.bartholomai@acsatlanta.com, November 17, 2003 11:32
I get the following error when I attempt to bookmark a file:
( I added the backslash as you mentioned ).
!(echo \\042 Bookmark: DATE=2003-Nov-17_14:32:05
PWD=/home/freddyb\\n:amenu Mo
2.BookMarks.NetworkMsgs\\.C :sp +1
/users/acs/V8.0/src/Network/NetworkMsgs.C >>
$HOME/bookmark.vim)
sh: line 1: (echo \042 Bookmark: DATE=2003-Nov-17_14:32:05
PWD=/home/freddyb\n:
amenu Mo2.BookMarks.NetworkMsgs\.C :sp +1
/users/acs/V8.0/src/Network/NetworkMsg
s.C >> /users/freddyb/bookmark.vim): No such file or directory
Any help would be appreciated.
mosh.cs.albany.edu, November 17, 2003 18:56
This works on linux (redhat71) with vim61 and bash (I shortened
it for linux):
:amenu Mo2.BookMarks.Add
\ :let @b=":amenu Mo2.BookMarks.".
\ escape(escape(expand("%:t"),'.'),'').
\ ' :sp +'.line(".").' '.
\ escape(expand("%:p"),' ')<CR>
\ :exe ':!(echo '.@b.' >>
$HOME/hist/bookmark.vim)'<CR>
\ :so $HOME/bookmark.vim<CR>
As usual the web posting may delete a backslash from the
second argument to escape(), you can add it back so it looks as
follows:
....
escape(escape(expand("%:t"),'<dot><backslash>'),'<backslash>').
...
escape(expand("%:p"),' <backslash>')<CR>
You can test it even in the console mode vim command line:
:emenu Mo2.Bookmarks.Add
:sp ~/bookmark.vim
- Mohsin.
mosh.cs.albany.edu, November 17, 2003 18:58
This should be correct for linux:
:amenu Mo2.BookMarks.Add
\ :let @b=":amenu Mo2.BookMarks.".
\ escape(escape(expand("%:t"),'.\'),'\').
\ ' :sp +'.line(".").' '.
\ escape(expand("%:p"),' \')<CR>
\ :exe ':!(echo '.@b.' >>
$HOME/bookmark.vim)'<CR>
\ :so $HOME/bookmark.vim<CR>
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Bookmarks as menu item | replace a word with the yanked text >>
Additional Notes
jeromeguigue@yahoo.fr, November 19, 2003 4:28
why "_" before "i" ?
ykhov@student.cs.uwaterloo.ca, November 19, 2003 15:14
I've been using something similar for years.
" Enter a blank line below/above cursor in Normal mode
without
" having to go to Insert. (Using o command will
continue comments in programming as well.)
"comma o"
nmap
nmap
,o
,O
o<ESC>k
O<ESC>j
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #605 - replace a word with the yanked text : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Doing <enter> in nmode | Seeing the man pages while being in VIM >>
Additional Notes
jigho@caramail.com, November 18, 2003 23:16
I was looking for something like that for years !
Nonetheless, it does not seem to be able to replace the
word with a previously deleted text, which is also very
useful. Someone can help me ?
Anonymous, November 19, 2003 1:31
Use numbered register 2 to insert previously deleted
text.
map S diw"2P
see
:help registers
jigho@caramail.com, November 19, 2003 23:23
Thanks a lot.
In fact, diwP is what I want, since it pastes from the
unnamed register (filled with text from the last d, c,
s, x or y comand)
http://www.vim.org/tips/tip.php?tip_id=605 (1 of 3) [18/02/2004 15:07:16]
Tip #605 - replace a word with the yanked text : vim online
word2
word2
Tip #605 - replace a word with the yanked text : vim online
In .vimrc
map S viw"0P
viw on word
and go to another word
S
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #606 - Seeing the man pages while being in VIM : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
You can see the man pages of anything you want from VIM.
No need to exit VIM. Just put the cursor under the
word.and press shift+k (Capital K) and you will be in
the man page section. when you are through just press
'q' and you will be out of VIM. Press enter to come back
to VIM.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<replace a word with the yanked text | Opening gvim atop a console window >>
Additional Notes
ivon@jinr.ru, November 19, 2003 0:56
Thank you! Now I can remove my function from .vimrc
which do the same thing :)
drNchipO@ScampbellPfamilyA.Mbiz - NOSPAM, November 19, 2003 7:02
After moving my <.vimrc> to <DOTVIMRC> and my <.vim/>
to <DOTVIM/>, so as to avoid
any of my customizations, and writing a new <.vimrc>
with just
set nocp
filetype plugin indent on
the tip did not work using <ctrl-k> on "printf(...)" in
a C file. Obviously it needs something!
May I suggest looking at vimtip#167 "Using vim as a manpage viewer under Unix" and
vimscript#489 "Manpageview.vim".
drNchipO@ScampbellPfamilyA.Mbiz, November 19, 2003 7:05
http://www.vim.org/tips/tip.php?tip_id=606 (1 of 2) [18/02/2004 15:07:21]
Tip #606 - Seeing the man pages while being in VIM : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
I like to have gvim open atop the current xterm I'm using,
rather
like a vim console would. Here's some Korn shell script
for
setting up a function "gv" which queries X for the current
window's
geometry and adjusts the window for the current fontsize,
borders,
and menu region.
Admittedly the adjustments for that vary with border sizes,
etc,
so you'll likely need to adjust x,y,w,h in the Adjustments
section.
Usage:
# =======================================
# gv: gvim covers starting console window
function gv
{
if [[ "${WINDOWID}" = "" ]]; then
echo "***error*** unknown window id!"
return
fi
xwi=$(xwininfo -id $WINDOWID)
xyposn=${xwi##*Corners: }
xyposn=${xyposn%% -*}
wh=${xwi##*geometry }
wh=${wh%+0+0}
integer x y w h
x=${xyposn%+[0-9]*}
y=${xyposn#+[0-9]*}
w=${wh%x*}
hh=${wh#*x}
h=${hh%[-+]*}
# ---------------------------# Adjustments:
#
x,y in pixels
#
w,h in characters
# ---------------------------# for RH8 Linux, GTK, courier-12-r
h=h-4
x=4
y=y-18
# ---------------------------# invoke gvim
gvim -geometry "${w}x${h}+${x}+${y}" $*
}
# =======================================
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Seeing the man pages while being in VIM | Evaluate current line (or pease of line) using Python >>
Additional Notes
Anonymous, November 19, 2003 15:43
don't know if this is useful directly (i don't
particularly mind where the window manager places the
window), but the fact that you can get a shell window's
info like this is very interesting.
drNchipO@ScampbellPfamilyA.Mbiz , November 21, 2003 7:29
Found a few bugs; probably should've made this a script
since one can't "adjust" tips.
Enjoy!
#
==========================================================
# gv: gvim covers starting console window
function gv
{
if [[ "${WINDOWID}" = "" ]]; then
return
fi
xwi=$(xwininfo -id $WINDOWID)
xyposn=${xwi##*Corners: }
xyposn=${xyposn%% -*}
wh=${xwi##*geometry }
wh=${wh%%[-+]*}
integer x y w h
x=${xyposn%+[0-9]*}
y=${xyposn##*+}
w=${wh%x*}
http://www.vim.org/tips/tip.php?tip_id=607 (2 of 3) [18/02/2004 15:07:24]
hh=${wh#*x}
h=${hh%%[-+]*}
# --------------------------------------------------------# Adjustments: account for window borders, menus,
fontsizes
# --------------------------------------------------------# Adjust for RH8 Linux: courier-12-r
h=h-4
x=x-4
y=y-18
# --------------------------------------------------------# execute gvim with geometry
gvim -geometry "${w}x${h}+${x}+${y}" $*
}
#
==========================================================
dolphinq@com.ne.kr, November 28, 2003 4:41
hi
i am korean.
Send this manual tim vim
this E-mail.(dolphinq@com.ne.kr)
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #608 - Evaluate current line (or pease of line) using Python : vim online
Home
Search
Tip #608: Evaluate current line (or pease of line) using Python
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Tip #608 - Evaluate current line (or pease of line) using Python : vim online
:PyEv r
evaluate expression and replased it by resalt of
evaluation. And other arg in argument searching the arg
backword from the end of current line and evaluate
followed expression. For example: let we have string
\setlength{\textwidth}{450-63
:PyEv r {
\setlength{\textwidth}{387
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Opening gvim atop a console window | Execute python from within current file >>
Additional Notes
emin@mccme.ru, November 24, 2003 5:28
Sorry, internet formatter killing all ident in the
python sript
I'm try again:
def EvaluateCurrentLine(*args):
cur_str = vim.current.line
action, symb = None, None
for i in args:
if i in ["r","p"]: action = i
else:
symb
= i
try:
start = cur_str.rindex(symb)+len(symb)
except: start = 0
result = eval(cur_str[start:],globals())
if action == "r":
vim.current.line = cur_str[:start]+str(result)
else:
print result
Anonymous, November 25, 2003 15:57
"pease"?
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #609 - Execute python from within current file : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Tip #609 - Execute python from within current file : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Evaluate current line (or pease of line) using Python | Saves you frequent typings of certain words. >>
Additional Notes
fs111@linuxmail.org, December 1, 2003 5:23
The Tipp is cool, but it does not wor the way you posted it. On my
fedora core 1 I had to change it into:
python << EOL
import vim, StringIO,sys
def PyExecReplace(line1,line2):
r = vim.current.buffer.range(int(line1),int(line2))
redirected = StringIO.StringIO()
sys.stdout = redirected
exec('\n'.join(r[:]) + '\n')
sys.stdout = sys.__stdout__
output = redirected.getvalue().split('\n')
r[:] = output[:-1] # the -1 is to remove the final blank line
redirected.close()
EOL
command -range Pyer python PyExecReplace(<f-line1>,<f-line2>)
Andr
Steve Halpin, December 10, 2003 10:06
My apologies - cut & paste error, thanks for the correction.
Now what was that vim command that takes what you actually copied to
the clipboard and replaces it with what you meant to copy .... :)
MIBSchmidt@gmx.de, December 12, 2003 5:00
Tip #609 - Execute python from within current file : vim online
Hello
can somebody tell how to change the scrip so that it:
1. writes the python output to a new window and not replaceing the
source
2. evaluates the hole buffer and not a selection
thank you
Michael
Anonymous, February 10, 2004 19:17
>can somebody tell how to change the scrip so that it:
>1. writes the python output to a new window and not replaceing the
source
You can just enter 'u' in command mode to 'undo' the output and get
your source back. However, as you suggest sending the output to (for
instance, the Preview window) would probably be better.
> 2. evaluates the hole buffer and not a selection
':%Pyer' does this. '%' represents the whole buffer in vim.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #610 - Saves you frequent typings of certain words. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
<<Execute python from within current file | Open big files and work fast >>
Additional Notes
Anonymous, November 30, 2003 9:59
rate
Tip #610 - Saves you frequent typings of certain words. : vim online
Tip #610 - Saves you frequent typings of certain words. : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #611 - Open big files and work fast : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Saves you frequent typings of certain words. | save a nanosecond with marks >>
Tip #611 - Open big files and work fast : vim online
Additional Notes
Anonymous, December 4, 2003 23:18
You should place a " around <afile> or vim will be
complaining too load and too much.
user=natter aei=domain dot NOcaJUNK, December 5, 2003 9:16
Thanks. I have it as expand("%") in my vimrc, but
expand("<afile>") is more accurate.
Anonymous, December 5, 2003 12:54
Checking the file size each time one enters the buffer
can be very expensive (time delays) when file is stored
on shares etc. I use as an extention to tip #343; the
following line that makes also auto command on the fly,
only for the file that is considered to be large, and
remove the auto commands when the file is closed (The
variable g:LargeFileUL is the save-value of undo
levels):
au BufReadPre * let f=expand("<afile>") | if
getfsize(f) > g:LargeFile | set ei=FileType | setlocal
noswf bh=unload bt=nowrite ro | let
f=escape(substitute(f,'\','/','g'),' ') |exe "au
LargeFile BufEnter ". f ." set ul=-1" | exe "au
LargeFile BufLeave ". f ." set ul=". LargeFileUL | exe
"au LargeFile BufUnload ". f ." au! LargeFile * ". f |
exe "" | else | set ei= | endif
Its all one line ;-) I'm not sure if this also works
for version 5.x.
Erik
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Open big files and work fast | open last edited file, AKA lvim for bash >>
Additional Notes
Anonymous, December 4, 2003 18:33
Actually, 'ma' will save you time compared with 'ml' if
you are typing with both of your hands.
Just my 2 cents
Anonymous, December 5, 2003 3:45
I use "mm", which is even faster for marking
Anonymous, December 5, 2003 6:51
I think the point is that you use the same finger for
'`' as for 'a', so '`a', '`z', and '`q' are slower to
type than for other marks.
Anonymous, December 5, 2003 8:32
Try ":mark a".
Anonymous, December 5, 2003 11:36
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #613 - open last edited file, AKA lvim for bash : vim online
Home
Search
Tip #613: open last edited file, AKA lvim for bash
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<save a nanosecond with marks | perldoc function and module keyboard mappings >>
Additional Notes
adamm@wazamatta.com, December 10, 2003 11:56
There needs to be a backslash in front of the second
single quote before the zero. This interface doesn't
let me write a backslash, so you have to replace the
word BACKSLASH with a literal backslash.
alias lvim='vim -c "normal 'BACKSLASH''0"'
Michael-O-Mendelsohn@vsnl.com, December 12, 2003 19:26
Put this in _vimrc, and invoking vim without arguments
will got last open file (it will get the last file and
position from .viminfo). Oh yes, replace BS by
Backslash.
- Michael O Mendelsohn
" Go to last buf if invoked without args.
:au VimEnter * nested if
BS
argc()
== 0
BS && bufname("%")
== ""
BS && bufname("2" + 0) != ""
BS | exe("normal `0")
http://www.vim.org/tips/tip.php?tip_id=613 (1 of 2) [18/02/2004 15:07:48]
Tip #613 - open last edited file, AKA lvim for bash : vim online
BS | endif
" From http://www.zellner.org/vim/vimrc and Campbell's
correction QUOTE to BACKQUOTE.
" Go to last cursor location, ie. goto
mark(double_quote)
:au BufReadPost * if
BS line("'BS"")
BS && line("'BS"") <= line("$")
BS | exe "normal `BS""
BS | endif
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #614 - perldoc function and module keyboard mappings : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
" put the cursor over a perl function and try backslashpf to see perldoc
:nmap <Leader>pf :!perldoc -f <cword><CR>
" put the cursor over a perl module name and try
backslash-pd to see perldoc
:nmap <Leader>pd :e `perldoc -ml <cword>`<CR>
" see ':help mapleader' for more info... default is
backslash.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<open last edited file, AKA lvim for bash | Moving to the next word in insert mode >>
Additional Notes
webmaster@topfx.com, December 16, 2003 13:43
Here's something similar I use, with these improvements
on original poste:
1. Only sets up the mapping when editing perl files
2. Sets up 1 smart mapping that automatically works for
perl functions as well as modules
3. Uses vim's build-in keyword definition feature
instead of defining a new mapping
In your .vimrc add these 2 lines:
autocmd BufEnter
*.pl,*.pm,*.cgi let oldkp=&kp |
set keywordprg=perl \ -e\
$c=shift;exec\"perldoc\".($c=~/^[a-z]+$/?\"\ -f\ \":\"\
\").$c'
autocmd BufLeave
http://www.vim.org/tips/tip.php?tip_id=614 (1 of 2) [18/02/2004 15:07:51]
*.pl,*.pm,*.cgi let
Tip #614 - perldoc function and module keyboard mappings : vim online
&keywordprg=oldkp
Then when editing a perl file you can use perl's builtin keyword definition mapping (capital K == shift+k)
when under a perl function or module to see it's POD.
See
:help K
For more information.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #615 - Moving to the next word in insert mode : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<perldoc function and module keyboard mappings | Have Vim check automatically if the file has
changed externally >>
Additional Notes
Anonymous, December 10, 2003 21:10
This is true when not using :behave mswin.
and <C-Right> will work in either case.
<C-Left>
Tip #615 - Moving to the next word in insert mode : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #616 - Have Vim check automatically if the file has changed externally : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #616: Have Vim check automatically if the file has changed
externally
tip karma
complexity: basic
as of Vim: 6.0
You can place this in your vimrc file, and then run:
:CheckForUpdates
This will toggle the behaviour for the given buffer.
" If you are using a console version of Vim, or dealing
" with a file that changes externally (ie a web server
log)
" then Vim does not always check to see if the file has
been changed.
" The GUI version of Vim will check more often (for
example on Focus change),
" and prompt you if you want to reload the file.
"
" There can be cases where you can be working away, and
Vim does not
" realize the file has changed.
"
" This function will force Vim to check more often.
"
" The function will turn on the :checktime command so
that the
" file is checked based on the CursorHold event.
"
" Thanks to Jrgen Krmer, Antoine J. Mechelynck for the
help.
"
" CheckForUpdates will toggle the behaviour on the
current buffer.
function! CheckForUpdates()
" Save the current default register
let saveB=@"
" Check to see if the checkforupdates autocommand
exists
redir @"
Tip #616 - Have Vim check automatically if the file has changed externally : vim online
Life Changing
Helpful
Unfulfilling
<<Moving to the next word in insert mode | Fun with case twiddling >>
Additional Notes
jkr@jottkaerr.de, December 10, 2003 23:13
rate
Tip #616 - Have Vim check automatically if the file has changed externally : vim online
In the line
\ substitute(expand("%:p"), '', '/', 'g')
there should be a backslash inside the first pair of
single quote. Let's
see, if it gets accepted this time
\ substitute(expand("%:p"), '', '/', 'g')
David Fishburn, December 12, 2003 16:34
Yes, you are right, I didn't notice that it was removed
during the posting.
I see the same thing happened to you.
So this line:
\ substitute(expand("%:p"), '', '/', 'g')
Should be:
\ substitute(expand("%:p"), '\', '/', 'g')
The first pair of single quotes after "%:p", should
have a backslash between them.
I will try this again, escaping it twice for the post:
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Have Vim check automatically if the file has changed externally | how to make and submit a patch
>>
Additional Notes
Anonymous, December 10, 2003 23:02
Sorry about the indentation, I won't try to cut-andpaste tabs next time :)
Anonymous, December 10, 2003 23:20
Remind me never to type in a tip at 2AM again.
What I meant to be talking about was "Title
Case". "Sentence Case" is the style I skipped.
Anonymous, December 11, 2003 6:18
s/\<\(.\)/\U\1/g
is easier
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Merging patches is no picnic, December 12, 2003 19:19
I had real trouble applying big 'cvs diff' patches,
and found the following gnu doc tools and doc useful:
http://www.gnu.org/software/diffutils/diffutils.html
"Comparing and Merging Files with GNU diff and patch"
by David MacKenzie, Paul Eggert, and Richard
Stallman
I use gnu-emacs for merges and patches, because no
other tool
comes close to emacs' power in interactive merging of
files
No, none of winmerge,araxis,windiff,vim -d, provide
half the
functionality of gnu-emacs-ediff-emerge.
- Michael O Mendelsohn
benji@member.AMS.org, January 2, 2004 5:26
If you are not subscribed to the vim-dev list, or
if you are submitting a small documentation patch and
do not feel it is worth the bandwidth to send it to the
list, you can send your patch directly to the
maintainer at bugs@vim.org .
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
Site Help
:help
:help
:help
:help
*1*
'keymap'
'iminsert'
language-mapping
<Char>
{lhs}
{rhs}
[comment]
<buffer>
{lhs}
{rhs}
Life Changing
Helpful
Unfulfilling
<<how to make and submit a patch | getting to know the function prototypes >>
Additional Notes
rate
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<HowTo make a keymap | Vim as a syntax highlighting engine for web publishing >>
Additional Notes
lpenz@terra.com.br, December 15, 2003 18:07
ctrl+i = TAB
So, "[ <TAB>" goes to the function prototype also, and
IMHO is easier to remember.
Anonymous, December 30, 2003 20:08
but what can I do if the prototype is longer than 1
line? Can help?
Anonymous, January 2, 2004 3:26
Its not working. I think you require a ctags file for
doing this operation. Otherwise how VIM will
know about the prototypes and definations. ANd "I"
(capital I) is required to insert at the begining
of a line NOT for listing of proto.
Manas Behera
sunil parolia, January 5, 2004 23:55
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #621 - Vim as a syntax highlighting engine for web publishing : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: advanced
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<getting to know the function prototypes | Deleting a buffer without changing your window layout >>
Additional Notes
mmr@b1n.org, February 5, 2004 11:09
within any file type (that has its own syntax
highlight) use
:runtime syntax/2html.vim
ta-da!
you got an html version.
Add Note
Tip #621 - Vim as a syntax highlighting engine for web publishing : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #622 - Deleting a buffer without changing your window layout : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
:Kwbd
Life Changing
Helpful
Unfulfilling
rate
<<Vim as a syntax highlighting engine for web publishing | External Paste Buffer >>
Additional Notes
Anonymous, December 17, 2003 9:45
At last!!
Anonymous, December 17, 2003 10:22
I had this need. Thank you for finding and sharing the
solution.
hari_vim at yahoo dot com, December 17, 2003 19:07
You can simplify this as:
com! Kwbd enew|bw #
Hari
Anonymous, December 17, 2003 19:14
YAY!
xburgerhout AT freeler DOT nl, December 17, 2003 22:59
Tip #622 - Deleting a buffer without changing your window layout : vim online
Great tip!
Additionally, I remapped bd to Kwbd:
map bd :Kwbd<CR>
Also, I added bn to Kwbd to automatically get the next
buffer:
com! Kwbd enew|bw #|bn
L.Josifovski@dcs.shef.ac.uk, January 9, 2004 6:31
When a buffer is open in sevral windows, those other
windows still get closed?!
I'm using the following at present - ugly (so many
lines for a simple task) but works for me:
" Delete the current buffer, issuing bnext in all
windows
" where displayed before that
function DeleteBuffer2()
let bid = bufnr("%")
let wid = winnr()
windo if bid == bufnr("%") | bprev | endif
exe "bdel " . bid
exe "normal " . wid . "^W^W"
endfunction
" count the number of buffers
function BufferCount()
" save cur buf number
let cbuf = bufnr("%")
let bnum = 0
bufdo let bnum = bnum + 1
" return to the buf
exe "b " . cbuf
return bnum
endfunction
"
"
function DeleteBuffer()
if BufferCount() > 1
call DeleteBuffer2()
else
exe "bdel"
endif
endfunction
"
map <C-K> :call DeleteBuffer()<CR>
imap <C-K> <C-O><C-K>
Tip #622 - Deleting a buffer without changing your window layout : vim online
:he ctrl-
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Deleting a buffer without changing your window layout | Insert template files into buffer ( HTML
editing for example) >>
Additional Notes
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #624 - Insert template files into buffer ( HTML editing for example) : vim online
Home
Search
Tip #624: Insert template files into buffer ( HTML editing for example)
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<External Paste Buffer | Typing print statements faster and more ergonomically (esp in C++) >>
Additional Notes
User-command-REVIM, December 20, 2003 14:30
Tip #624 - Insert template files into buffer ( HTML editing for example) : vim online
Tip #624 - Insert template files into buffer ( HTML editing for example) : vim online
Great ideas!
I changed the name of the user command to Refile -- to
remind
me to rename the file after the alterations, and to
keep the
reference file with the #refile=path/file
lines intact...
refile > read ref(erence) file(s)
This would require changing that magic number from 7 to
8,
because "refile" has one more letter than "revim" ...
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #625 - Typing print statements faster and more ergonomically (esp in C++) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Tip #625 - Typing print statements faster and more ergonomically (esp in C++) : vim online
inoremap < ,
inoremap ' "
inoremap " '
imap ; <Esc>:call CppResetCout ()<CR>a;
map <Esc>, :call CppResetCout ()<CR>
imap <Esc>, <C-o>:call CppResetCout ()<CR>
endf
function! CppResetCout ()
iunmap ,
iunmap <
iunmap '
iunmap "
iunmap ;
imap <Esc>, <C-o>:call CppSetupCout ()<CR>
map <Esc>, :call CppSetupCout ()<CR>
endfunction
function! AuCpp ()
inoremap cout <End><Esc>:call CppSetupCout
()<CR>acout <<
imap <Esc>, <C-o>:call CppSetupCout ()<CR>
map <Esc>, :call CppSetupCout ()<CR>
endfunction
autocmd FileType cpp call AuCpp()
Notice that I use <Esc>, (or Alt-,) to quickly toggle
these mappings on or off in other situations.
For some other languages it's prob sufficient to simply
switch single- and double-quotes. Java might call for
switching '+' and '=' within system.out.println. Come to
think of it:
autocmd FileType java iabbrev sop system.out.println
You get the idea.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Insert template files into buffer ( HTML editing for example) | open vimrc file >>
Additional Notes
Anonymous, December 24, 2003 3:52
Tip #625 - Typing print statements faster and more ergonomically (esp in C++) : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Typing print statements faster and more ergonomically (esp in C++) | Customizing ftplugin, syntax
etc. (eg for TeX) >>
Additional Notes
Anonymous, December 24, 2003 6:34
I'm using it slightly different way:
:cabbrev vi $VIM/_vimrc
:cabbrev gvi $VIM/_gvimrc
now whenever i want to tweak my setup i just type:
:e vi<space>
or
:vs vi<space>
or
:sp vi<space>
and voila!
( <space> is pressing spacebar key )
Nice tip, anyway! :)
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #627 - Customizing ftplugin, syntax etc. (eg for TeX) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Tip #627 - Customizing ftplugin, syntax etc. (eg for TeX) : vim online
"-------------------------if exists("b:did_mysyntax")
finish
endif
let b:did_mysyntax = 1
"hilight 1 true in, 1truein, 1 truein, 1true in, 1in, 1 in, 1.1 truein, etc.
syn match texTrueLength "\<\d\+\(\.\d\+\)\=\(\ *true\ *\|\ *\)\
\(\ *pt\|\
\ *he\|\
\ *bp\|\
\ *cc\|\
\ *cm\|\
\ *dd\|\
\ *em\|\
\ *ex\|\
\ *in\|\
\ *mm\|\
\ *pc\|\
\ *pt\|\
\ *sp\)\>"
if version >= 508 || !exists("did_c_syn_inits")
if version < 508
let did_c_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink texTrueLength Number
delcommand HiLink
endif
"---*---*---*---*---*---
Life Changing
Helpful
<<open vimrc file | Execut "things" in Win98 from within VIM >>
Unfulfilling
rate
Tip #627 - Customizing ftplugin, syntax etc. (eg for TeX) : vim online
Additional Notes
Suresh Govindachar, December 24, 2003 18:04
The first four lines in each file should _NOT_ be present:
if exists("b:did_my...")
finish
endif
let b:did_my... = 1
When these lines are present, they prevent the loading
of the customization when, for example, the user
does ":e!".
benji@member.AMS.org, December 30, 2003 13:25
Unless you add
let b:did_ftplugin
to the ftplugin, the default ftplugin/tex.vim will still be read, and it will
clobber your customizations. Similar remarks apply to the other customization
files. See
:help ftplugin-overrule
for more details.
This can be useful as an example, but before you decide not to use the
default settings, have a look at what you are losing. Because of a typo, the
default ftplugin/tex.vim does not recognize \gdef, but it does recognize \def,
\let, \font, \newcommand, and \renewcommand, as well as \futurelet, \newcount,
and several other variants. If you care about \gdef, the best thing to do is to
alert the maintainer (in this case, c'est moi).
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #628 - Execut "things" in Win98 from within VIM : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Tip #628 - Execut "things" in Win98 from within VIM : vim online
help
<cWORD>
Life Changing
Helpful
Unfulfilling
rate
<<Customizing ftplugin, syntax etc. (eg for TeX) | After quitting VIM, comeback to the same file position where
you were while quitting. >>
Additional Notes
Suresh Govindachar, January 1, 2004 16:27
Executing a directory works, but this is not a good usage
of the mapping -- since it is better to edit a directory!
See help file-explorer
Suresh Govindachar, January 1, 2004 20:08
Although the example given above about searching this website
for "mail" does work with \x, there is a bug in rundll32 that
prevents \x from working on url's that end with an actual
file -- see
"http://support.microsoft.com/default.aspx?scid=kb;enus;283225";
The following mapping can be used for such cases (based on
vimtip #394):
nmap \e
:silent !start "c:\program files\internet
explorer\iexplore.exe" -nohome <cWORD> <CR>
hermitte {at} free {dot} fr, January 6, 2004 1:51
Because sometimes URLs can be within a pair of brackets or
<>, I'm using : the following mappings:
nnoremap <silent> <C-L>e
\ :exe ':!start cygstart '.
\
matchstr(expand('<cWORD>'),
\
'\%(.\{}\zs\%(news:\\|mailto:\\|ftp://\\|https\=://\)\)\=[^:;,<>]\+'
\ )<CR>
vnoremap <silent> <C-L>e
\ <C-\><C-N>:let w:a_save=@a<cr>gv"ay
\ :exe ':!start cygstart '.@a<CR>:let
@a=w:a_save<cr>:unlet w:a_save<cr>
(Note as filenames may contains spaces, I haven't tried to
support file:///)
Tip #628 - Execut "things" in Win98 from within VIM : vim online
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #629 - After quitting VIM, comeback to the same file position where you were while quitting. : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #629: After quitting VIM, comeback to the same file position
where you were while quitting.
tip karma
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Execut "things" in Win98 from within VIM | usefull for programming >>
Additional Notes
drNchip@OcampSbellPfamilyA.bizM, January 2, 2004 7:19
In order to exit vim and return later to the file at
the same file position, see vimtip#80.
Anonymous, January 5, 2004 2:55
May be using '0 or `0 is easier? :)
sgs_ocp@yahoo.com, January 7, 2004 1:03
Tip #629 - After quitting VIM, comeback to the same file position where you were while quitting. : vim online
Hi
i don't know exactly how but my VIM 6.2 on win 2k saves
position when i re open the file !
i use :wq to save and exit
Romland, January 8, 2004 3:42
...and if you found this interesting you might also
find that you can open more VIMs at the command prompt
and suspend those too (with ctrl-z). Then to see a list
of all suspended VIMs (processes) you type 'jobs'.
Might look something like this:
fnurt@iblam[www]$ jobs
[1]- Stopped
vim foo
[2]+ Stopped
vim bar
To return to either of the processes just type %1 for
the first one and %2 for the second one and so forth.
cheers.
da_infamous_one@hotmail.com, February 5, 2004 8:06
....unfortunately you cannot suspend processes like
that in windows.
Another solution to edit multiple files in vim is to
use vim's multiple buffers.
Just place the following in your .vimrc file
map <M-Left> :bN!<CR>
map <M-Right> :bn!<CR>
map <M-Up> :buffers<CR>
Just load up all your files in vim, by recursive :e
command or at prompt vim *
Now you can cycle through your multiple buffers by
pressing the alt-left or alt-right.
Oh and alt-up will show your buffer list...
enjoy.
da_infamous_one@hotmail.com, February 5, 2004 8:06
Tip #629 - After quitting VIM, comeback to the same file position where you were while quitting. : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Hello,
I was looking for that feature for the very long time.
I use vim for programming and I always keep forgetting
about closing the parents, quotes etc.
I wanted to remap the keyboard in insert mode in that
way that when I open a quote or parent I will get the
closing one and the cursor would be placed between these
two characters.
here is
<pre>
:imap (
:imap [
:imap "
</pre>
Life Changing
Helpful
Unfulfilling
rate
<<After quitting VIM, comeback to the same file position where you were while quitting. | Disabling IME
input in Windows >>
Additional Notes
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Anonymous, January 4, 2004 18:04
imcmdline and imsearch can also be disabled in the same
way.
Anonymous, January 5, 2004 2:08
set imdisable
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
(if 'nocompatible'), or
(if 'compatible')
Life Changing
Helpful
Unfulfilling
<<Disabling IME input in Windows | spell check of word below cursor >>
Additional Notes
rate
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Setting the font in the GUI | To view all colours available to gvim >>
Additional Notes
JonathanOrlev@yahoo.com, January 11, 2004 1:30
Very nive tip.
ThanQ very much.
don@seiler.us, January 14, 2004 7:41
This probably deserves an RTFM, but what does "map <Ae>" map to? Meaning what keys do I hit to run the
command?
surs.deletethis@cis.ohio-state.edu, January 14, 2004 7:49
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
tip karma
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 6.0
Site Help
snow
GhostWhite
WhiteSmoke
gainsboro
FloralWhite
OldLace
linen
AntiqueWhite
PapayaWhip
BlanchedAlmond
bisque
PeachPuff
NavajoWhite
moccasin
cornsilk
ivory
LemonChiffon
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
seashell
honeydew
MintCream
azure
AliceBlue
lavender
LavenderBlush
MistyRose
white
black
DarkSlateGray
DarkSlateGrey
DimGray
DimGrey
SlateGray
SlateGrey
LightSlateGray
LightSlateGrey
gray
grey
LightGrey
LightGray
MidnightBlue
navy
NavyBlue
CornflowerBlue
DarkSlateBlue
SlateBlue
MediumSlateBlue
LightSlateBlue
MediumBlue
RoyalBlue
blue
DodgerBlue
DeepSkyBlue
SkyBlue
LightSkyBlue
SteelBlue
LightSteelBlue
LightBlue
PowderBlue
PaleTurquoise
DarkTurquoise
MediumTurquoise
turquoise
cyan
LightCyan
CadetBlue
MediumAquamarine
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
aquamarine
DarkGreen
DarkOliveGreen
DarkSeaGreen
SeaGreen
MediumSeaGreen
LightSeaGreen
PaleGreen
SpringGreen
LawnGreen
green
chartreuse
MediumSpringGreen
GreenYellow
LimeGreen
YellowGreen
ForestGreen
OliveDrab
DarkKhaki
khaki
PaleGoldenrod
LightGoldenrodYellow
LightYellow
yellow
gold
LightGoldenrod
goldenrod
DarkGoldenrod
RosyBrown
IndianRed
SaddleBrown
sienna
peru
burlywood
beige
wheat
SandyBrown
tan
chocolate
firebrick
brown
DarkSalmon
salmon
LightSalmon
orange
DarkOrange
coral
LightCoral
tomato
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
OrangeRed
red
HotPink
DeepPink
pink
LightPink
PaleVioletRed
maroon
MediumVioletRed
VioletRed
magenta
violet
plum
orchid
MediumOrchid
DarkOrchid
DarkViolet
BlueViolet
purple
MediumPurple
thistle
snow1
snow2
snow3
snow4
seashell1
seashell2
seashell3
seashell4
AntiqueWhite1
AntiqueWhite2
AntiqueWhite3
AntiqueWhite4
bisque1
bisque2
bisque3
bisque4
PeachPuff1
PeachPuff2
PeachPuff3
PeachPuff4
NavajoWhite1
NavajoWhite2
NavajoWhite3
NavajoWhite4
LemonChiffon1
LemonChiffon2
LemonChiffon3
LemonChiffon4
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
cornsilk1
cornsilk2
cornsilk3
cornsilk4
ivory1
ivory2
ivory3
ivory4
honeydew1
honeydew2
honeydew3
honeydew4
LavenderBlush1
LavenderBlush2
LavenderBlush3
LavenderBlush4
MistyRose1
MistyRose2
MistyRose3
MistyRose4
azure1
azure2
azure3
azure4
SlateBlue1
SlateBlue2
SlateBlue3
SlateBlue4
RoyalBlue1
RoyalBlue2
RoyalBlue3
RoyalBlue4
blue1
blue2
blue3
blue4
DodgerBlue1
DodgerBlue2
DodgerBlue3
DodgerBlue4
SteelBlue1
SteelBlue2
SteelBlue3
SteelBlue4
DeepSkyBlue1
DeepSkyBlue2
DeepSkyBlue3
DeepSkyBlue4
SkyBlue1
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
SkyBlue2
SkyBlue3
SkyBlue4
LightSkyBlue1
LightSkyBlue2
LightSkyBlue3
LightSkyBlue4
SlateGray1
SlateGray2
SlateGray3
SlateGray4
LightSteelBlue1
LightSteelBlue2
LightSteelBlue3
LightSteelBlue4
LightBlue1
LightBlue2
LightBlue3
LightBlue4
LightCyan1
LightCyan2
LightCyan3
LightCyan4
PaleTurquoise1
PaleTurquoise2
PaleTurquoise3
PaleTurquoise4
CadetBlue1
CadetBlue2
CadetBlue3
CadetBlue4
turquoise1
turquoise2
turquoise3
turquoise4
cyan1
cyan2
cyan3
cyan4
DarkSlateGray1
DarkSlateGray2
DarkSlateGray3
DarkSlateGray4
aquamarine1
aquamarine2
aquamarine3
aquamarine4
DarkSeaGreen1
DarkSeaGreen2
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
DarkSeaGreen3
DarkSeaGreen4
SeaGreen1
SeaGreen2
SeaGreen3
SeaGreen4
PaleGreen1
PaleGreen2
PaleGreen3
PaleGreen4
SpringGreen1
SpringGreen2
SpringGreen3
SpringGreen4
green1
green2
green3
green4
chartreuse1
chartreuse2
chartreuse3
chartreuse4
OliveDrab1
OliveDrab2
OliveDrab3
OliveDrab4
DarkOliveGreen1
DarkOliveGreen2
DarkOliveGreen3
DarkOliveGreen4
khaki1
khaki2
khaki3
khaki4
LightGoldenrod1
LightGoldenrod2
LightGoldenrod3
LightGoldenrod4
LightYellow1
LightYellow2
LightYellow3
LightYellow4
yellow1
yellow2
yellow3
yellow4
gold1
gold2
gold3
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
gold4
goldenrod1
goldenrod2
goldenrod3
goldenrod4
DarkGoldenrod1
DarkGoldenrod2
DarkGoldenrod3
DarkGoldenrod4
RosyBrown1
RosyBrown2
RosyBrown3
RosyBrown4
IndianRed1
IndianRed2
IndianRed3
IndianRed4
sienna1
sienna2
sienna3
sienna4
burlywood1
burlywood2
burlywood3
burlywood4
wheat1
wheat2
wheat3
wheat4
tan1
tan2
tan3
tan4
chocolate1
chocolate2
chocolate3
chocolate4
firebrick1
firebrick2
firebrick3
firebrick4
brown1
brown2
brown3
brown4
salmon1
salmon2
salmon3
salmon4
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
LightSalmon1
LightSalmon2
LightSalmon3
LightSalmon4
orange1
orange2
orange3
orange4
DarkOrange1
DarkOrange2
DarkOrange3
DarkOrange4
coral1
coral2
coral3
coral4
tomato1
tomato2
tomato3
tomato4
OrangeRed1
OrangeRed2
OrangeRed3
OrangeRed4
red1
red2
red3
red4
DeepPink1
DeepPink2
DeepPink3
DeepPink4
HotPink1
HotPink2
HotPink3
HotPink4
pink1
pink2
pink3
pink4
LightPink1
LightPink2
LightPink3
LightPink4
PaleVioletRed1
PaleVioletRed2
PaleVioletRed3
PaleVioletRed4
maroon1
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
maroon2
maroon3
maroon4
VioletRed1
VioletRed2
VioletRed3
VioletRed4
magenta1
magenta2
magenta3
magenta4
orchid1
orchid2
orchid3
orchid4
plum1
plum2
plum3
plum4
MediumOrchid1
MediumOrchid2
MediumOrchid3
MediumOrchid4
DarkOrchid1
DarkOrchid2
DarkOrchid3
DarkOrchid4
purple1
purple2
purple3
purple4
MediumPurple1
MediumPurple2
MediumPurple3
MediumPurple4
thistle1
thistle2
thistle3
thistle4
gray0
grey0
gray1
grey1
gray2
grey2
gray3
grey3
gray4
grey4
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
gray5
grey5
gray6
grey6
gray7
grey7
gray8
grey8
gray9
grey9
gray10
grey10
gray11
grey11
gray12
grey12
gray13
grey13
gray14
grey14
gray15
grey15
gray16
grey16
gray17
grey17
gray18
grey18
gray19
grey19
gray20
grey20
gray21
grey21
gray22
grey22
gray23
grey23
gray24
grey24
gray25
grey25
gray26
grey26
gray27
grey27
gray28
grey28
gray29
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
grey29
gray30
grey30
gray31
grey31
gray32
grey32
gray33
grey33
gray34
grey34
gray35
grey35
gray36
grey36
gray37
grey37
gray38
grey38
gray39
grey39
gray40
grey40
gray41
grey41
gray42
grey42
gray43
grey43
gray44
grey44
gray45
grey45
gray46
grey46
gray47
grey47
gray48
grey48
gray49
grey49
gray50
grey50
gray51
grey51
gray52
grey52
gray53
grey53
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
gray54
grey54
gray55
grey55
gray56
grey56
gray57
grey57
gray58
grey58
gray59
grey59
gray60
grey60
gray61
grey61
gray62
grey62
gray63
grey63
gray64
grey64
gray65
grey65
gray66
grey66
gray67
grey67
gray68
grey68
gray69
grey69
gray70
grey70
gray71
grey71
gray72
grey72
gray73
grey73
gray74
grey74
gray75
grey75
gray76
grey76
gray77
grey77
gray78
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
"
grey78
gray79
grey79
gray80
grey80
gray81
grey81
gray82
grey82
gray83
grey83
gray84
grey84
gray85
grey85
gray86
grey86
gray87
grey87
gray88
grey88
gray89
grey89
gray90
grey90
gray91
grey91
gray92
grey92
gray93
grey93
gray94
grey94
gray95
grey95
gray96
grey96
gray97
grey97
gray98
grey98
gray99
grey99
gray100
grey100
DarkGrey
DarkGray
DarkBlue
DarkCyan
" DarkMagenta
" DarkRed
" LightGreen
Life Changing
Helpful
Unfulfilling
rate
<<spell check of word below cursor | getting colors to work on solaris >>
Additional Notes
mosh, January 8, 2004 16:05
In the first two lines, change double backslashes to
single-backslashes.
I can't post single backslashes from the web interface.
Also keep the cursor the first line, when doing ':so
%'.
drNchip@OcampSbellPfamilyA.comM - NOSPAM, January 9, 2004 9:48
I believe vim is limited to 224 concurrent colors due
to the way it is stored.
Anonymous, January 9, 2004 20:16
Hmm... all colors show in :highlight though.
Couldn't ever get this to work within the file on
WinXP, although again, :highlight showed them all.
http://www.cs.albany.edu/~mosh, January 13, 2004 18:52
I simplified the script below, you can try it on 100
colors at a time
to see your choices, since vim seems to have a limit on
the
number of simultaneous colors.
Note that the second line has two double backslashes,
they might
get deleted in the process the web posting.
- mosh
-- cut here -call search("^$")
while search("\\w\\+") > 0
http://www.vim.org/tips/tip.php?tip_id=634 (15 of 19) [18/02/2004 15:09:14]
gray13 grey13
gray18 grey18
gray23 grey23
gray28 grey28
gray33 grey33
gray38 grey38
gray43 grey43
gray48 grey48
gray53 grey53
gray58 grey58
gray63 grey63
gray68 grey68
gray73 grey73
gray78 grey78
gray83 grey83
gray88 grey88
gray93 grey93
gray98 grey98
DarkCyan
Executable
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<To view all colours available to gvim | Adding Vim to MS-Windows File Explorer Menu >>
Additional Notes
smaillboy@yahoo.com, January 22, 2004 23:54
I tried this in sun solaris 2.8.. but didn't work
out.
I installed ncurses from the site mentioned and of no
use...
-Prem
sleelsc@yahoo.com, January 23, 2004 20:52
I tried type in the line as VIM command, it return
error: "E492: Not an editor command: --withtlib=ncuerses."
And it dosen't work either, if I put it in my .vimrc
file.
Someone know anything about this, please help!!!
ipkiss _at_ via.ecp.fr, January 29, 2004 7:18
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #636 - Adding Vim to MS-Windows File Explorer Menu : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
Additional Notes
http://www.vim.org/tips/tip.php?tip_id=636 (1 of 2) [18/02/2004 15:09:21]
rate
Tip #636 - Adding Vim to MS-Windows File Explorer Menu : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Adding Vim to MS-Windows File Explorer Menu | Editing ActiveState Perl batch files >>
Additional Notes
bertilow@gmx.net, January 18, 2004 3:12
I guess you meant:
inoremap <somekey> <esc>u:@.
sergio@imovelweb.com.br, January 19, 2004 13:01
I prefer inoremap <somekey> <esc>u@. i
zzapper@ntlworld.com, January 20, 2004 1:58
Also
yy@"
yy
@"
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
endfun
--->That's it! This is very specific to look for the
string pl2bat adds to the file, but can be easily
modified to your needs.
Life Changing
Helpful
Unfulfilling
rate
<<execute accidently inserted commands | Comment highlight #ifdef DEBUG for code-read ease
(C/C++) >>
Additional Notes
Anonymous, January 19, 2004 4:10
Add this line at the top of your converted pl2bat
script and everything should work automatically:
@rem vim: set ft=perl:
See :h modeline
Same anonymous, January 19, 2004 4:16
A little offtopic about perl:
Under windows you _can_ use piping _not converting to
bat files_
#file test.pl
print "hi!\n";
#file test1.pl
$str = <>;
print "\$str=$str\n";
Now just run perl test.pl | perl test1.pl
And you see piping. :)
Anonymous, January 20, 2004 2:23
foo.pl
param1
param2
perl foo.pl
param1
param2
But not the way I have it. I suppose tihs may point to
a bug in Perl on Windows, but I could also write my
scripts differently. Thanks for some enlightenment on
two subjects.
</offtopic>
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #639 - Comment highlight #ifdef DEBUG for code-read ease (C/C++) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Hi all,
If your C/C++ code is scattered with statements like
#ifdef DEBUG
// Some code..
cout << "Debug output: blah" << endl;
#endif
and you would like to highlight these segments in a
different colour (so that
you can skip them visually), add the following code in
your .vimrc (colouring
follows that of comments)
CODE STARTS
syn region MySkip contained
start="^\s*#\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$"
end="^\s*#\s*endif\>" contains=MySkip
let g:CommentDefines = ""
hi link MyCommentOut2 MyCommentOut
hi link MySkip MyCommentOut
hi link MyCommentOut Comment
map <silent> ,a :call AddCommentDefine()<CR>
map <silent> ,x :call ClearCommentDefine()<CR>
function! AddCommentDefine()
let g:CommentDefines = "\\(" . expand("<cword>") .
"\\)"
syn clear MyCommentOut
syn clear MyCommentOut2
exe 'syn region MyCommentOut
start="^\s*#\s*ifdef\s\+' . g:CommentDefines . '\>"
end=".\|$" contains=MyCommentOut2'
exe 'syn region MyCommentOut2 contained start="' .
Tip #639 - Comment highlight #ifdef DEBUG for code-read ease (C/C++) : vim online
g:CommentDefines . '"
end="^\s*#\s*\(endif\>\|else\>\|elif\>\)"
contains=MySkip'
endfunction
function! ClearCommentDefine()
let g:ClearCommentDefine = ""
syn clear MyCommentOut
syn clear MyCommentOut2
endfunction
CODE ENDS
To see the effect, position the cursor on the word DEBUG
in the C code snippet above and type ,a
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<Editing ActiveState Perl batch files | See your vim templates in Windows Explorer's New context
menu >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #640 - See your vim templates in Windows Explorer's New context menu : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Do you wish you had your own vim settings for a file
appear automatically when
you right click in Windows Explorer? If so then read on,
following these steps
sequentially:
- Create a template file where the last few lines
control vim. See below for a
sample:
-[sample template file begins below this line]--------------------------------End of Text--------------------------------The line below controls vim, which you can get free
from: http://www.vim.org/
vim:tw=80:ai:ft=txt:norl:
-[sample template file ends above this line]- Call the above sample template file GVIM.vtd and save
it in
"C:\Windows\ShellNew\" directory. You may use another
extension, but I
played it safe and used one that wasn't being used on
my system. Moreover, I
did not change the default location of Windows
installation, but you may
need to do so if your system does not match mine.
- Open Explorer and click on Tools->Folder Options... in
the dialog box that
appears, click on File Types and then scroll the file
types until you reach
VTD. Click on the file extension VTD and click on
Change; now associate
gvim.exe with this file extension.
Tip #640 - See your vim templates in Windows Explorer's New context menu : vim online
Life Changing
Helpful
Unfulfilling
rate
<<Comment highlight #ifdef DEBUG for code-read ease (C/C++) | Highlighting of method names in the
definition (C++) >>
Tip #640 - See your vim templates in Windows Explorer's New context menu : vim online
Additional Notes
Mark Fernandes, January 20, 2004 20:42
Sorry I forgot to add this important information too...
- In the registry editor (Start->Run->regedit) goto
HKEY_CLASSES_ROOT and then
scroll till you get to ".vtd" and change string value
(Default) to Vim.Application
- next click on [HKEY_CLASSES_ROOT\.vtd]; add a key;
call it "ShellNew"
- next click on "ShellNew" and add a String Value; call
it "FileName";
double click on "FileName" and enter GVIM.vtd
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #641 - Highlighting of method names in the definition (C++) : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<See your vim templates in Windows Explorer's New context menu | Windows: Get K to not display a
DOS box that needs closing >>
Additional Notes
Niklas, January 22, 2004 16:41
Tip #641 - Highlighting of method names in the definition (C++) : vim online
Hi,
good tip! To further facilitate adding user-defined
extensions to existing syntax files, you can use a
".vim/after/syntax/" directory. See:
:help mysyntaxfile-add
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #642 - Windows: Get K to not display a DOS box that needs closing : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #642: Windows: Get K to not display a DOS box that needs
closing
tip karma
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Highlighting of method names in the definition (C++) | Disable built-in command >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Windows: Get K to not display a DOS box that needs closing | restoring indent for '#' >>
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Disable built-in command | Enabling Windows shortcuts (eg alt+space, F10 etc) for gvim window >>
Additional Notes
Anonymous, January 29, 2004 19:45
Too bad that map doesn't work when there are characters
on the line after where you are trying to insert the #,
then you wind up with an "a" instead. Instead try
:inoremap # a#<Left><BS><Right>
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #645 - Enabling Windows shortcuts (eg alt+space, F10 etc) for gvim window : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
Tip #645: Enabling Windows shortcuts (eg alt+space, F10 etc) for
gvim window
tip karma
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
jevonsdu@hotmail.com, January 28, 2004 5:19
I use VIM on Win2K, ALT+Space works well on English
Win2K platform, it seems this shortcut does not work on
multi-byte language Win2K (e.g. Chinese Win2K). Is this
a bug ?
slackorama@GOAWAYSPAMMERS_hotmail.com, January 28, 2004 18:28
Tip #645 - Enabling Windows shortcuts (eg alt+space, F10 etc) for gvim window : vim online
I'm using vim 6.1 on WinXP and the Alt+Space works for
me but not in the normal way. I have to press Alt,
release it and then press the space bar to bring up the
menu. In most other programs I can press and hold Alt
and then hit the space bar.
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Enabling Windows shortcuts (eg alt+space, F10 etc) for gvim window | Single letter insert >>
Additional Notes
salmanhalim@hotmail.com, January 29, 2004 7:00
This works everywhere except at the top or bottom of
the buffer. There was a discussion about this on the
Vim list a while back and a swap line plugin came out
of it -- I don't know who produced it in the first
place and I won't want to post it here without giving
due credit, but basically it mapped the key
combinations to two different functions that would
first store the current column the cursor was in, then
swap the line (behaving differently at the
beginning/end of the buffer -- try doing the
combination in the original tip here to see what I mean
about the need to behave differently at the edges of
the buffer) and then restore the cursor position,
<f11>
<f11>
<f12>
<f12>
:.w! c:/aaa/xr<CR>
<ESC>:.w! c:/aaa/xr<CR>
:r c:/aaa/xr<CR>
<ESC>:r c:/aaa/xr<CR>
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Anonymous, January 30, 2004 6:51
Doesn't work when there is nothing already on the line.
I use
:map ,i i?<Esc>r
and
:map ,a a?<Esc>r
Anonymous, January 30, 2004 6:53
The previous note wasn't an original, but grew out of
vimtip #466 .
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: intermediate
as of Vim: 6.0
There are two versions, the first leaves only the last line,
the second leaves only the first line.
g/^\(.*\)$\n\1$/d
g/\%(^\1$\n\)\@<=\(.*\)$/d
Breakdown of the second version:
Site Help
g//d
\@<=
<-- If the bit following matches, make sure the bit
preceding this symbol directly precedes the match
\(.*\)$
\%( )
<--- Group without placing in a subst register.
^\1$\n
<--- Match subst register 1 followed by end of line
and the new line between the 2 lines
In this simple format (matching the whole line), it's not
going to make much difference, but it will start to matter if
you want to do stuff like match the first word only
This does a uniq on the first word in the line, and deletes
all but the first line:
g/\%(^\1\>.*$\n\)\@<=\(\k\+\).*$/d
Life Changing
Helpful
Additional Notes
box1024@post.com, February 2, 2004 4:57
Unfulfilling
rate
search('^'.escape(getline('.'),'\.*[]^$/').'$','bW')\|'ld<CR>
Antony
ads@metawire.org, February 4, 2004 8:10
Here are some more vim-native ways for removing duplicate
lines. This time they don't have to be adjacent. Line order
is preserved.
This one can be a bit slow.
:nno \d1
:g/^/m0<CR>:g/^\(.*\)\n\_.*\%(^\1$\)/d<CR>:g/^/m0<CR>
This is faster (some help from Preben Guldberg with this
one).
Uses mark l.
:nno \d2 :g/^/kl\|if
search('^'.escape(getline('.'),'\.*[]^$/').'$','bW')\|'ld<CR>
Antony
ads@metawire.org, February 4, 2004 8:10
Here are some more vim-native ways for removing duplicate
lines. This time they don't have to be adjacent. Line order
is preserved.
This one can be a bit slow.
:nno \d1
:g/^/m0<CR>:g/^\(.*\)\n\_.*\%(^\1$\)/d<CR>:g/^/m0<CR>
This is faster (some help from Preben Guldberg with this
one).
Uses mark l.
:nno \d2 :g/^/kl\|if
search('^'.escape(getline('.'),'\.*[]^$/').'$','bW')\|'ld<CR>
Antony
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<Uniq - Removing duplicate lines | abbreviation that prompts whether to expand it or not >>
Additional Notes
ads@metawire.org, February 4, 2004 7:54
That won't work if the abbrev. is the last word on the
line. Try:
:nno <C-X><C-X> ciw@<Esc>"_s<C-R>"<Esc>b
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #650 - abbreviation that prompts whether to expand it or not : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
mark.thomas@tampagov.net, February 4, 2004 9:26
In your example shouldn't 'AskExpand' read 'MyExpand' ?
Add Note
Tip #650 - abbreviation that prompts whether to expand it or not : vim online
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
<<abbreviation that prompts whether to expand it or not | save all open buffers at once >>
Additional Notes
victorlei@yahoo.com, February 10, 2004 3:18
One should be aware of leaving pieces of the plaintext
inside registers
in .viminfo file.
http://www.cs.albany.edu/~mosh, February 10, 2004 19:12
Specify -n option, so that vim doesn't use swap file
and save the plain text to disk.
I wrote the vimcrypt functionality in vim5.7 when I was
in India,
its not strong, but keeps the grandmons and admin at
bay.
- Mohsin.
schella@comp.uark.edu, February 15, 2004 21:11
Nice, very helpful! When I do a :w though, cursor
position is reset to the beginning of the buffer. Is
there any way to prevent this and keep it at where it
was?
ingok@gmx.net, February 16, 2004 8:36
if gpg fails, your encrypted file is gone :(
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
Additional Notes
loveunixnet@tom.com, February 6, 2004 19:01
how about :wa
I like to use it
wormdetector@gmx.de, February 7, 2004 1:02
http://www.vim.org/tips/tip.php?tip_id=652 (1 of 2) [18/02/2004 15:10:22]
rate
:-)
good hint. I didn't know it.
mosh, February 10, 2004 19:06
:xa
to save all modified buffers and exit.
:wa
will update files even if unmodified.
- Mohsin
wormdetector@gmx.de, February 13, 2004 2:07
sorry, Mosh, that's not correct.
:wa
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: intermediate
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
<<save all open buffers at once | special characters in VIM substitution >>
Additional Notes
allanneal@myrealbox.com, February 12, 2004 10:44
rate
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Anonymous, February 15, 2004 22:32
why not?
%s/\(\d\)\(\d\)/[\1][\2]/
elvegamx@yahoo.com.mx, February 16, 2004 5:53
this works too:
%s/\v(\d)(\d)/[\1][\2]
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: basic
as of Vim: 5.7
:nmap
Site Help
Now you can search for the word under the cursor in
normal mode with the F8 key backwards and the F9 key
forwards.
Can this be done in insert mode?
rate this tip
Life Changing
Helpful
Unfulfilling
rate
<<special characters in VIM substitution | Recursive mappings - (2 examples to learn from) >>
Additional Notes
sandor.kopanyi@essnet.se, February 16, 2004 23:41
In insert mode just escape to normal mode, do the same
thing, then go back to insert mode with "a":
:imap
:nmap
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
complexity: advanced
as of Vim: 5.7
Site Help
want to change
myid
199
myid2 200
myid3 201
To
#define myid
201
#define myid2 202
#define myid3 203
The simple mapping would be :map z 2^Ajz
Where ^A is CTRL_V+A
1.
2.
3.
Also see
:help recursive_mapping
:help CTRL-A
:help nowrapscan // when using recursion with
searching.
There may be many ways to solve the above problems...
this is just another way which I like to use. Recursion
is very powerful espcially when I manipulate many open
windows where the content of one is to be used in
another.
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Mohit Kalra, February 17, 2004 8:19
Ignore the extra space in front of 199 in the second
example (in case you are copy pasting from the
examples).
It just got there somehow.
anon, February 17, 2004 12:16
How does one stop a recursion that starts with a
search?
For example, I went through a document marking the
paragraphs of
interest with ^*****, and then tried yanking them using
the recursion:
nmap z /^\*\*\*\*\*k"Ay}3jz
This went into an infinite loop -- which I killed with
^C. Then, after
pasting register a, I had to delete the duplicate
stuff.
--Anon
Mohit Kalra, February 17, 2004 20:25
>>How does one stop a recursion that starts with a
search?
:set nowrapscan
See the "Also See" section in the tip above.
The terminating condition for such a recursive mapping
is that the search should not find anything. If the
wrapscan is on, the search starts from the top of the
document again. So setting wrapscan to **off** makes
sure that the search has a terminating condition.
BTW I think nmap z /^\*\*\*\*\*k"Ay}3jz
should be
nmap z /^\*\*\*\*\*<CR>k"Ay}3jz
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
Life Changing
Helpful
Unfulfilling
rate
<<Recursive mappings - (2 examples to learn from) | Switching to unit test module for python >>
Additional Notes
Anon, February 17, 2004 21:16
**Please use this site responsibly.**
IMHO - This tip is no better than the questions posted
here. The site you mention has two messages posted and
only two registered members.
Try
http://groups.google.com/groups?hl=en&lr=&ie=UTF8&oe=UTF-8&group=comp.editors
Anonymous, February 18, 2004 7:06
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #658 - Switching to unit test module for python : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 6.0
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo
Tip #658 - Switching to unit test module for python : vim online
Home
Search
About Vim
Community
News
Sponsoring
Trivia
Documentation
Download
Scripts
Tips
My Account
Site Help
complexity: basic
as of Vim: 5.7
endif
endwhile
endfunction
rate this tip
Life Changing
Helpful
Unfulfilling
rate
Additional Notes
Add Note
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to vim@vim.org after searching the archive. Help Bram help Uganda.
SourceForge
Logo