I typically write all my software in the same way (omitting the TDD parts):
- Iterate pseudo code until it is granular enough that each part can be written in, hopefully, under 20 minutes.
- Implement each "pseudo"-component
Contrived example:
# Get file
# Open file
# Verify integrity
# Parse
# Close file
To encourage modularity i typically don't write these functions in "one" block. I write them in separate files or at least separate blocks and then "paste" them in. This is to ensure I'm not encouraged to add unnecessary dependencies. Right now, I'm literally copy->move to pseudocode-line->Paste over it with block of code, a function or method name, or whatever copy represents. This works very well for me and the code turns out nice. However, being lazy, I don't want to have to touch the mouse or do too much if there's a way to do it with less effort. I'm looking for a way to select->copy->replace a pseudocode-line with the selected:
In file Parse.c:
int ParseMyFile(char* fileName)
{
# Get file
return 0;
}
I would then write # Get file in another file or buffer:
{GetFileSomehow}
As a next step I would love to just mark this block of code, and replace # Get file
with the block to produce:
int ParseMyFile(char* fileName)
{
{GetFileSomehow}
return 0;
}
I tried experimenting with marks to copy&paste "onto" a mark, but it did not work well enough. I copied->move to mark-> replace line. I would love to get this down to copy->replace. I can not download extensions. I only have access to standard Vim. It must be less effort than physically marking the block, navigate to the correct pseudo-line, and paste it. It may not sound like a lot of work, but I write even very small blocks of code like this, as little as 2-3 lines if it helps me reason about the code. It adds up.
:r
(:read
) command does what you want? It can read an external file into the current cursor position...shift+v
) and then past whatever you have copied withp
?vimrc
, but that seems implausible now I think about it. For maximum efficiency, I think you’re going to want to set up a function you can map to. Are you interested in this sort of solution, or were you hoping only to use standard Vim commands?