5

Vim is not properly indenting assembly code, regardless of if I want it to do it automatically or if I try gg=G it'll just says ## lines indented even though it didn't change anything and all my text is still left-aligned.

4 Answers 4

1

It appears that Vim does not do indenting of assembly out of the box. Looking in the /usr/share/vim/vim74/indent directory of Vim 7.4.335, there are no file names containing "asm" and neither grep -i asm * nor grep -i assembl * return any matches.

You could write your own indent plugin. See :help indent-expression for a start.

1
  • Writing my own plugin seems like a challenge, but it would give me some software credit and I could opensource it. This is the type of thing that can also go on a resume, right, if I wanted to? EDIT That was silly, putting something like that on a resume seems very stupid to me. In retrospect, I could publish it and that would...help the community, right? Could I then say I contribute to open-source software?
    – user339365
    Jul 2, 2014 at 19:11
0

Maybe vim didn't recognize filetype? Try

:set ft=nasm

and then run your indenting command.

or other options listed here https://stackoverflow.com/questions/782384/assembly-vim-syntax-highlighting

2
  • 2
    This changes the colors, but gg=G still doesn't work.
    – user339365
    Jul 2, 2014 at 17:28
  • 1
    I did look at that thread though, and it wasn't very helpful. All I got out of it was a new colorscheme better than my custom one.
    – user339365
    Jul 2, 2014 at 17:31
0

I know this method isn't perfect, but it may be useful to you:

cp /usr/share/vim/vim74/indent/python.vim ~/.vim/indent/nasm.vim

It will indent on a line after one that ends with :.

However, it won't unindent when you type a new label. Perhaps another syntax file would do the job.

0

vim-asm-indent

You might be interested in a file that sets indentation after a label and unindents a label.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .