« first day (290 days earlier)      last day (1521 days later) » 

5:10 PM
So I recently posted this answer on SO:
4
A: How do you yank between two different symbols in vim?

DJMcMayhemYou can define your own text object like this: onoremap I :exec 'norm vT'.nr2char(getchar()).'ot'.nr2char(getchar())<cr> Then, to do your example, you would type yI<space>" The mnemonic I think of is "(d)elete (I)nbetween <char 1>, <char 2>". Thankfully, I cannot be used as an argument to a...

And it made me realize that there aren't really any custom text-objects in V, although there's plenty of room for them (since it has it's own mode, we wouldn't have to worry about overwriting other operators)
So does anyone have ideas for new text objects to add?
I think whole-buffer (blockwise and linewise) would be two good ones
Current-line could be useful too
Maybe current-column? Not sure if that would would be as useful
Hi Downgoat!
 
> onoremap
ono! :P
@DJMcMayhem hello
@DJMcMayhem is iW (like iw) a thing in vim already?
 
Yeah.
Each text object has i and a too
 
oh, what does aw do then?
 
It grabs the characters around the word boundaries
 
oh so goat dow|ngoat goat where | represents cursor. doing daw would give me " downgoat " (with spaces)?
TIL :D
 
5:23 PM
It would be nice to add a text object for between/around chars. So for example y<M-i>w would Yank between two occurrences of 'w'
And like I said, since onoremap is different than nnoremap, we don't have to worry about overwriting <M-i>
 
@DJMcMayhem <M-i> is two bytes, right? could you not do like yàw?
sorry, if stupid question >_>
 
Nah, not a stupid question. :)
<M-i> is the vim-key description/mnemonic for é. You type it with alt-i
Jan 25 at 7:08, by DJMcMayhem
New features: 1) verbose mode. If you pass the -v flag, you can use vim-key descriptions instead of unprintable characters.
That way, you can do <ESC> instead of getting the actual unprintable character. Same thing for all the non-ascii
@Downgoat Does that make sense?
 
