On Tuesday, June 23, 2015 at 3:35:50 PM UTC-5, Ben Fritz wrote:
> I'm working on a custom command to add strikethrough to text, using the Unicode COMBINING LONG STROKE OVERLAY, 0x0336.
>
> In this command, I want to apply a strikethrough to a character, only if it is not already present.
>
> This pattern fails because it doesn't match *anything* with regexpengine set to 2, it does not match an unadorned character immediately before a struck-through base character, and it *does* match the last combining character in a word for some reason:
>
> [^\u0336]\%u0336\@!
>
> This pattern also fails, because it matches already struck-through base characters for some reason (although it does the same thing in both engines):
>
> [^\u0336][^\u0336]\@=
>
> What is the correct way to do this?
>
> Full command (attempted):
>
> '<,'>s;\%#=1\%V[^\u0336]\%u0336\@!;\=submatch(0)."\u0336";g
>
> Note, how I'm also limiting to a visual selection; so I'm trying to use the :s command for simplicity.
My next attempt is to do two passes, first to remove the combining character from everywhere in the visual selection, and then to add it to the entire visual selection.
But, my patterns for this task either don't match at all, or they remove the base character along with the combining character! Even this doesn't work, it removes the base character:
echo join(split(getline('.'), "\u0336"),"")
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Tuesday, June 23, 2015
Search for character that doesn't have a combining character?
I'm working on a custom command to add strikethrough to text, using the Unicode COMBINING LONG STROKE OVERLAY, 0x0336.
In this command, I want to apply a strikethrough to a character, only if it is not already present.
This pattern fails because it doesn't match *anything* with regexpengine set to 2, it does not match an unadorned character immediately before a struck-through base character, and it *does* match the last combining character in a word for some reason:
[^\u0336]\%u0336\@!
This pattern also fails, because it matches already struck-through base characters for some reason (although it does the same thing in both engines):
[^\u0336][^\u0336]\@=
What is the correct way to do this?
Full command (attempted):
'<,'>s;\%#=1\%V[^\u0336]\%u0336\@!;\=submatch(0)."\u0336";g
Note, how I'm also limiting to a visual selection; so I'm trying to use the :s command for simplicity.
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
In this command, I want to apply a strikethrough to a character, only if it is not already present.
This pattern fails because it doesn't match *anything* with regexpengine set to 2, it does not match an unadorned character immediately before a struck-through base character, and it *does* match the last combining character in a word for some reason:
[^\u0336]\%u0336\@!
This pattern also fails, because it matches already struck-through base characters for some reason (although it does the same thing in both engines):
[^\u0336][^\u0336]\@=
What is the correct way to do this?
Full command (attempted):
'<,'>s;\%#=1\%V[^\u0336]\%u0336\@!;\=submatch(0)."\u0336";g
Note, how I'm also limiting to a visual selection; so I'm trying to use the :s command for simplicity.
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Re: vim replace a string when a change occurred in another place
Erik,
Thanks for your detailed answer. I have choose python (so that it can be called from vim's ftplugin.)
I have checked the standalone python code, which works. But, I put the python code inside vim as:
function! Edname()
python<<EOF
import vim
import fileinput
with open("i.f90") as inp:
for line in inp:
if line.startswith("Program"):
var = line.rsplit(' ', 1)[-1].strip()
if line.startswith("End Program"):
v2 = line.strip()
print v2
inp.close()
STR="End Program "+var
print STR
for line in fileinput.input("i.f90", inplace=True):
print line.replace(v2, STR).strip()
EOF
endfunction
Now it is not working. It is printing the v2 and STR properly, but the file is NOT getting updated.
Any clue?
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thanks for your detailed answer. I have choose python (so that it can be called from vim's ftplugin.)
I have checked the standalone python code, which works. But, I put the python code inside vim as:
function! Edname()
python<<EOF
import vim
import fileinput
with open("i.f90") as inp:
for line in inp:
if line.startswith("Program"):
var = line.rsplit(' ', 1)[-1].strip()
if line.startswith("End Program"):
v2 = line.strip()
print v2
inp.close()
STR="End Program "+var
print STR
for line in fileinput.input("i.f90", inplace=True):
print line.replace(v2, STR).strip()
EOF
endfunction
Now it is not working. It is printing the v2 and STR properly, but the file is NOT getting updated.
Any clue?
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Re: vim replace a string when a change occurred in another place
On 23.06.15 03:52, Rudra Banerjee wrote:
> Say, I have a file:
> Program bar
> <program text>
> End Program bar
>
> Is it possible that if I change the word "foo" in the first line to
> "bar" (which may not be the first line of the file), the last line's
> "foo" will also be changed to "bar" automatically?
From the shorter repost, I assume there were no replies to the longer
one, so I'll venture the simple semi-automatic method I use:
1) Place cursor on the first "foo", and hit '*'.
2) We're now on the second. Type "cebar<Esc>" to replace with bar.
3) Type "N." to replicate the replacement on the first.
Since the first and second steps (target identification and
replacement), remain manual input in even an automated method, the cost
of a manual "N." for repetition is so low that striving for full
automation seems low. After all, what is the worth of full automation of
2foo when the next use case involves 3foo?
That said, if you hit 'qa' beforehand, perform the above, then 'q',
followed by '"np' , then we can see that we have full automation in
register 'a':
*cebar N.
That could be reused on another target other than "foo", but it is
perhaps too automated, because the replacement text should doubtless
then differ.
My preferred solution for automated consistency enforcement would be a
couple of lines of awk, since that is an efficient text processing tool,
while vim is a text editor. E.g.:
$ cat /tmp/text
Program bar
<program text>
End Program foo
Program far
<program text>
End Program boo
erik@ratatosk:~$ gawk '/^[^End]+Program/ {tgt = $2}
/^ *End *Program/ {$3 = tgt} {print}' /tmp/text
Program bar
<program text>
End Program bar
Program far
<program text>
End Program far
For the given syntax, it'll reform a file of any length, in one step.
Add " > /some/file" to capture the output. Put it in a bash script
with a following overwrite of the original file if that's desired.
It's "horses for courses", I suggest. (And every step pretty simple)
Erik
--
I have long felt that most computers today do not use electricity.
They instead seem to be powered by the "pumping" motion of the mouse!
- William Shotts, Jr. on http://linuxcommand.org/learning_the_shell.ph
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
> Say, I have a file:
> Program bar
> <program text>
> End Program bar
>
> Is it possible that if I change the word "foo" in the first line to
> "bar" (which may not be the first line of the file), the last line's
> "foo" will also be changed to "bar" automatically?
From the shorter repost, I assume there were no replies to the longer
one, so I'll venture the simple semi-automatic method I use:
1) Place cursor on the first "foo", and hit '*'.
2) We're now on the second. Type "cebar<Esc>" to replace with bar.
3) Type "N." to replicate the replacement on the first.
Since the first and second steps (target identification and
replacement), remain manual input in even an automated method, the cost
of a manual "N." for repetition is so low that striving for full
automation seems low. After all, what is the worth of full automation of
2foo when the next use case involves 3foo?
That said, if you hit 'qa' beforehand, perform the above, then 'q',
followed by '"np' , then we can see that we have full automation in
register 'a':
*cebar N.
That could be reused on another target other than "foo", but it is
perhaps too automated, because the replacement text should doubtless
then differ.
My preferred solution for automated consistency enforcement would be a
couple of lines of awk, since that is an efficient text processing tool,
while vim is a text editor. E.g.:
$ cat /tmp/text
Program bar
<program text>
End Program foo
Program far
<program text>
End Program boo
erik@ratatosk:~$ gawk '/^[^End]+Program/ {tgt = $2}
/^ *End *Program/ {$3 = tgt} {print}' /tmp/text
Program bar
<program text>
End Program bar
Program far
<program text>
End Program far
For the given syntax, it'll reform a file of any length, in one step.
Add " > /some/file" to capture the output. Put it in a bash script
with a following overwrite of the original file if that's desired.
It's "horses for courses", I suggest. (And every step pretty simple)
Erik
--
I have long felt that most computers today do not use electricity.
They instead seem to be powered by the "pumping" motion of the mouse!
- William Shotts, Jr. on http://linuxcommand.org/learning_the_shell.ph
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
vim replace a string when a change occurred in another place
Hi,
Say, I have a file:
Program foo
<program text>
End Program foo
Is it possible that if I change the word "foo" in the first line to "bar" (which may not be the first line of the file), the last line's "foo" will also be changed to "bar" automatically?
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Say, I have a file:
Program foo
<program text>
End Program foo
Is it possible that if I change the word "foo" in the first line to "bar" (which may not be the first line of the file), the last line's "foo" will also be changed to "bar" automatically?
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
encoding termencoding problem
Hi,
I have set my encoding features in _vimrc in utf-8 and notice that I some hexa codes are displayed when I use Vim to yank or copy lines:
It says that "<e9> yanked lines".
CAn you help me to
My vimrc
if has("multi_byte")
set termencoding=utf-8
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
"setglobal bomb
endif
I
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I have set my encoding features in _vimrc in utf-8 and notice that I some hexa codes are displayed when I use Vim to yank or copy lines:
It says that "<e9> yanked lines".
CAn you help me to
My vimrc
if has("multi_byte")
set termencoding=utf-8
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
"setglobal bomb
endif
I
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Monday, June 22, 2015
Help with errorformat for Android/Gradle output
When developing Android applications with AndroidAnotations to auto-generate classes and with gradle as build system it is common to get errors like these:
/home/ryujin/Projects/KidInt/kidint-android/src/main/java/com/kidint/app/ChildResourceGridActivity.java:16: error: cannot find symbol
import com.kidint.app.adapter.ChildResourceAdapter_;
^
location: package com.kidint.app.adapter
/home/ryujin/Projects/KidInt/kidint-android/src/main/java/com/kidint/app/BookDetailActivity.java:18: error: cannot find symbol
import com.kidint.app.util.ChildResourceData_;
^
location: package com.kidint.app.util
/home/ryujin/Projects/KidInt/kidint-android/src/main/java/com/kidint/app/BookDetailActivity.java:25: error: cannot find symbol
import com.kidint.app.service.KidIntService_;
^
location: package com.kidint.app.service
/home/ryujin/Projects/KidInt/kidint-android/src/main/java/com/kidint/app/BookDetailActivity.java:26: error: cannot find symbol
import com.kidint.app.service.KidIntBookService_;
^
location: package com.kidint.app.service
/home/ryujin/Projects/KidInt/kidint-android/src/main/java/com/kidint/app/BookDetailActivity.java:27: error: cannot find symbol
import com.kidint.app.service.KidIntQuestionService_;
^
location: package com.kidint.app.service
/home/ryujin/Projects/KidInt/kidint-android/src/main/java/com/kidint/app/LoginFragment.java:34: error: cannot find symbol
import com.kidint.app.service.KidIntService_;
^
location: package com.kidint.app.service
/home/ryujin/Projects/KidInt/kidint-android/src/main/java/com/kidint/app/LoginFragment.java:60: error: cannot find symbol
@EFrgment(R.layout.kidint_login)
^
symbol: class EFrgment
/home/ryujin/Projects/KidInt/kidint-android/src/main/java/com/kidint/app/StatisticsFragment.java:29: error: cannot find symbol
import com.kidint.app.adapter.BookProfileRecyclerAdapter_;
^
location: package com.kidint.app.adapter
Experienced developers immediately can recognize that the only valid error above is the typo for the @EFragmet annotation and that all other errors are simply consequences of this single one.
The errorformat I use in vim is able to catch all these errors that results in a huge list in the quickfix window. I would really like to add a pattern to my errorformat to filter out all errors related to AndroidAnnotaions auto-generated classes (those that end with _).
My current errorformat:
CompilerSet errorformat=\%W%f:%l:\ %tarning:\ %m,%Z%p%*[%^~],%+C%.%#,
\%E%f:%l:\ %trror:\ %m,%Z%p%*[%^~],%+C%.%#,
\%-G%.%#
I tried adding variations of the same pattern to remove the ones I do not want but it did not work. These are some examples of patterns I have used without success since they tend to remove all messages, including those that are valid errors:
1. \%-E%f:%l:\ %trror:\ %m,%Z%p^,%+C%.%#_,
2. \%-E%f:%l:\ %trror:\ %m_,%Z%p^,
3. \%-E%f:%l:\ %trror:\ %m,%Z%p^%.%#_,
4. \%-E%f:%l:\ %trror:\ %m,%Z%p^%.%#%*[_],
NOTE: I added these patters as the first one my multi patter errorformat. The whole pattern I use can be found on my [vim-android plugin][1]
[1]: https://github.com/hsanson/vim-android/blob/master/compiler/gradle.vim#L12
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
/home/ryujin/Projects/KidInt/kidint-android/src/main/java/com/kidint/app/ChildResourceGridActivity.java:16: error: cannot find symbol
import com.kidint.app.adapter.ChildResourceAdapter_;
^
location: package com.kidint.app.adapter
/home/ryujin/Projects/KidInt/kidint-android/src/main/java/com/kidint/app/BookDetailActivity.java:18: error: cannot find symbol
import com.kidint.app.util.ChildResourceData_;
^
location: package com.kidint.app.util
/home/ryujin/Projects/KidInt/kidint-android/src/main/java/com/kidint/app/BookDetailActivity.java:25: error: cannot find symbol
import com.kidint.app.service.KidIntService_;
^
location: package com.kidint.app.service
/home/ryujin/Projects/KidInt/kidint-android/src/main/java/com/kidint/app/BookDetailActivity.java:26: error: cannot find symbol
import com.kidint.app.service.KidIntBookService_;
^
location: package com.kidint.app.service
/home/ryujin/Projects/KidInt/kidint-android/src/main/java/com/kidint/app/BookDetailActivity.java:27: error: cannot find symbol
import com.kidint.app.service.KidIntQuestionService_;
^
location: package com.kidint.app.service
/home/ryujin/Projects/KidInt/kidint-android/src/main/java/com/kidint/app/LoginFragment.java:34: error: cannot find symbol
import com.kidint.app.service.KidIntService_;
^
location: package com.kidint.app.service
/home/ryujin/Projects/KidInt/kidint-android/src/main/java/com/kidint/app/LoginFragment.java:60: error: cannot find symbol
@EFrgment(R.layout.kidint_login)
^
symbol: class EFrgment
/home/ryujin/Projects/KidInt/kidint-android/src/main/java/com/kidint/app/StatisticsFragment.java:29: error: cannot find symbol
import com.kidint.app.adapter.BookProfileRecyclerAdapter_;
^
location: package com.kidint.app.adapter
Experienced developers immediately can recognize that the only valid error above is the typo for the @EFragmet annotation and that all other errors are simply consequences of this single one.
The errorformat I use in vim is able to catch all these errors that results in a huge list in the quickfix window. I would really like to add a pattern to my errorformat to filter out all errors related to AndroidAnnotaions auto-generated classes (those that end with _).
My current errorformat:
CompilerSet errorformat=\%W%f:%l:\ %tarning:\ %m,%Z%p%*[%^~],%+C%.%#,
\%E%f:%l:\ %trror:\ %m,%Z%p%*[%^~],%+C%.%#,
\%-G%.%#
I tried adding variations of the same pattern to remove the ones I do not want but it did not work. These are some examples of patterns I have used without success since they tend to remove all messages, including those that are valid errors:
1. \%-E%f:%l:\ %trror:\ %m,%Z%p^,%+C%.%#_,
2. \%-E%f:%l:\ %trror:\ %m_,%Z%p^,
3. \%-E%f:%l:\ %trror:\ %m,%Z%p^%.%#_,
4. \%-E%f:%l:\ %trror:\ %m,%Z%p^%.%#%*[_],
NOTE: I added these patters as the first one my multi patter errorformat. The whole pattern I use can be found on my [vim-android plugin][1]
[1]: https://github.com/hsanson/vim-android/blob/master/compiler/gradle.vim#L12
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Posts (Atom)