Hello,

I installed Ubuntu a few months ago on my work laptop and I’ve been running and loving it since.

However, I am used to VsCode, so this is what I am using in Ubuntu as well.

So I am curious, what kind of coding so you do? And what is your workflow.

I am an embedded firware developper and mainly use C. I am cross compiling my code in VsCode for a FPGA from Xilinx (dual core arm + PL)

Never dove into make files and cmake more than what I needed in the past, but I had an opportunity to learn CMake and build a project from it.

So my workflow is :

  1. Code in VsCode
  2. Build in CMake
  3. Transfer the app through scp on the target with a custom script (target is running petalinux, which is yocto + Xilinx recipes)
  4. Use gdb server to debug the code.

It’s a pretty simple workflow, but I’d like to know what you guys are running so that I can maybe upgrade my workflow.

  • ffhein
    link
    41 year ago

    I guess a few hours until I had memorised basic stuff like moving around, copy-paste, etc. Then maybe a week or two before I really felt comfortable with it. There’s some point where you actually understand vim and start using it more like a programming language and less like a traditional text editor. For example I love the “repeat last command” (default bound to . key), but to use it effectively you need to create a command that will be usable everywhere you want it to, and there are many different commands that do the same thing.

    Here’s a random example:

    Let’s say you have the following text in a document you’re editing with vim, and you want to delete the word “dance”. Vim is currently in normal mode, and with the cursor placed on the highlighted “c”:

    Monkey dance party

    If your brain is still in Notepad.exe mode, you might achieve this by pressing “i” to go into insert mode and using a combination of backspace and delete to edit the line.

    A vim beginner might know that “x” and “X” in normal mode works like delete and backspace, without going to insert mode, so “XXXxx” does the same.

    Someone who has learned basic movement could instead solve this by combining two commands, first “b” to move the cursor back to the beginning of the word, followed by “dw” (delete to next word).

    But there’s also a single command that deletes the current word, regardless of where the cursor is in it, which is “daw”. And since this is a single command, you can repeat it with the “.” key to delete a different word.

    Now here comes the vim magic: If you instead want to replace the word “dance” with “pool” you just modify the above commands by replacing “d” (delete) with “c” (change). So in our example you could type “caw” in normal mode, which deletes the word under the cursor and places you in insert mode. There you write “pool” and press Escape to go back to normal mode. Now you have a single command that replaces any word under the cursor with the word pool, which you can repeat anywhere you like.

    And if it’s not just the current word you want to change, then replace the “w” in the command with something else, for example “ca)” will change a pair of parenthesis and everything inside them, which is very useful when programming C/C++/etc… And if you have nested parentheses and want do something with two levels at the same time, the command becomes “c2a)” which might look complicated, but it’s basically just simple rules that you string together.

    https://vim-adventures.com/ might be a fun way to get started, then look up some nice vim cheat sheet and keep that nearby. I would also recommend looking up some example vim configs, because the editor is very bare bones with the defaults. I like relative line numbers for easy jumping between lines, so give that a try.

    When you’ve mastered (?) vim you’ll also see less (the program) keyboard shortcuts make a lot more sense. You can also change your shell to vi mode for faster editing of commands.

    • @[email protected]OP
      link
      fedilink
      11 year ago

      I will look into vim adventures. Trying to learn Vim at the same time as learning everything else is hard. So hopefully, a Vim game will be more palatable.