I use vim to write a lot of text (mostly for research papers), and I recently start to format paragraphs and sentences like this:
Lorem ipsum dolor sit amet, consectetur adipiscing
elit sed diam et arcu scelerisque rutrum eget
vitae sed diam et arcu scelerisque rutrum eget
vitae sed diam et arcu scelerisque rutrum eget
vitae.
Aenean euismod tristique sollicitudin.
Vestibulum sed diam et arcu scelerisque rutrum eget
vitae sapien.
Quisque dui ligula, semper eget iaculis at, eleifend
at ligula.
Sed vestibulum tellus ac libero iaculis sit amet commodo
sapien pellentesque.
Cras quis dignissim neque.
Donec neque mauris, dictum tempus tincidunt in,
pellentesque sit amet dui.
I hope you can guess the pattern.
Now I do this mostly manual what is some kind of akward, especially if you add text in the middle of the sentence. My question would be, how can i do this automagically?
I know that I can use "gq100" to force a linebreak on the next 100 lines, but this does not do exactly what I want. It would be great if this is not really a hard linebreak but only a virtual one, which means when I put the cursor in the line starting with "Lorem ipsum" I can copy and past the whole sentence with y and p as if there wouldn't be any linebreak at all.
Does someone have an idea on this one?
Cheers,
T
Do you mean: If a line starts with 3 spaces, it belong to previous sentence?
You can do this:
:set textwidth=0
:set wrap
:set showbreak=\ \ \
Note: there's a space after every \.
Try to type a very lone line. It'll auto wrap. And the next line starts with 3 spaces.
I guess this is what you are looking for, the breakindent patch for vim:
http://sqizit.bartletts.id.au/2011/01/31/vim-and-breakindent/
Related
I am working on text files (copied and pasted from a facebook group) I have stripped out all the strings "Like" "Comment" comment numbers etc with group of sed commands . I am left with lines that look like this:
Jane Doe
Jane Doe Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Donec ac urna ut quam sagittis placerat id vitae justo.
John Doe
John Doe Maecenas id justo tempus, auctor velit in, porta nibh.
John Doe
John Doe Maecenas id justo tempus, auctor velit in, porta nibh.
Fred Crun
Fred Crun Maecenas id justo tempus, auctor velit in, porta nibh. Mauris bibendum et ligula molestie faucibus. Nullam feugiat tristique sapien non fringilla.
Fred Crun
Fred Crun Maecenas id justo tempus, auctor velit in, porta nibh. Mauris bibendum et ligula molestie faucibus. Nullam feugiat tristique sapien non fringilla.
Frank Zappa
Frank Zappa Suspendisse malesuada libero id tortor scelerisque feugiat. Suspendisse vel feugiat est. Vestibulum vel nisl magna. Aenean viverra diam vel vulputate pulvinar. In hac habitasse platea dictumst.
I am looking for a regexp for sed or other Unix utility that would remove the name on the line(s) with no other text following, leaving the lines looking like this:
Jane Doe Lorem ipsum dolor sit amet, consectetur adipiscing elit.
John Doe Maecenas id justo tempus, auctor velit in, porta nibh.
John Doe Maecenas id justo tempus, auctor velit in, porta nibh.
Fred Crun Maecenas id justo tempus, auctor velit in, porta nibh. Mauris bibendum et ligula molestie faucibus. Nullam feugiat tristique sapien non fringilla
Fred Crun Maecenas id justo tempus, auctor velit in, porta nibh. Mauris bibendum et ligula molestie faucibus. Nullam feugiat tristique sapien non fringilla.
Frank Zappa Suspendisse malesuada libero id tortor scelerisque feugiat. Suspendisse vel feugiat est. Vestibulum vel nisl magna. Aenean viverra diam vel vulputate pulvinar. In hac habitasse platea dictumst.
ode here.
. I looked at uniq and several examples of regep in gvim but I could not see a way to achieve my aim . Names may consist of 3 words.
This might work for you (GNU sed):
sed -E 'N;/^(.*)\n\1./!P;D' file
Open a two line window throughout the length of the file.
If the whole of the first line is the same as the start of the second, do not print it.
Delete the first line and repeat.
In Vim you can do the following:
:%s/^\(.*\)\n\1/\1
Which looks for a line, followed by \n and the same line (plus potentially something after, it is not specified) and replaces it with the pattern found, removing the first part.
if your data in d file, tried on gnu sed:
sed -E '/^\w+\s\w+\s*$/{N;s/([^\n]+)\n(\1.+)/\2/;b};d' d
I cannot get the MS recommended 'work-around' for COUNTIF/COUNTIFS criteria greater than 255 characters to produce any result beyond a worksheet #VALUE! error.
Source: COUNTIF function
Wrong value returned The COUNTIF function returns incorrect results when you use it to match stringsfor long strings longer than 255 characters. To match strings longer than 255 characters, use the CONCATENATE function or the concatenate operator &. For example, =COUNTIF(A2:A5,"long string"&"another long string")
Sample text string with a 504 character length string in A2:A5,
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur et mi congue, ullamcorper, nulla non, interdum augue. Etiam at turpis sagittis, auctor ante quis, imperdiet neque. Nulla ut mauris ac enim rutrum congue. Vivamus elementum nisi et lectus scelerisque bibendum. Mauris tristique condimentum purus, dictum sagittis velit. Cras non purus ut magna placerat suscipit nec sit amet est. Nam finibus sed nibh ac euismod. Nam fermentum mattis quam, a commodo elit suscipit nec. In eu ipsum iaculis.
Formula per support.office.com recommendations,
'this exceeds 255 character limit
=countif(a:a, a2)
'this is the recommended work-around
=countif(a:a, left(a2, 255)&mid(a2, 256, 255))
'alternate for a2 < 256 characters
=countif(a:a, left(a2, 255)&iferror(mid(a2, 256, 255), text(,)))
Result should be 4. I cannot get anything but #VALUE! if A2 contains any text with a length longer than 255.
Hard-coding the first 255 characters suffixed with the second remaining 249 characters does nothing but return the same #VALUE! error.
=COUNTIF(A:A, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur et mi congue, ullamcorper, nulla non, interdum augue. Etiam at turpis sagittis, auctor ante quis, imperdiet neque. Nulla ut mauris ac enim rutrum congue. Vivamus elementum nisi et lectus s"&"celerisque bibendum. Mauris tristique condimentum purus, dictum sagittis velit. Cras non purus ut magna placerat suscipit nec sit amet est. Nam finibus sed nibh ac euismod. Nam fermentum mattis quam, a commodo elit suscipit nec. In eu ipsum iaculis.")
I guess you want a question. Does this work at all? What am I missing? Is it my xl2010/xl2016 versions? The documentation I've referred to seems current.
Addendum:
If this does not work as described (or even as imagined) then a proof of a broken concept is easily an acceptable answer.
This will do strings up to 508 character fairly reliably.
=COUNTIFS(D1:D5,LEFT(D1,254)&"*",D1:D5,"*" &RIGHT(D1,254))
It will, in fact, do larger strings by comparing the last 254 and the first 254. Which may or may not suffice for individual requirements.
But may give false positives if the search parameters are shorter than 255 and, the to be searched ends and begins with the same text. For example test test will be counted twice if A1 is test.
I was wondering if it would be possible to run the vim spell checker while coding with PHP.
I can run it if I disable syntax highlighting, and it highlights almost all methods/function names because they are not English words.
So, my question is this, can I run the spell check on just the strings within PHP files?
For example, just within the ' quotes (and " quotes), ignoring everything else:
$paragraph = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. In est libero, dictum ut suscipit eget, lacinia in justo. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Praesent sit amet sem libero, in pretium enim. Pellentesque tortor ante, imperdiet quis mattis in, tincidunt et ligula. Cras porta velit a ligula venenatis placerat.';
$paragraph2 = "Vestibulum quis eleifend lectus. Vestibulum odio odio, mollis at eleifend a, adipiscing sed quam. Nam quis nisi quis mauris faucibus hendrerit eu a leo. Sed feugiat purus sit amet purus congue quis semper diam malesuada. Vivamus et enim non arcu pretium sollicitudin. Nullam blandit, lorem eu aliquet tincidunt, enim mauris placerat lectus, id faucibus nulla lectus non elit. Sed eget fermentum lacus. Ut tempus pulvinar neque, vel pellentesque purus aliquet quis. Vivamus molestie pretium quam at imperdiet. Maecenas diam turpis, malesuada ut sollicitudin ac, congue eleifend urna. Quisque id ipsum eget ipsum tempus blandit at vel magna. Fusce eu felis metus.";
see the vim help: :help spell-syntax
You can define particular syntax groups as having spell checking.
There's probably a better way to do it (using a ~/.vim/after/syntax/php.vim file?), but a simple hack is to make a personal version of the php syntax file in ~/.vim/syntax (you can do this by doing :e $VIMRUNTIME/syntax/php.vim and the :saveas ~/.vim/syntax/php.vim), and change all instances of the text contains=#phpAddStrings to contains=#Spell,#phpAddStrings. Next time you open a php file, turn on spell checking as normal with :set spell.
I'm currently doing something like:
a\hfill{}b
which puts 'a' at the far left, and 'b' at the far right of the page. However, I'd like 'b' to be exactly half way. Is there a \hfill equivalent where I can say \hfill{0.5\textwidth}?
I don't know the width of 'a'.
Obviously, I could use tabular, or maybe minipage, but the rest of the code here is pretty complicated, so I'd rather not mess with it.
Edit:
a and b are both subfloats (subfigure) with lstinputlistings in them.
\documentclass{article}
\begin{document}
\noindent\hbox to 0.5\textwidth{a}b
Curabitur viverra ligula a dui condimentum tempus. Aenean convallis, massa ut fermentum
convallis, leo justo iaculis lectus, quis molestie orci ligula ut leo. Quisque vitae neque
sit amet tortor convallis rhoncus ac at nibh. Cras sit amet mauris sit amet neque
tincidunt iaculis non non ante. Proin quis nisi porttitor enim adipiscing bibendum et
fermentum magna. Morbi sapien nibh, venenatis in fringilla id, laoreet ut libero.
\end{document}
NB: this works if width of a is less than 0.5\textwidth so the multicol answer is probably more reasonable
a\hfill{}b\hspace{0.5\textwidth}
You could try a multicol environment with columnsep set to 0.
There is, by the way, also a way to measure the size of a rendered part, through \settowidth and \settoheight.
Try replacing \hfill to \hskip 0pt plus 1fill and you can do amazing things. For example,
a\hskip 0pt plus .35 fill b\hskip 0pt plus .65 fill
For the life of me, I cannot figure out the cause of this: when writing in LaTeX documents, I like to keep my line width to maximum of 80 characters. As such, I will execute the vim command gqap and vim will automatically re-wordwrap the paragraph I am writing.
For example, it will cause a long line to become many shorter ones:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque pharetra nunc eget arcu dapibus pretium. Nulla vel risus quam, ut sollicitudin sem. Vivamus vitae diam in risus pharetra gravida. Donec rutrum mattis nulla, in consectetur lorem luctus varius. Donec augue purus, iaculis eget fringilla nec, vehicula ut sapien. Quisque sit amet dolor mauris. Sed ac est eu ligula aliquam tincidunt. Proin condimentum rutrum lacinia.
becomes:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque pharetra
nunc eget arcu dapibus pretium. Nulla vel risus quam, ut sollicitudin sem.
Vivamus vitae diam in risus pharetra gravida. Donec rutrum mattis nulla, in
consectetur lorem luctus varius. Donec augue purus, iaculis eget fringilla nec,
vehicula ut sapien. Quisque sit amet dolor mauris. Sed ac est eu ligula aliquam
tincidunt. Proin condimentum rutrum lacini
But, for some paragraphs, it will start adding unusual indentions towards the end of the paragraph:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque pharetra
nunc eget arcu dapibus pretium. Nulla vel risus quam, ut sollicitudin sem.
Vivamus vitae diam in risus pharetra gravida. Donec rutrum mattis nulla, in
consectetur lorem luctus varius. Donec augue purus, iaculis eget fringilla,
vehicula ut sapien. Quisque sit amet dolor mauris. Sed ac est eu ligula
tincidunt. Proin condimentum rutrum lacini
Why does vim do this? I have yet to figure out the pattern. How can I make it format paragraphs "the correct way"?
Yes, vim's 'smartindent' is not well named. I had trouble with this for a while before I figured out what was wrong. For others, if you notice strange indenting behavior after lines starting with "if" or "for", unset smartindent. You will come across this a lot if you start using vim as a word processor.
From the vim help file, 'smartindent' will indent after a line starting with a keyword from 'cinwords', which is "if,else,while,do,for,switch", by default.
The problem was that I had "smartindent" enabled. Disabling this for LaTeX documents solved it:
au BufEnter *.tex set nosmartindent