ohhhhh
:( <M-i> doesn't do anything in my vim but that might just be mac
 
Yeah, kritixi had similar problems
They eventually figured out a workaround, but I don't remember what it was
 
Wait does SE convert <ESC> into <kbd> tag
 
5:31 PM
@Downgoat wait, did you do it from insert mode?
 
@DJMcMayhem I tried from insert and normal mode
 
Ok, just double checking
 
Apple has custom bindings for alt+key so probably happens at a lower level than vim
 
I think kritixi fixed it by switching terminals, but in the meantime, there is this workaround I came up with ages ago:
gist: 058d5cdf846fec42bf6b1ffeb8c0cfdd, 2016-12-10 16:22:29Z
function! Alt()
  let c = nr2char(getchar() + 128)
  exec 'normal gi'.c
endfunction

inoremap <C-i> <C-o>:call Alt()<cr>
Then, to type <M-i>, you would just do <C-i>i from insert.
 
meaning doing <C-i>i to enter insert mode?
btw @KritixiLithos did you switch to Terminal.app, iTerm, Hyperterm, or something else?
 
5:33 PM
XQuartz
 
@Downgoat No, entering insert is the same as before, it's just doing <C-i> tells vim the next key should be an alt-key.
 
ohhhh
 
Or that it should pretend it's an alt-key
 
nr2char converts char code to a char right?
 
Yup.
 
5:35 PM
One more question: can I open a tab with an empty buffer? :e requests a file name
@DJMcMayhem cool :D
 
For some idiotic reason, Bram thought it would be a good idea to have getchar return a number, not a char. Facepalm
@Downgoat A tab specifically? You can do tabedit with no filename, but to do e with no filename you want enew
 
oh ok, thanks
@DJMcMayhem so does vimscript have both number & string types, or is it like bash where numbers are technically strings
 
It has both, but it's kinda dumb about conversion
echo "123" + 1
 
are we talking JS-dumb?
 
124
@Downgoat vimscript is significantly worse than JavaScript. The only thing I like about it is that it lets me do cool things with vim. Other than that it's a horrible language with no redeeming features
 
5:40 PM
@DJMcMayhem >_____<
:normal 'i'.(1 + 1)
it says 'Mark not set' >_< am I doing a stupid
 
function! Foo(a)
  return a + a
endfunction
 
sorry if I'm bothering you with so many question >_<
 
@Downgoat Now, what would you expect echo Foo(2) to output?
 
@DJMcMayhem 4?
 
Yes, that's exactly what any sane language should do.
Error detected while processing function Foo:
line    1:
E121: Undefined variable: a
E15: Invalid expression: a + a
 
5:42 PM
O_____O
 
Seriously, you couldn't even make this crap up.
 
oh my halp
are they parsing vim script with potato wat ._.
O____o and it even returns zero
 
The correct version is:
function! Foo(a)
  return a:a + a:a
endfunction
 
And that's not even the worst feature I've found.
The worst feature it has is string comparison.
There are about 30 different operators for comparing strings, and all of the "regular ones" depend on user settings for case-sensitivity.
 
5:46 PM
idk if I want to know anymore >_>
> But vi programmers no longer need cast envious glances towards Emacs' parenthetical scripting language. Our favorite editor can be scripted too—and much more humanely than Emacs
> much more humanely
opls
 
@Downgoat So, for example, does :echo 'FOO' == 'foo' print true or false?
 
please tell me false
 
The answer is much worse than false.
The answer is sometimes.
 
actally not that weird maybe I just broke something
 
Every person who runs that will get a different result.
 
5:48 PM
what do you get?
 
I get true (technically '1', but same difference)
And you get 0.
 
I get 0
 
ok so macs get 0 and windows get 1?
 
No.
 
anyone know what echom is?
 
5:51 PM
@Downgoat It's not about OS, it's about the ignorecase setting
Which I have on because it's really useful
 
> E149: Sorry, no help for you because you are a goat
:(
@DJMcMayhem oh, maybe I should just steal your vimrc brb
@DJMcMayhem do you happen to know :normal 'ihello' says "Mark not set"?
SO leads to believe "Mark not set" means a syntax error is present but looks pretty simple to me
 
Ooooohhhh, I get it.
That's actually a funny error.
@Downgoat normal doesn't take a string. It's just the keystrokes directly. So it interprets the single quotes as part of your normal command
 
@Downgoat It's cause of the 's
 
'i in Normal mode means "jump to Mark 'i'"
 
@KritixiLithos can't tell if joke or serious <_>
 
6:04 PM
Serious. You want :normal iHello
 
:exec 'normal i'.(1+1) awww yiss this works :D
 
Do you understand what that does differently?
 
@DJMcMayhem my version and the one you mentioned?
 
No, your new one (with exec) and your old one
 
to my understanding exec executes vimscript string so it's like doing print "1+1" vs exec "print" + ( 1 + 1 )
 
6:08 PM
:normal 'i'.(1+1) means "Type 'i'.(1+1) like it was normal mode
:exec 'normal i'.(1+1) means "Evaluate 'normal i'.(1+1) as a string, and run it as vimscript"
'i'.(1+1) is clearly not something you want to type in normal mode
 
oh I see
btw is exec 'normal i'.string the best way to insert a string at the cursor?
 
Probably yeah.
There are two minor improvements and one potential problem
Will the string ever contain unprintable characters?
 
oh, if it has like <esc> char in the middle it will break?
 
Exactly.
One minor improvement is exec 'normal! i'.string
the ! makes it so any mappings are ignored.
So if someone had for example inoremap jk <esc> (like I do) then normal ihijklmnop will not work, but normal! ihijklmnop will.
 
oh, so if user did nnoremap i :echo 'IM NOT GOATTING INTO INSERT MODE' it would still work?
 
6:12 PM
Exactly
And if you call if from insert mode (like with <esc> or <C-o> somewhere in the mapping) then you should do gi instead of i
 
oh I see, the cursor looks like it goes back one column sometimes
is there a difference between :call func(args) and :exec func(args)?
 
Yes, but I couldn't explain it super well. >_<
Actually wait, I'm not sure what the difference is
 
looks like :exec executes the return value of the function
 
I thought exec getchar() would fail but it didn't
Wait, duh of course that happens
 
i have to goat, but thanks for taking time for vim lesson :P :)
 
6:17 PM
Anytime :)
@Downgoat call simply means "call func". exec means "evaluate func as a string and run it". So if "func" returns normal iHello, then exec func will insert hello
Exec ends up calling the function in the end, but that's because it has to call it to evaluate the expression
 

« first day (290 days earlier)      last day (1521 days later) »