Differences between revisions 1 and 5 (spanning 4 versions)
Revision 1 as of 2020-04-28 16:32:47
Size: 623
Comment:
Revision 5 as of 2021-11-02 18:54:34
Size: 1179
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Vim Tricks = = Vim =
Line 9: Line 9:
== Quoting Words == Tips ==

=== Searching for Non-ASCII Characters ===

Vim regular expressions can use hexadecimal to represent non-ASCII code points, but the syntax differs for literal characters and character classes. To search for the number 0, try `/\%x30`. But to search for any non-ASCII code point, try `/[^\x00-\x7F]` (note: the omitted percent sign).

Similar syntax is available for Unicode code points, especially multibyte characters. To search for left curly quotes, try `/\%u201c`. To search for left or right curly quotes, try `/[\u201c-\u201d]`.



=== Quoting Words ===
Line 22: Line 32:

Vim


Tips

Searching for Non-ASCII Characters

Vim regular expressions can use hexadecimal to represent non-ASCII code points, but the syntax differs for literal characters and character classes. To search for the number 0, try /\%x30. But to search for any non-ASCII code point, try /[^\x00-\x7F] (note: the omitted percent sign).

Similar syntax is available for Unicode code points, especially multibyte characters. To search for left curly quotes, try /\%u201c. To search for left or right curly quotes, try /[\u201c-\u201d].

Quoting Words

Affixes can be applied programmatically using word deletion and registers. For example, to quote the currently selected word, use ciw'Ctrl+r"'.

  • ciw - delete selected word and enter insert mode

  • ' - insert the leading quote mark

  • Ctrl+r" - insert the contents of the " register, a.k.a. the deleted word

  • ' - insert the trailing quote mark

This method can be used to apply any affixes. To surround an SPSS string variable name with the trimming functions, use ciwrtrim(ltrim(Ctrl+r")).


CategoryRicottone

Vim (last edited 2024-02-22 13:11:59 by DominicRicottone)