Skip to content

Instantly share code, notes, and snippets.

@saurabh-sp-tripathi
Created July 6, 2018 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saurabh-sp-tripathi/d8c608351b4a62a4c22114d7295f18fa to your computer and use it in GitHub Desktop.
Save saurabh-sp-tripathi/d8c608351b4a62a4c22114d7295f18fa to your computer and use it in GitHub Desktop.

Vim task

  • write something "file1", "file2".... or
"uid1",
"uid2",
"uid3",
"uid4",
"uid5",
"uid6",
"uid7",
"uid8",
"uid9",
"uid10",

For such task do

:for i in range(1, 10) | put='uid'.i | endfor
//----loop logic ------|-loop-body---|--end--
/*
will write as
uid1
uid2
uid3 ....
*/

Rules The string literal in loop body has to single quoted The variable concatination (equivalent to '+' in other langs) : . (dot/period) any special symbol may need to escape like double quoutes example: to print the above in double quotes:

for i in range(1, 10) | put='\"uid'.i.'\",' | endfor
//--------------------| '\"uid'+i+''\"' ------ => "uid1",
/*
output:
"uid1",
"uid2",
"uid3",
....
*/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment