-
-
Save codepedia/d45f71162e3f16648aa44eb7d72754e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:%s/<Ctrl-V><Ctrl-M>//g | |
find spaces before end of line and remove it ..anything before this "$" | |
:%s/\s\+$//g | |
#ctrlP plugin | |
:h ctrlp-mapping | |
#repeat a char | |
E.g. Esc 4 i J Esc will output JJJJ. | |
#trailing space finder | |
:%s/\s$/ | |
# vim colors are here | |
ls ls /usr/share/vim/vim74/colors/ | |
# reading a file | |
:put =readfile('/path/to/foo/foo.c')[146:226] | |
#OR | |
:r file_name | |
#OR | |
:r! sed -n 147,227p /path/to/foo/foo.c | |
# find lines that start with a space and end with space, but they are actual lines in the file. | |
^I^I^I^I^I^I$ | |
^I^I^I^I^I^I$ | |
^I^I^I^I^I^I$ | |
^I^I^I^I^I^I$ | |
/^\s\+$ | |
======================================================= | |
#bash-4.1$ file somefile.txt | |
somefile.txt: Little-endian UTF-16 Unicode text, with CRLF, CR line terminators | |
WHen the file is read for insertion by sql server, it says: | |
[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax near '��B'. (SQL-42000) | |
[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Unclosed quotation mark after the character string '��B'. (SQL-42000) at | |
To fix : open the file with VIM and convert the charset from 16 based to 8 based. | |
:set fileencoding=utf8 | |
Now | |
#bash-4.1$ file somefile.txt | |
somefile.txt: UTF-8 Unicode (with BOM) text, with CRLF line terminators | |
======================================================= | |
# doing file on the file outputs. Need to look into how to work with this formt. | |
somefile.xls CDF V2 Document, Little Endian, Os: Windows, Version 6.1, Code page: 1252 | |
file somefile.txt prints =>> ASCII text, with CR line terminators >> ^M. >> doing :%s/^M/\r/g made it show "ASCII text" | |
help digraph-table | |
char digraph hex dec official name | |
^@ NU 0x00 0 NULL (NUL) | |
^A SH 0x01 1 START OF HEADING (SOH) | |
^B SX 0x02 2 START OF TEXT (STX) | |
^C EX 0x03 3 END OF TEXT (ETX) | |
^D ET 0x04 4 END OF TRANSMISSION (EOT) | |
^E EQ 0x05 5 ENQUIRY (ENQ) | |
# diff two files and save the result to html file. | |
vimdiff f1 f2 -c TOhtml -c 'w! diff.html' -c 'qa!' | |
# Delete the column in a tab-del file | |
:%s/^[^\t]*\t// | |
:%s/^[^\t]// <<= deletes the first char of a column | |
# sort a file by x column | |
# nice read : https://jordanelver.co.uk/blog/2014/03/12/sorting-columnds-of-text-in-vim-using-sort/ | |
:%!column -t | |
# sort by first column | |
:%!sort -k1nr | |
# search and replac ein a specific column. | |
:1,2 s/\%3cBBB/YYY/ | |
\%3c means third column (see :help /\%c or more globally :help pattern) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment