![]() The highlighting is token-based, but the tokens are rendered invisible by the syntax, and can be inserted with very convenient and intuitive mappings, which don't require you to remember anything: e.g., "bold-underline" could be specified with a string such as bu or ub. The latest version supports 8 configurable foreground and background colors, as well as all combinations of bold, underline, italic, etc. It's a bit like having "rich text" capability for plain text in Vim. See :h allowrevins.The Txtfmt plugin definitely provides the functionality you are looking for. Note: Setting/resetting 'paste' and 'compatible' can set/reset 'allowrevins'. You can ofcourse further automate this with a macro, a function or a binding This will make the easy i_Ctrl-N / i_Ctrl-P bindings available for a handy word reversal session. Just go over the options in :h 'complete'. ![]() Tip: You can set 'complete' exclusively (for the buffer, at least) to a completion option that is guaranteed to return no result. You should then hit Ctrl+_ again to get back to regular insert mode and keyboard layout and go on with editing. Notice that the cursor will move to the beginning of that word (it's reversed direction of writing, remember?) for an unsyntactic text file you can hit in insert mode Ctrl+x Ctrl+d which is guaranteed to fail to find any macro/function names in the current file (See :h i_CTRL-X_CTRL-D and :h complete for more information).Īnd voila! Completion lookup in reverse mode makes the looked up word reverse. Ysing Ctrl+e to cancel in-place completion does not seem to work in this case. Hit Ctrl+_ and then pick a completion ( i_Ctrl-x) method which is the most likely not to return any results for your word. Type your desired word in Insert mode, or move your cursor to the end of an already typed word. It was originally made for inserting bidirectional scripts. You set 'allowrevins' which let you hit Ctrl+_ in insert mode to start Reverse Insert mode. There is a tricky way to do this if you have Vim compiled with +rightleft. The python statement then reverses the line of input. So if you wanted some other line reversed, you would send that line number as argument. The "1" in the command tells vi to send line 1 to the python statement which we are executing: "print raw_input()". :1 ! python -c "print raw_input()"Īnd your text will be replaced to become: nohtyP Well you could use python itself to reverse the line through the filter command. Which shows the same thing so I guess that's it. \ gvca :let :let remember where it came from but a google search come this article on. Not sure what has to be compiled in or turned on but this only works sometimes. but I have had a lot of compatibility issues with that. If your version of VIM supports it you can do vw\is or viw\is (put your cursor at the first letter of the word before typing the command). This pipes your selection to your shell while passing it a command. Select what you want to reverse and filter ( %! ) it: :%! rev via MSys or Cygwin) then it's really not this difficult. ![]() The article indicates that the result will appear in the status bar, which would be non-optimal if you were trying to replace the string in a document, but if you just want to check that your girlfriend is properly reversing strings in her head, this should be fine. This article seems like a good explanation of how to use Python in VIM and I'm guessing you'd do something like this: :python 'word' I don't have Python supported on my VIM, but it looks like it would be pretty simple to do it with Python. The substitute command finds each word and then passes the word to the expressions and uses the result as replacement.Īssuming you've got perl support built in to vim, you can do this: command! ReverseWord call ReverseWord()Īnd potentially bind that to a keystroke like so: nmap ,r :ReverseWord This works by first creating a list of characters in the word, which is reversed and joined back to form the word. If you want to replace all words in the buffer, :%s/\(\\)/\=join(reverse(split(submatch(1), '.\zs')), '')/g Here is another (pythonic) solution based on how this works: :echo join(reverse(split('hello', '.\zs')), '') \:let are more solutions in the comments. For a single word you can use vw (or viw): viw\is vnoremap is :let Simply enable visual mode (v), highlight the characters you want inverted, and hit \is.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |