Click to See Complete Forum and Search --> : vim stuff (for TLD)


Strike
10-13-2000, 05:23 PM
Okay, here's a few really key things for setting up macros and such for using vim.

The way I have things set up is so that I have one main .vimrc file that handles most things by calling other files, depending upon the type of file I'm editing.

Here it comes (what I've done so far, I just recently started from scratch to try and clean things up):

---[~/.vimrc]---
" Formatting
set tabstop=4 " tabs are 4 spaces
set bs=2 " backspace over anything in insert mode
set smartindent " does C-style stuff

" Mouse stuff
set mousehide " hides mouse after characters are typed
set mousefocus " no real reason for this
set mouse=a " mouse in all modes
set mousem=popup " Right button - menu, shift-left - extend selection

" Other stuff
set autowrite " writes on make and shell commands, etc
set ruler " Turn the ruler on
set nohlsearch " Highlighting found search items is annoying
set nocompatible " vi compatibility is weak, disable it

" set suffixes to ignore in command-line completion
" these are mostly things we won't want to hand edit
set suffixes=.bak,~,.o,.info,.swp,.aux,.bbl,.blg,.dvi, .lof,.log,.lot,.ps,.toc

" And, of course, the ever important syntax highlighting
syntax on

" Remove ALL auto-commands. This avoids having the autocommands twice
" in case the file gets sources more than once
autocmd!

" LaTeX autocmds
autocmd BufRead *.tex source ~/.vim-files/.vimrc.latex
autocmd BufNewFile *.tex source ~/.vim-files/.vimrc.latex
"C autocmds
autocmd BufRead *.c source ~/.vim-files/.vimrc.c
autocmd BufNewFile *.c source ~/.vim-files/.vimrc.c
" asm autocmds
autocmd BufRead *.s,*.S,*.asm source ~/.vim-files/.vimrc.asm
autocmd BufNewFile *.s,*.S,*.asm 0r ~/.vim-files/skeletons/skel.asm
autocmd BufNewFile *.s,*.S,*.asm source ~/.vim-files/.vimrc.asm
" HTML autocmds
autocmd BufRead *.htm,*.html source ~/.vim-files/.vimrc.html
autocmd BufNewFile *.htm,*.html 0r ~/.vim-files/skeletons/skel.html
autocmd BufNewFile *.htm,*.html source ~/.vim-files/.vimrc.html
" Perl autocmds
autocmd BufRead *.pl source ~/.vim-files/.vimrc.perl
autocmd BufNewFile *.pl 0r ~/.vim-files/skeletons/skel.pl
autocmd BufNewFile *.pl source ~/.vim-files/.vimrc.perl
autocmd BufWrite *.pl !chmod +x %
" Java autocmds
autocmd BufRead *.java source ~/.vim-files/.vimrc.java
autocmd BufNewFile *.java source ~/.vim-files/.vimrc.java
---[~/.vimrc]---

The stuff at the top is just some basic options that can be set at the : command line anyway, but I don't want to have to do it every time, no way. The comments explain each.

Then, of course, I turn syntax highlighting on if the extension matches one of vim's built in ones (and oh so many do).

And all the autocmd stuff is fairly well exemplified above. Basically, let's take a look at the Perl autocmds I have defined:
---(in ~/.vimrc)---
" Perl autocmds
autocmd BufRead *.pl source ~/.vim-files/.vimrc.perl
autocmd BufNewFile *.pl 0r ~/.vim-files/skeletons/skel.pl
autocmd BufNewFile *.pl source ~/.vim-files/.vimrc.perl
autocmd BufWrite *.pl !chmod +x %
The first one is a BufRead autocmd. What this means is that if vim is instructed to read a file with the extension .pl into a buffer (every file you edit goes into a buffer), then it performs the command source ~/.vim-files/.vimrc.perl.

---edit---
(I'll discuss the other three in the next post)
---edit---

Now's probably a good time to explain my hierarchy further. I have one big .vimrc (most of it is above), and then a directory ~/.vim-files that contains other SUB-.vimrc's as well as "skeleton" files (if you don't know what that means, I'll explain in a minute). Basically, for each language I write in, I have a .vimrc.<language-name> file in that ~/.vim-files directory.

Okay, let's take a look at an example one of my .vimrc.<language> files. The Perl one is not a good start because ... I haven't put any macros in it yet http://www.linuxnewbie.org/ubb/smile.gif Let's look at my LaTeX one (only part of it though, because it is 64 lines long):
---[~/.vim-files/.vimrc.latex]----
" The first macro will invoke LaTeX on the current file: (after saving)
map ,rl :w<CR>:!latex %<CR>

" These deal with Postscript output
map ,cps :!dvips %<.dvi -t letter -o %<.ps<CR>
map ,gv :!ghostview %<.ps &<CR>
map ,lpr :!echo "Printing %<.ps on default printer"; lpr %<.ps <CR>

---[~/.vim-files/.vimrc.latex]---
These are some simple (yes, simple) macros for the command mode. Try and pick them apart.

Here, I'll use my newly hacked ~/.vim-files/.vimrc.c to show input mode macros (use map! instead of map):

---[~/.vim-files/.vimrc.c]---
" Basic C editing/compiling macros
"

" this will run gcc on the current file
" (good for small projects, otherwise you should
" use makefiles, and vim natively supports :make)
map ,gcc :w<CR>:!gcc -o %< %<CR>
" this will run the executable (assuming the name is just
" the source file with the extension chopped off)
map ,run :w<CR>:!%<<CR>

"Input mode macros
map! ]mainfull int main (int argc, char *argv[])
map! ]if if () {^[o}^[keei
map! ]for for () {^[o}^[keei
map! ]while while () {^[o}^[keei
map! ]inc #include <.h>^[hhi

---[~/.vim-files/.vimrc.c]---
The top stuff is kinda self-explanatory. The bottom mappings mean that while I am still in input mode, I can type ]mainfull and it will insert all that stuff. That's an easy example because it doesn't have escape sequences like the other ones.

The next three are essentially the same one with just different loop constructs in mind. Let's look at ]for. What happens when I type that? Well, first the text for () { will go in at the current cursor position. Then the ^[ escapes out of input mode (I don't think you can type those two characters to get this to work, when editing your file hit CTRL-V and then ESC to get it). Then the o inserts on the next line (that's a standard vi command), and it inserts a } and then escapes out of input mode again. It then goes up one line (k) and then goes two words ahead, at the end of the words (ee). And finally, it goes back into input mode (i). This will print out the entire for() with braces and all, and then put me back inside the parentheses, ready to define the loop.

Pretty cool, huh?

Well, before this post gets (even more) out of hand, I'm going to submit it and then answer any questions anyone has http://www.linuxnewbie.org/ubb/smile.gif

---edit---
I'm going to edit this a lot getting the formatting right, probably

[This message has been edited by Strike (edited 13 October 2000).]

TheLinuxDuck
10-13-2000, 05:37 PM
Qool.. http://www.linuxnewbie.org/ubb/smile.gif Give me a little time to examine this, and I'm sure I'll have questions.. http://www.linuxnewbie.org/ubb/wink.gif

------------------
TheLinuxDuck
Wait... that's a penguin?!?!?
:wq

Strike
10-13-2000, 05:40 PM
Okay, now for the next three autocmd lines.

The two BufNewFile lines are executed in order when a new file is created in a buffer and the filename matches *.pl. What these do are:

0r ~/.vim-files/skeletons/skel.pl

0 - goes to beginning of line 0
r ~/.vim-files/skeletons/skel.pl - reads the file mentioned into the current buffer (but we're still editing a different one, this just gives us a skeleton to start with)

In particular, my ~/.vim-files/skeletons/skel.pl looks like this:
#!/usr/bin/perl -w
use strict;

The skeleton files are useful for things that have a basic, well ... skeleton. For example, until I get more into Perl, every single script I write will have that at the top. But I'm lazy and don't want to write it every time (besides, why increase the chance for typing errors?), so I made a skeleton file for it. I did the same for my assembly stuff and HTML stuff, but none of my C or Java stuff really has a pattern to it, so I don't bother with making skeleton files since they'd probably just hinder me.

The next line of course does the same thing as the BufRead line explained above. We just have to specify that we want all those macros defined now as well (if there were any in my Perl .vimrc at the moment).

And lastly, since Perl scripts don't have to be compiled, but do have to be executable, I make sure that it is executable whenever I write the buffer by doing:
!chmod +x %
! - signifies to run this in a shell
chmod +x - duh
% - the current filename

Here are some other cool filename manipulations that might help you tear apart some of the stuff in the first post:
%< - the current filename minus any extension
%<.foo - will replace .foo for the filename's current extension

Strike
10-13-2000, 05:43 PM
Have I mentioned how much I love vim? http://www.linuxnewbie.org/ubb/biggrin.gif

Hey, kmj, get in here with some cool config'ing goodness! I'm sure you've got a whole bunch of cool keymappings you can unload on us http://www.linuxnewbie.org/ubb/smile.gif I remember you had a few, but here would be a good thread to consolidate all this stuff, methinks.

Strike
10-13-2000, 06:45 PM
Wow, I must be bored, replying to my own post so much http://www.linuxnewbie.org/ubb/smile.gif

Just for you guys' info, I've started an NHF on this now.

kmj
10-14-2000, 02:49 AM
Word... I bow before the power. I'm gonna steal alot of that rc file, I think. It's 3am, I'm drunk, and I'll be back. I'll post m y simple macros for setting up one button toggling of search-hilighting and set nu and stuff. Simple things. May not get back til mon. Thanks for the sweet configs Strike...

Strike
10-14-2000, 03:50 AM
Ha, even Old Man Alcohol can't keep kmj from the power of vim http://www.linuxnewbie.org/ubb/smile.gif

Here (http://www.geocities.com/djdipaolo/CustomizingVim-NHF.txt) is that NHF I was talking about, pre-HTML and all that. Tell me what you all think.

---edit---
oops on the link, it's fixed now

[This message has been edited by Strike (edited 14 October 2000).]

kmj
10-14-2000, 04:32 PM
Wow, M18 is Beau-T-ful!

That's alot of info, Strike, looks like I'm gonna learn alot. I noticed in one of your macros you used ^[; is that Escape? You can also use <Esc>; likewise, you can use <Fx> to mean Fx, <Home> to mean home, etc.


I just picked up the O'reilly sed & awk book and make book. I checked out the vim pocket reference and was pleasantly suprised to note that I already knew most of it. http://www.linuxnewbie.org/ubb/smile.gif

TheLinuxDuck
10-14-2000, 11:32 PM
Strike:

Dood, that is some super fly super funky super qool shizzit!

So far I added the first part of your post (up to autocmd!). I noticed that no matter what I set tabstop to, the smartindent still goes out 8 chars. Me no like.. me no like 8 char tabs for code indenting. So, I removed that.. that's for the better, anyway, because I don't the code to autoindent. I like to manually take care of it, so I always will keep tabs on what I'm doing.

As for the stuff for perl scripts, here's the thing. I almost never name my perl stuff as .pl.. I don't really see a point, since all my perl scripts are in a directory called perl.. And, besides, I am lazy, and don't want to have to type in .pl every time I run a script.. http://www.linuxnewbie.org/ubb/wink.gif Is there anyway to set the BufWrite to check for #!/usr/bin/perl at the beginning of the file, and then have it execute the chmod command? That would be guh-roovy.

Also, the syntax on line doesn't seem to work for me. I have to go tell it (on the mountain) after it's loaded. http://www.linuxnewbie.org/ubb/frown.gif Me no like.

Dood, this really taught me a lot, so thanks for the time and biz and such. http://www.linuxnewbie.org/ubb/smile.gif

Poo... on a biscuit

------------------
TheLinuxDuck
Wait... that's a penguin?!?!?
:wq

Strike
10-15-2000, 12:19 AM
What version of vim are you using? Anything past 5.0 should support syntax highlighting. Did you compile it yourself? You may have to enable syntax highlighting there.

wait ... it works when you use it at the command prompt for vim? try putting this in you .vimrc:


" Only do this for Vim version 5.0 and later.
if version >= 500

if has("terminfo")
set t_Co=8
set t_Sf=^[[3%p1%dm
set t_Sb=^[[4%p1%dm
else
set t_Co=8
set t_Sf=^[[3%dm
set t_Sb=^[[4%dm
endif

endif



As far as the perl stuff goes, you might be able to have it check for that (I don't know of any easy way how), but you also might be able to put that directory you wanted instead of *.pl, like /my/perl/stuff/* or whatever in place of *.pl. I don't know if that would work or not, but it's worth a shot.

kmj
10-15-2000, 11:50 AM
The cindent uses shiftwidth, not tabstop; so do a set sw=4 (or whatever), and see how that works. Soon you'll be doing missionary work LD http://www.linuxnewbie.org/ubb/smile.gif

kmj
10-15-2000, 11:54 AM
trust me, use cindent for a day (after you have it all set up), and you will never go back; it actually helps you keep track of things, because if you forget to close your parenthises (or something) the indenting will get all screwed up...

TheLinuxDuck
10-15-2000, 01:24 PM
Originally posted by Strike:
wait ... it works when you use it at the command prompt for vim? try putting this in you .vimrc:

When I added that data, the ansi codes stopped working on vim. Very strange. http://www.linuxnewbie.org/ubb/wink.gif I'm going to try adding that line to the BufRead and BufNewFile command files. Maybe it will work there.. http://www.linuxnewbie.org/ubb/wink.gif

able to put that directory you wanted instead of *.pl, like /my/perl/stuff/* or whatever in place of *.pl.[/B]

It works.. http://www.linuxnewbie.org/ubb/smile.gif Very nicely as well.. I'm really enjoying this! So far, here's what I've put into my ~/.vimrc:

set tabstop=2 " tabs are 2 spaces
set bs=2 " backspace over anything in insert mode
set sw=2 " setwidth for cindent
set smartindent " does C-style stuff
set mousehide " hides mouse after characters are typed
set mousefocus " no real reason for this
set mouse=a " mouse in all modes
set mousem=popup " Right button - menu, shift-left - extend selection
set autowrite " writes on make and shell commands, etc
set ruler " Turn the ruler on
set nohlsearch " Highlighting found search items is annoying
set nocompatible " vi compatibility is weak, disable it
set suffixes=.bak,~,.o,.info,.swp,.aux,.bbl,.blg,.dvi, .lof,.log,.lot,.ps,.toc
autocmd!
" Perl autocmds
autocmd BufNewFile ~/perl/* 0r ~/.vim-files/skeletons/skel.perl
autocmd BufWrite ~/perl/* !chmod +x %


Tabstop, me like.. http://www.linuxnewbie.org/ubb/wink.gif I don't like long tabs.. they seem a waste of space to me.. ::heh heh:: I also LOVE the bs=2 command.. oh dood, you don't know how much I hated it before!!!!

Alot of the mouse stuff, I haven't messed with or seen any difference, only because I don't use the mouse in it..
What is the ruler? I don't think I've even noticed it..
What does the suffix list do?

Man o man, this is quite a learning experience. ::heh heh::

------------------
TheLinuxDuck
Wait... that's a penguin?!?!?
:wq

TheLinuxDuck
10-15-2000, 01:27 PM
Originally posted by kmj:
trust me, use cindent for a day (after you have it all set up), and you will never go back; it actually helps you keep track of things, because if you forget to close your parenthises (or something) the indenting will get all screwed up...

Alright, Mr mj.. I will try it for a little bit of time.. to remain true to my attitude of trying new things.. http://www.linuxnewbie.org/ubb/wink.gif

Also, I added the sw=2 command into the .vimrc file, and it works nicely with the autoindent. http://www.linuxnewbie.org/ubb/wink.gif

Now, I haven't really done any semi-serious C coding in a while, since being involved in perl so much, but I would imagine that these tabbings and such carry over..

Are you going to post some of your mappings?

------------------
TheLinuxDuck
Wait... that's a penguin?!?!?
:wq

kmj
10-15-2000, 04:19 PM
I don't really have anything setup at home; I played with most of the stuff at work. I will post some things on monday, but not much. Strike's will put mine to shame... Still, I've got a bit.


Right now I'm listening to "in the air tonight" Tupac vs. Phil Collins. Frikkin weird; someone overlayed one of tupak's songs with "in the air tonight". Interesting...
(i don't know if it's a c or k, so I covered all my bases. http://www.linuxnewbie.org/ubb/smile.gif)

btw, LD, you may want to check out kguitar at freshmeat.net; I noticed it when I went to get the latest XMMS. You're interested in that stuff, aren't you? I don't know if it's what you're looking for, but it's in the realm...

larryliberty
10-15-2000, 05:50 PM
I'm very much looking forward to seeing the finished NHF. I like vi, but :help doesn't (unless you already know the answer, but just forgot).

Larry


------------------
Democracy: Two wolves and a lamb deciding what to have for dinner.
Constitutional Republic: Same as above, but lamb's not on the menu (unless the wolves are really hungry).

TheLinuxDuck
10-15-2000, 07:44 PM
Originally posted by kmj:
I don't really have anything setup at home; I played with most of the stuff at work. I will post some things on monday, but not much. Strike's will put mine to shame... Still, I've got a bit.[/quot]

Qool.. I still have a couple at work that you gave me before.. http://www.linuxnewbie.org/ubb/wink.gif


[quote]btw, LD, you may want to check out kguitar at freshmeat.net; I noticed it when I went to get the latest XMMS. You're interested in that stuff, aren't you? I don't know if it's what you're looking for, but it's in the realm...


I'll have to go take a look at it. http://www.linuxnewbie.org/ubb/smile.gif Thanks for the info..

------------------
TheLinuxDuck
Wait... that's a penguin?!?!?
:wq

Strike
10-15-2000, 07:59 PM
Originally posted by larryliberty:
I'm very much looking forward to seeing the finished NHF. I like vi, but :help doesn't (unless you already know the answer, but just forgot).

Larry



Actually, you'd be surprised at what you got if you just put in some related topic. Like if you want to know what keystrokes move through the text are, ":help motion" will help you. And if you ever see anything between two pipe's (|like-this|), you can just say ":help like-this" and it will take you to that separate section.

I don't remember what it was about cindent that I didn't like so much, but I remember not liking it. Maybe I'll give it another shot now that I'm becoming a total vim-o-phile.

kmj
10-15-2000, 08:22 PM
It took me a little to figure out that it was shiftwidth I had to adjust, not tabstop... To get the most out of cindent, you have to adjust cinoptions to your likings.

kmj
10-16-2000, 09:13 AM
set nohlsearch
let hlsearch_on=0
map <F7> :if hlsearch_on <Bar> set nohlsearch <Bar>let hlsearch_on=0 <Bar> else <Bar> set hlsearch <Bar> let hlsearch_on=1 <Bar> endif <CR> <CR>
let line_numbers=0
map <F8> :if line_numbers <Bar> set nonu <Bar> let line_numbers=0 <Bar> else <Bar> set nu <Bar> let line_numbers=1 <Bar> endif <CR> <CR>


...I hope that comes out ok. I'm positive that they can be done on multiple lines, if you were to type as vim commands, you'd use a | where I have <Bar>; Those are the places where line breaks should be. I haven't tried, but I should, just so it doesn't look so craptacular. The first toggles the "highlight search match" on and off, the second toggles line numbers. This also demonstrates creating and using variables.

[This message has been edited by kmj (edited 16 October 2000).]

kmj
10-16-2000, 09:15 AM
hmm. both of those map lines should all be one line. you could try just pasting them into your .vimrc and seeing if they work. If not, let me know, but they should. They work for me. Obviously, this type of thing could be done for basically any on/off thing in vim.

Edit: changed the "quote" tags to "code" so it looks better. I use :set nowrap, so long lines don't bother me too much. all the same, I should fix that....

[This message has been edited by kmj (edited 16 October 2000).]

kmj
10-16-2000, 03:23 PM
Here's a macro (http://www.linuxnewbie.org/ubb/Forum14/HTML/001282.html) I posted a while ago. For when you've got a bunch of mixed-case words that you want to change to all uppercase...

kmj
10-17-2000, 10:45 AM
You should be careful with autowrite. I keep it turned off, since I don't like ctags to write files for me. Course, I don't make much use of quick compile, or shell escapes.

kmj
10-18-2000, 09:25 AM
If you're using cindent, and you happen to copy and paste a bunch of code from one place to another, try pressing highlighting (with visual mode) the range of pasted text and pressing '='. This will cause all that text to move to it's proper cindent position automagically.

TheLinuxDuck
10-18-2000, 09:54 AM
Originally posted by kmj:
If you're using cindent, and you happen
to copy and paste a bunch of code from one
place to another, try pressing highlighting
(with visual mode) the range of pasted text
and pressing '='. This will cause all that
text to move to it's proper cindent position
automagically.

ERr.. I'm going to ask a dumb question... how do I highlight text with visual mode?

I don't think I've ever even been in visual mode..

::sigh:: NEWBIE ALERT! NEWBIE ALERT!!

------------------
TheLinuxDuck
Wait... that's a penguin?!?!?
:wq

kmj
10-18-2000, 10:02 AM
No prob; just press 'v'. Then any of the movement keys. v3j highlights three lines down; vG highlights from current line to the end of the file; v0 highlights from cursor to beginning of line; 'V' is the same, but only highlights entire lines. Then you can use d,D,y,orY to grap/cut that text. I think Vy and vY have the same effect. (also true for vD and Vd.) One highlights then yanks/cuts entire line, while the other highlights entire line then yanks/cuts.

(I hope I'm not being cryptic; there's quite a bit you can do with this; makes things easier sometimes.)

With =, you could probably just do like 4= and that would indent the next four lines, I haven't tried.

EyesWideOpen
10-18-2000, 10:03 AM
Originally posted by TheLinuxDuck:
ERr.. I'm going to ask a dumb question... how do I highlight text with visual mode?

I don't think I've ever even been in visual mode..

::sigh:: NEWBIE ALERT! NEWBIE ALERT!!


The command set smd(I have this in my .vimrc file) will display the mode in the status bar at the bottom of the window. This will let you know whether your in INSERT-, VISUAL-, VISUAL LINE-mode, etc.

I believe that whenever you highlight text, whether dragging over text to highlight or double-clicking, then you are in VISUAL mode.

------------------
"Ford," he said, "you're turning into a penguin. Stop it."
~ THGTTG

[This message has been edited by EyesWideOpen (edited 18 October 2000).]

kmj
10-18-2000, 11:15 AM
EWO: I don't know about the linux version, but in windows, when you highlight text, it becomes "SELECT" mode. Here, if you press any button while highlighted, the highlighted text is deleted and substituted with the character pressed. I think this may have something to do with the file mswin.vim that comes with the windows version, which sets some bindings up to be similar to windows-style editing.

LD: I was wrong about 4=, you'd have to do 4=j (or down_arrow) or =4j. They both work. (this makes sense, since = want to know which direction to go.)

TheLinuxDuck
10-18-2000, 03:35 PM
Originally posted by kmj:
No prob; just press 'v'. Then any of the movement keys. v3j highlights three lines down; vG highlights from current line to the end of the file; v0 highlights from cursor to beginning of line; 'V' is the same, but only highlights entire lines. Then you can use d,D,y,orY to grap/cut that text. I think Vy and vY have the same effect. (also true for vD and Vd.) One highlights then yanks/cuts entire line, while the other highlights entire line then yanks/cuts.

That wasn't cryptic at all! Mucho good! See, I had heard of visual mode, but hadn't ever used it before.. http://www.linuxnewbie.org/ubb/wink.gif

Ok, I have another question for you, then. Is there any way to determine how = does what it does in visual mode?

You see, I don't like using tabs in source code. Even with setting the tab to 2 in vim, I still don't like it (because externally, it is still an 8-space tab). Is there anyway that I can tell = to use 2 spaces instead of tabs? Me no like tabs.

Originally posted by EyesWideOpen:
The command set smd(I have this in my .vimrc file) will display the mode in the status bar at the bottom of the window. This will let you know whether your in INSERT-, VISUAL-, VISUAL LINE-mode, etc.

Odd.. mine has been doing that, even without the smd command. I like it to tell me what mode it's in, because I'm dumb and forget otherwise.

I'm going to have to get used to using visual mode. http://www.linuxnewbie.org/ubb/wink.gif

------------------
TheLinuxDuck
Wait... that's a penguin?!?!?
:wq

kmj
10-18-2000, 03:42 PM
That's something I need to look into. Have you tried setting sw to 2? cindent uses sw, not tabstops. The =, I think for each line, determines what the indenting should be based on how your cinoptions are setup. Getting these to be exactly how you like them may take a little time, but it pays off in convenience.

Strike
10-18-2000, 05:04 PM
Yeah, visual mode is pretty slick. Don't forget that you can do regex search and replace stuff within a visual-mode selected text block (highlight the block and then hit :, from there just do s/foo/bar/g to do a global replacement of foo with bar - the prepended stuff is automatically put in).

TLD, don't forget, you can remap any key you want. Even standard vim keys if you want (I just tested mapping h to l and sure enough, I had no right-arrow after that http://www.linuxnewbie.org/ubb/biggrin.gif).

TheLinuxDuck
10-18-2000, 05:07 PM
Originally posted by Strike:
TLD, don't forget, you can remap any key you want. Even standard vim keys if you want (I just tested mapping h to l and sure enough, I had no right-arrow after that http://www.linuxnewbie.org/ubb/biggrin.gif).

Does that mean that I could remap my tab to be two spaces? Would this affect files that already have a tab in them?

How would I go about remapping it thusly?

------------------
TheLinuxDuck
Wait... that's a penguin?!?!?
:wq

kmj
10-18-2000, 09:53 PM
try typing :imap <tab> <space><space>

see how that works for you.


Duh, I can't believe my dumbass didn't think of that.

Strike
10-18-2000, 10:35 PM
Originally posted by kmj:
Duh, I can't believe my dumbass didn't think of that.
Yeah, shame on you. I relieve you of your vim-superuser status. http://www.linuxnewbie.org/ubb/smile.gif

Nah, I've just been getting pretty creative into customizing vim, so I'm not afraid to try anything or read any help file.

kmj
10-19-2000, 03:31 PM
Did that work for you LD?

Originally posted by Strike:
Yeah, shame on you. I relieve you of your vim-superuser status. http://www.linuxnewbie.org/ubb/smile.gif

I've got a ways to go, man... I just know enough to fake it right now.


Nah, I've just been getting pretty creative into customizing vim, so I'm not afraid to try anything or read any help file.

I've been creative when it comes to interactive use, trying to pick up as many commands as possible, and working on macro and regex skill, but I've been too lazy to work out a good rc file. For example, I've got my rc set up so that my background is transparent (so it's the same as the term it's in), but the background behind the characters is still black! I haven't bothered to fix it yet. Stuff like that. Plus my vimrc can't handle indenting for anything except C/C++ yet. I'm lazy.

kmj
10-19-2000, 03:38 PM
Holy magic! I make a post and suddenly, Strike's a HAL! I've got the touch.

TheLinuxDuck
10-19-2000, 04:00 PM
Originally posted by kmj:
Did that work for you LD?

Yeppers!! I am really starting to like vim!! http://www.linuxnewbie.org/ubb/smile.gif Ok, how about this..

How do I replace the tabs in source code I edit to two spaces?
I tried:

:s/<tab>/ /g
:s/\t/ /g
:s/^I/ /g

Me don't know.
Me confused.
Me like vim.
Me likes word me.
Sounds like yoda, me do.

------------------
TheLinuxDuck
Wait... that's a penguin?!?!?
:wq

kmj
10-19-2000, 04:07 PM
If you don't give it a range, it will only work on the current line...

try:
: % s/.../.../... (all lines in file)
: .,$ ... (current line to end of file)
: .,+X ... (current line, and the next X lines)
: a,b ... (line a through line b)


That programming with vim NHF should have this stuff in it, I think. It was one of the things that took me forever to find good information on.

Edit: btw, it's \t that you want to use.


[This message has been edited by kmj (edited 19 October 2000).]

Strike
10-20-2000, 04:53 AM
Originally posted by kmj:
Holy magic! I make a post and suddenly, Strike's a HAL! I've got the touch.
::hallelujah chorus plays in the background::
yeah, who knows where that came from? http://www.linuxnewbie.org/ubb/wink.gif j/k, Sensei offered me the status a while back and I decided to take him up on it today

TheLinuxDuck
10-20-2000, 10:41 AM
Originally posted by Strike:
Sensei offered me the status a while back and I decided to take him up on it today


http://www.linuxnewbie.org/ubb/smile.gif well, good sir, you're certainly worthy! http://www.linuxnewbie.org/ubb/smile.gif

------------------
TheLinuxDuck
Wait... that's a penguin?!?!?
:wq

kmj
10-20-2000, 12:27 PM
Hey, you wanna see something cool? type
:h todo

that's awesome.